1
- /* Zigbee Common Functions */
2
- # include " Zigbee_core.h "
3
- #include " Zigbee_handlers.cpp "
4
- #include " Arduino.h "
1
+ /* Zigbee Core Functions */
2
+
3
+ #include " ZigbeeCore.h "
4
+ #if SOC_IEEE802154_SUPPORTED
5
5
6
+ #include " ZigbeeHandlers.cpp"
7
+ #include " Arduino.h"
6
8
7
- Zigbee_Core::Zigbee_Core () {
9
+ ZigbeeCore::ZigbeeCore () {
8
10
_radio_config = ZIGBEE_DEFAULT_RADIO_CONFIG ();
9
11
_host_config = ZIGBEE_DEFAULT_HOST_CONFIG ();
10
12
_zb_ep_list = esp_zb_ep_list_create ();
@@ -13,20 +15,20 @@ Zigbee_Core::Zigbee_Core() {
13
15
_scan_status = ZB_SCAN_FAILED;
14
16
_started = false ;
15
17
}
16
- Zigbee_Core ::~Zigbee_Core () {}
18
+ ZigbeeCore ::~ZigbeeCore () {}
17
19
18
20
// forward declaration
19
21
static esp_err_t zb_action_handler (esp_zb_core_action_callback_id_t callback_id, const void *message);
20
22
21
- bool Zigbee_Core ::begin (esp_zb_cfg_t *role_cfg, bool erase_nvs) {
23
+ bool ZigbeeCore ::begin (esp_zb_cfg_t *role_cfg, bool erase_nvs) {
22
24
if (!zigbeeInit (role_cfg, erase_nvs)){
23
25
return false ;
24
26
}
25
27
_role = (zigbee_role_t )role_cfg->esp_zb_role ;
26
28
return true ;
27
29
}
28
30
29
- bool Zigbee_Core ::begin (zigbee_role_t role, bool erase_nvs) {
31
+ bool ZigbeeCore ::begin (zigbee_role_t role, bool erase_nvs) {
30
32
bool status = true ;
31
33
switch (role)
32
34
{
@@ -55,13 +57,13 @@ bool Zigbee_Core::begin(zigbee_role_t role, bool erase_nvs) {
55
57
return status;
56
58
}
57
59
58
- void Zigbee_Core ::addEndpoint (Zigbee_EP *ep) {
60
+ void ZigbeeCore ::addEndpoint (ZigbeeEP *ep) {
59
61
ep_objects.push_back (ep);
60
62
61
63
log_d (" Endpoint: %d, Device ID: 0x%04x" , ep->_endpoint , ep->_device_id );
62
- // Register clusters and ep_list to the Zigbee_Core class's ep_list
64
+ // Register clusters and ep_list to the ZigbeeCore class's ep_list
63
65
if (ep->_ep_config .endpoint == 0 || ep->_cluster_list == nullptr ) {
64
- log_e (" Endpoint config or Cluster list is not initialized, EP not added to Zigbee_Core 's EP list" );
66
+ log_e (" Endpoint config or Cluster list is not initialized, EP not added to ZigbeeCore 's EP list" );
65
67
return ;
66
68
}
67
69
@@ -75,7 +77,7 @@ static void esp_zb_task(void *pvParameters) {
75
77
}
76
78
77
79
// Zigbee core init function
78
- bool Zigbee_Core ::zigbeeInit (esp_zb_cfg_t *zb_cfg, bool erase_nvs) {
80
+ bool ZigbeeCore ::zigbeeInit (esp_zb_cfg_t *zb_cfg, bool erase_nvs) {
79
81
// Zigbee platform configuration
80
82
esp_zb_platform_config_t platform_config = {
81
83
.radio_config = _radio_config,
@@ -105,7 +107,7 @@ bool Zigbee_Core::zigbeeInit(esp_zb_cfg_t *zb_cfg, bool erase_nvs) {
105
107
106
108
// print the list of Zigbee EPs from ep_objects
107
109
log_i (" List of registered Zigbee EPs:" );
108
- for (std::list<Zigbee_EP *>::iterator it = ep_objects.begin (); it != ep_objects.end (); ++it) {
110
+ for (std::list<ZigbeeEP *>::iterator it = ep_objects.begin (); it != ep_objects.end (); ++it) {
109
111
log_i (" Device type: %s, Endpoint: %d, Device ID: 0x%04x" , getDeviceTypeString ((*it)->_device_id ), (*it)->_endpoint , (*it)->_device_id );
110
112
}
111
113
}
@@ -128,27 +130,27 @@ bool Zigbee_Core::zigbeeInit(esp_zb_cfg_t *zb_cfg, bool erase_nvs) {
128
130
return true ;
129
131
}
130
132
131
- void Zigbee_Core ::setRadioConfig (esp_zb_radio_config_t config) {
133
+ void ZigbeeCore ::setRadioConfig (esp_zb_radio_config_t config) {
132
134
_radio_config = config;
133
135
}
134
136
135
- esp_zb_radio_config_t Zigbee_Core ::getRadioConfig () {
137
+ esp_zb_radio_config_t ZigbeeCore ::getRadioConfig () {
136
138
return _radio_config;
137
139
}
138
140
139
- void Zigbee_Core ::setHostConfig (esp_zb_host_config_t config) {
141
+ void ZigbeeCore ::setHostConfig (esp_zb_host_config_t config) {
140
142
_host_config = config;
141
143
}
142
144
143
- esp_zb_host_config_t Zigbee_Core ::getHostConfig () {
145
+ esp_zb_host_config_t ZigbeeCore ::getHostConfig () {
144
146
return _host_config;
145
147
}
146
148
147
- void Zigbee_Core ::setPrimaryChannelMask (uint32_t mask) {
149
+ void ZigbeeCore ::setPrimaryChannelMask (uint32_t mask) {
148
150
_primary_channel_mask = mask;
149
151
}
150
152
151
- void Zigbee_Core ::setRebootOpenNetwork (uint8_t time) {
153
+ void ZigbeeCore ::setRebootOpenNetwork (uint8_t time) {
152
154
_open_network = time;
153
155
}
154
156
@@ -258,7 +260,7 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
258
260
*/
259
261
260
262
// for each endpoint in the list call the find_endpoint function if not bounded or allowed to bind multiple devices
261
- for (std::list<Zigbee_EP *>::iterator it = Zigbee.ep_objects .begin (); it != Zigbee.ep_objects .end (); ++it) {
263
+ for (std::list<ZigbeeEP *>::iterator it = Zigbee.ep_objects .begin (); it != Zigbee.ep_objects .end (); ++it) {
262
264
if (!(*it)->_is_bound || (*it)->_allow_multiple_binding ) {
263
265
(*it)->find_endpoint (&cmd_req);
264
266
}
@@ -280,16 +282,16 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
280
282
}
281
283
}
282
284
283
- void Zigbee_Core ::factoryReset () {
285
+ void ZigbeeCore ::factoryReset () {
284
286
log_v (" Factory reseting Zigbee stack, device will reboot" );
285
287
esp_zb_factory_reset ();
286
288
}
287
289
288
- bool Zigbee_Core ::isStarted () {
290
+ bool ZigbeeCore ::isStarted () {
289
291
return _started;
290
292
}
291
293
292
- void Zigbee_Core ::scanCompleteCallback (esp_zb_zdp_status_t zdo_status, uint8_t count, esp_zb_network_descriptor_t *nwk_descriptor){
294
+ void ZigbeeCore ::scanCompleteCallback (esp_zb_zdp_status_t zdo_status, uint8_t count, esp_zb_network_descriptor_t *nwk_descriptor){
293
295
log_v (" Zigbee network scan complete" );
294
296
if (zdo_status == ESP_ZB_ZDP_STATUS_SUCCESS) {
295
297
log_v (" Found %d networks" , count);
@@ -310,7 +312,7 @@ void Zigbee_Core::scanCompleteCallback(esp_zb_zdp_status_t zdo_status, uint8_t c
310
312
}
311
313
}
312
314
313
- void Zigbee_Core ::scanNetworks (u_int32_t channel_mask, u_int8_t scan_duration) {
315
+ void ZigbeeCore ::scanNetworks (u_int32_t channel_mask, u_int8_t scan_duration) {
314
316
if (!_started) {
315
317
log_e (" Zigbee stack is not started, cannot scan networks" );
316
318
return ;
@@ -320,15 +322,15 @@ void Zigbee_Core::scanNetworks(u_int32_t channel_mask, u_int8_t scan_duration) {
320
322
_scan_status = ZB_SCAN_RUNNING;
321
323
}
322
324
323
- int16_t Zigbee_Core ::scanComplete (){
325
+ int16_t ZigbeeCore ::scanComplete (){
324
326
return _scan_status;
325
327
}
326
328
327
- zigbee_scan_result_t * Zigbee_Core ::getScanResult () {
329
+ zigbee_scan_result_t * ZigbeeCore ::getScanResult () {
328
330
return _scan_result;
329
331
}
330
332
331
- void Zigbee_Core ::scanDelete () {
333
+ void ZigbeeCore ::scanDelete () {
332
334
if (_scan_result != nullptr ) {
333
335
free (_scan_result);
334
336
_scan_result = nullptr ;
@@ -337,7 +339,7 @@ void Zigbee_Core::scanDelete() {
337
339
}
338
340
339
341
// Function to convert enum value to string
340
- const char * Zigbee_Core ::getDeviceTypeString (esp_zb_ha_standard_devices_t deviceId) {
342
+ const char * ZigbeeCore ::getDeviceTypeString (esp_zb_ha_standard_devices_t deviceId) {
341
343
switch (deviceId) {
342
344
case ESP_ZB_HA_ON_OFF_SWITCH_DEVICE_ID: return " General On/Off switch" ;
343
345
case ESP_ZB_HA_LEVEL_CONTROL_SWITCH_DEVICE_ID: return " Level Control Switch" ;
@@ -381,4 +383,6 @@ const char* Zigbee_Core::getDeviceTypeString(esp_zb_ha_standard_devices_t device
381
383
}
382
384
}
383
385
384
- Zigbee_Core Zigbee = Zigbee_Core();
386
+ ZigbeeCore Zigbee = ZigbeeCore();
387
+
388
+ #endif // SOC_IEEE802154_SUPPORTED
0 commit comments