forked from alekslt/HANToMQTT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHanReader.h
58 lines (47 loc) · 1.4 KB
/
HanReader.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
#ifndef _HANREADER_h
#define _HANREADER_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#include <HardwareSerial.h>
#else
#include "WProgram.h"
#endif
#include <vector>
#include "DlmsReader.h"
struct ClockDeviation;
struct Element;
struct ObisElement;
class HanReader
{
public:
std::vector<ObisElement*> cosemObjectList;
HanReader();
void setup(HardwareSerial *hanPort, Stream *debugPort);
void setGetEpochTime(GETEPOCHTIME_FN function) { getEpochTime = function; }
void setNetworkLogger(LOG_FN function) { netLog = function; }
void setSendBuffer(SENDBUFFER_FN function) { sendBuffer = function; }
bool read();
bool read(byte data);
unsigned long messageTimestamp() { return reader.messageTimestamp; }
private:
uint8_t debugLevel;
Stream *debug;
GETEPOCHTIME_FN getEpochTime;
LOG_FN netLog;
SENDBUFFER_FN sendBuffer;
HardwareSerial *han;
int bytesRead;
DlmsReader reader;
byte* userData;
int userDataLen;
void Init();
void printObjectStart(uint16_t pos);
bool decodeClockAndDeviation(byte* buf, ClockDeviation& element);
bool decodeAndApplyScalerElement(uint16_t& nextPos, ObisElement* element);
bool decodeDataElement(uint16_t& nextPos, Element& element);
bool decodeListElement(uint16_t& nextPos, ObisElement* obisElement);
bool decodeAidonMeter();
bool decodeKaifaKamstrupMeter();
void debugPrint(byte *buffer, int start, int length);
};
#endif