-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathESP_SHD_ContactSensor.h
50 lines (38 loc) · 1.27 KB
/
ESP_SHD_ContactSensor.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
#include "ESP_SmartHomeDevice.h"
#include <SoftwareSerial.h>
#define DEBUG 5
#define MQTT_TOPIC_SIZE 70
#define MQTT_PAYLOAD_BUFFER_SIZE 10
enum contactSensorType {
CS_NORMAL = 0,
CS_LSC_DOOR_SENROR = 1
};
enum csStatus {
CS_OPENED, CS_CLOSED, CS_ERROR
};
class ShdContactSensor : public ESP_SmartHomeDevice {
public:
ShdContactSensor(contactSensorType _type, bool _sleepAfterPublish, bool _getBatteryStatus);
ShdContactSensor(contactSensorType _type, uint8_t _pin, bool _lowAcive, bool _sleepAfterPublish, uint16_t _intervalMillis, bool _getBatteryStatus);
private:
static uint8_t contactSensorCount;
void timer5msHandler();
bool handleMqttRequest(char* _topic, unsigned char* _payload, uint16_t _length);
void republish();
char payloadBuffer[50];
contactSensorType csType;
char pubTopicState[MQTT_TOPIC_SIZE];
csStatus lastStatus;
bool sleepAfterPublish;
uint8_t csNumber;
bool getBatteryStatus;
char pubTopicBattery[MQTT_TOPIC_SIZE];
uint8_t pin;
bool lowActive;
uint16_t updateInterval, updateCounter;
void getStatus();
csStatus getStatusNormal();
csStatus getStatusLsc();
void lscCommunication(byte _cmd, byte _len, byte _value, uint8_t* _reply, uint8_t _maxReplySize, uint8_t* _replySize);
SoftwareSerial swSerial; // REMOVE!
};