forked from Jipede/SolaDin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Soladin.h
82 lines (66 loc) · 1.65 KB
/
Soladin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
Soladin.h - Library for comunicating to a Soladin 600.
Created by Teding, November , 2011.
Released into the public domain.
*/
#ifndef Soladin_h
#define Soladin_h
// commands
#define PRB 0xC1
#define FWI 0xB4
#define DVS 0xB6
#define HSD 0x9A
#define RMP 0xB9
#define ZMP 0x97
// adress
#define null 0x00
#define dest 0x11
// action
#define Ac_zmp 0x01
#define TimeOut 100 // 100 ms
#define dly 50 // 50 ms give me time to push some buttons
//#include "Arduino.h"
#include <SoftwareSerial.h>
class Soladin
{
public:
void begin(SoftwareSerial *theSerial);
Soladin(); // constructer
bool query(uint8_t Cmdo);
bool query(uint8_t Cmdo,uint8_t _day); // overload
// variable from devstate call
uint16_t Flag ;
uint16_t PVvolt ;
uint16_t PVamp ;
uint16_t Gridfreq ;
uint16_t Gridvolt ;
uint16_t Gridpower ;
uint32_t Totalpower ;
uint8_t DeviceTemp ;
uint32_t TotalOperaTime ;
// variable from Firware info call
uint8_t FW_ID;
uint16_t FW_version;
uint16_t FW_date;
// variable from Max power call
uint16_t MaxPower;
// variable from historical data call
uint8_t DailyOpTm ;
uint16_t Gridoutput ;
// communication status
char RxBuf[40];
uint8_t RxLgth ;
uint16_t RxError ;
private:
SoftwareSerial *_serial;
void conCat(uint8_t _cmd, uint8_t _act, char *OutBuf);
void sndBuf(int size, char *OutBuf);
bool txRx(uint8_t Cmdo);
void DS_deCode(char *InBuf);
void FW_deCode(char *InBuf);
void MP_deCode(char *InBuf);
void HD_deCode(char *InBuf);
int PolRxBuf(uint8_t Cmd);
char TxBuf[9];
};
#endif