-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathZigbeeGateway.h
More file actions
113 lines (83 loc) · 3.89 KB
/
ZigbeeGateway.h
File metadata and controls
113 lines (83 loc) · 3.89 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* Class of Zigbee Temperature sensor endpoint inherited from common EP class */
#pragma once
#include "soc/soc_caps.h"
#include "sdkconfig.h"
#if SOC_IEEE802154_SUPPORTED
//&& CONFIG_ZB_ENABLED
#include "ZigbeeEP.h"
#include "ha/esp_zigbee_ha_standard.h"
//define the thermostat configuration to avoid narrowing conversion issue in zigbee-sdk
#define ZB_DEFAULT_GATEWAY_CONFIG() \
{ \
.basic_cfg = \
{ \
.zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE, \
.power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE, \
}, \
.identify_cfg = \
{ \
.identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE, \
} \
}
typedef struct findcb_userdata_s {
uint8_t _endpoint;
uint16_t _cluster_id;
} findcb_userdata_t;
class ZigbeeGateway : public ZigbeeEP {
public:
ZigbeeGateway(uint8_t endpoint);
~ZigbeeGateway();
std::list<zb_device_params_t *> getGatewayDevices() const {
return _gateway_devices;
}
void addGatewayDevice(zb_device_params_t * device){
if (device) _gateway_devices.push_back(device);
}
std::list<zb_device_params_t *> getJoinedDevices() const {
return _joined_devices;
}
zb_device_params_t * getLastJoinedDevice() {
zb_device_params_t *last_joined_device = NULL;
if (!_joined_devices.empty()) {
last_joined_device = _joined_devices.back();
_joined_devices.pop_back();
}
return last_joined_device;
}
void printGatewayDevices();
void printJoinedDevices();
static bool isNewDeviceJoined() {
return _new_device_joined;
}
static void clearNewDeviceJoined(){
_new_device_joined = false;
}
static void bindDeviceCluster(zb_device_params_t *,int16_t cluster_id );
void setIASZReporting(uint16_t min_interval, uint16_t max_interval);
void onStatusNotification(void (*callback)(int, uint8_t *)) {
_on_status_notification = callback;
}
void onConfigRecieve(void (*callback)(float, float, float)) {
_on_config_recieve = callback;
}
private:
// save instance of the class in order to use it in static functions
static ZigbeeGateway *_instance;
static findcb_userdata_t findcb_userdata;
static bool _last_bind_success;
static bool _in_binding;
static bool _new_device_joined;
void (*_on_status_notification)(int, uint8_t *);
void (*_on_config_recieve)(float, float, float);
void findEndpoint(esp_zb_zdo_match_desc_req_param_t *cmd_req);
static void bindCb(esp_zb_zdp_status_t zdo_status, void *user_ctx);
static void find_Cb(esp_zb_zdp_status_t zdo_status, uint16_t addr, uint8_t endpoint, void *user_ctx);
void zbAttributeRead(esp_zb_zcl_addr_t src_address, uint16_t src_endpoint, uint16_t cluster_id, const esp_zb_zcl_attribute_t *attribute) override;
void zbIASZoneStatusChangeNotification(const esp_zb_zcl_ias_zone_status_change_notification_message_t *message) override;
void addBoundDevice(zb_device_params_t *device) override;
protected:
static SemaphoreHandle_t gt_lock;
std::list<zb_device_params_t *> _joined_devices;
std::list<zb_device_params_t *> _gateway_devices;
};
#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED