-
Notifications
You must be signed in to change notification settings - Fork 0
/
HMWModule.h
61 lines (45 loc) · 1.74 KB
/
HMWModule.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
/*
* HMWModule.h
*
* Created on: 09.05.2014
* Author: thorsten
*/
#ifndef HMWMODULE_H_
#define HMWMODULE_H_
#include "HMWRS485.h"
#include "Arduino.h"
// TODO: Firmware/Hardware Version aus EEPROM bzw. Flash?
#define MODULE_HARDWARE_VERSION 1
#define MODULE_FIRMWARE_VERSION 0x0306
// Abstrakte Basisklasse mit Callbacks aus dem Modul
class HMWDeviceBase {
public:
virtual void setLevel(byte,unsigned int) = 0; // channel, level
virtual unsigned int getLevel(byte) = 0; // channel, returns level
virtual void readConfig() = 0; // read config from EEPROM
};
class HMWModule : public HMWModuleBase {
public:
HMWModule(HMWDeviceBase*, HMWRS485*, byte); // rs485, device type
virtual ~HMWModule();
virtual void processEvent(byte const * const frameData, byte frameDataLength, boolean isBroadcast = false);
void broadcastAnnounce(byte); // channel
void broadcastKeyEvent(byte, byte, byte = 0); // channel, keyPressNum, long/short (long = 1)
void sendInfoMessage(byte, byte *ptr, byte length, unsigned long); // channel, info, target address
byte deviceType; // device type @ 0x7FF1 in FlashRom TODO: Not really...
// write to EEPROM, but only if not "value" anyway
// the uppermost 4 bytes are reserved for the device address and can only be changed if privileged = true
void writeEEPROM(int address, byte value, bool privileged = false );
void setNewId();
private:
HMWRS485* hmwrs485;
HMWDeviceBase* device;
void readAddressFromEEPROM();
void determineSerial(byte*);
void processEventKey();
void processEventSetLevel(byte channel, unsigned int level);
void processEventGetLevel(byte channel);
void processEventSetLock();
void processEmessage(byte const * const frameData);
};
#endif /* HMWMODULE_H_ */