-
Notifications
You must be signed in to change notification settings - Fork 1
/
TeleInfo.h
64 lines (45 loc) · 1.2 KB
/
TeleInfo.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
#ifndef Teleinfo_h
#define Teleinfo_h
#include <stdint.h>
#include "Arduino.h"
#include <Stream.h>
#define LABEL_MAX_SIZE 8
#define DATA_MAX_SIZE 13
#define LINE_MAX_COUNT 12
#define FRAME_MAX_SIZE 350
class TeleInfo
{
public:
//TeleInfo(uint8_t rxPin,uint8_t txPin);
TeleInfo(Stream* serial);
void begin();
boolean available();
void process();
void resetAvailable();
/**
* return NULL if this label is not found
*/
const char * getStringVal(const char * label);
/**
* return a negative valure if this label is not found
*/
long getLongVal(const char * label);
void printAllToSerial();
void setDebug(boolean debug);
private:
void resetAll();
int readLabel(int beginIndex, char* label);
int readData(int beginIndex, char* data);
boolean isChecksumValid(char *label, char *data, char checksum);
boolean readFrame();
Stream* _cptSerial;
//SoftwareSerial _serial;
boolean _isDebug = false;
boolean _isAvailable = false;
char _frame[FRAME_MAX_SIZE];
int _frameIndex = 0;
char _label[LINE_MAX_COUNT][LABEL_MAX_SIZE+1]; //+1 for '\0' ending
char _data[LINE_MAX_COUNT][DATA_MAX_SIZE+1];
int _dataCount = 0;
};
#endif