Skip to content

Commit fa6267a

Browse files
committed
Dev Update: Version setting, Thermostat fix, ...
Simplified bounded device print as the structure is common for any EP type Allowed setting custom app version for EP, default is 0 Small fixes and code updates
1 parent 4d18a8c commit fa6267a

20 files changed

+149
-236
lines changed

boards.txt

Lines changed: 42 additions & 42 deletions
Large diffs are not rendered by default.

libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Set the Button Switch GPIO by changing the `GPIO_SWITCH` definition. By default,
2424
To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits).
2525

2626
* Before Compile/Verify, select the correct board: `Tools -> Board`.
27-
* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator)`.
27+
* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator/router)`.
2828
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`.
2929
* Select the COM port: `Tools -> Port: xxx where the `xxx` is the detected COM port.
3030
* Optional: Set debug level to info to see logs from Zigbee stack: `Tools -> Core Debug Level: Info`.

libraries/Zigbee/examples/Zigbee_On_Off_Switch/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ Currently, this example supports the following targets.
1717

1818
### Configure the Project
1919

20-
Set the Button Switch GPIO by changing the `GPIO_INPUT_IO_TOGGLE_SWITCH` definition. By default, the LED_PIN is `GPIO_NUM_9`.
20+
Set the Button Switch GPIO by changing the `GPIO_INPUT_IO_TOGGLE_SWITCH` definition. By default, it's the pin `9` (BOOT button on ESP32-C6 and ESP32-H2).
2121

2222
#### Using Arduino IDE
2323

2424
To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits).
2525

2626
* Before Compile/Verify, select the correct board: `Tools -> Board`.
27-
* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator)`.
27+
* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator/router)`.
2828
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`.
2929
* Select the COM port: `Tools -> Port: xxx where the `xxx` is the detected COM port.
3030
* Optional: Set debug level to info to see logs from Zigbee stack: `Tools -> Core Debug Level: Info`.

libraries/Zigbee/examples/Zigbee_Thermostat/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Set the Button GPIO by changing the `BUTTON_PIN` definition. By default, it's th
3535
To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits).
3636

3737
* Before Compile/Verify, select the correct board: `Tools -> Board`.
38-
* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator)`.
38+
* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator/router)`.
3939
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`.
4040
* Select the COM port: `Tools -> Port: xxx where the `xxx` is the detected COM port.
4141
* Optional: Set debug level to info to see logs from Zigbee stack: `Tools -> Core Debug Level: Info`.

libraries/Zigbee/examples/Zigbee_Thermostat/Zigbee_Thermostat.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void setup() {
9393
// When all EPs are registered, start Zigbee with ZIGBEE_COORDINATOR mode
9494
Zigbee.begin(ZIGBEE_COORDINATOR);
9595

96-
Serial.println("Waiting for Light to bound to the switch");
96+
Serial.println("Waiting for Temperature sensor to bound to the switch");
9797
//Wait for switch to bound to a light:
9898
while(!zbThermostat.is_bound())
9999
{

libraries/Zigbee/library.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ author=P-R-O-C-H-Y
44
maintainer=Jan Procházka <jan.prochazka@espressif.com>
55
sentence=Enables zigbee connection with the ESP32
66
paragraph=With this library you can create zigbee end devices, routers, coordinators and connect them to the zigbee network.
7+
category=Communication
78
url=
89
architectures=esp32

libraries/Zigbee/src/Zigbee_core.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
244244
esp_zb_zdo_match_desc_req_param_t cmd_req;
245245
cmd_req.dst_nwk_addr = dev_annce_params->device_short_addr;
246246
cmd_req.addr_of_interest = dev_annce_params->device_short_addr;
247-
log_i("Device capabilities: 0x%02x", dev_annce_params->capability);
247+
log_v("Device capabilities: 0x%02x", dev_annce_params->capability);
248248
/*
249249
capability:
250250
Bit 0 – Alternate PAN Coordinator
@@ -257,8 +257,6 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
257257
Bit 7 – Reserved
258258
*/
259259

260-
//TODO: Save the device short address and endpoint to the list ????????
261-
262260
// for each endpoint in the list call the find_endpoint function if not bounded or allowed to bind multiple devices
263261
for (std::list<Zigbee_EP*>::iterator it = Zigbee.ep_objects.begin(); it != Zigbee.ep_objects.end(); ++it) {
264262
if (!(*it)->_is_bound || (*it)->_allow_multiple_binding) {
@@ -278,7 +276,7 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
278276
}
279277
}
280278
break;
281-
default: log_i("ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type, esp_err_to_name(err_status)); break;
279+
default: log_v("ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type, esp_err_to_name(err_status)); break;
282280
}
283281
}
284282

@@ -338,28 +336,6 @@ void Zigbee_Core::scanDelete() {
338336
_scan_status = ZB_SCAN_FAILED;
339337
}
340338

341-
// NOTE: Binding functions to not forget
342-
// void esp_zb_zdo_device_bind_req(esp_zb_zdo_bind_req_param_t *cmd_req, esp_zb_zdo_bind_callback_t user_cb, void *user_ctx)
343-
// {
344-
// uint8_t output = 0;
345-
// uint16_t outlen = sizeof(uint8_t);
346-
347-
// typedef struct {
348-
// esp_zb_zdo_bind_req_param_t bind_req;
349-
// esp_zb_user_cb_t bind_usr;
350-
// } esp_zb_zdo_bind_req_t;
351-
352-
// esp_zb_zdo_bind_req_t zdo_data = {
353-
// .bind_usr = {
354-
// .user_ctx = (uint32_t)user_ctx,
355-
// .user_cb = (uint32_t)user_cb,
356-
// },
357-
// };
358-
359-
// memcpy(&zdo_data.bind_req, cmd_req, sizeof(esp_zb_zdo_bind_req_param_t));
360-
// esp_host_zb_output(ESP_ZNSP_ZDO_BIND_SET, &zdo_data, sizeof(esp_zb_zdo_bind_req_t), &output, &outlen);
361-
// }
362-
363339
// Function to convert enum value to string
364340
const char* Zigbee_Core::getDeviceTypeString(esp_zb_ha_standard_devices_t deviceId) {
365341
switch (deviceId) {
@@ -386,6 +362,7 @@ const char* Zigbee_Core::getDeviceTypeString(esp_zb_ha_standard_devices_t device
386362
case ESP_ZB_HA_COLOR_DIMMABLE_LIGHT_DEVICE_ID: return "Color Dimmable Light Device";
387363
case ESP_ZB_HA_DIMMER_SWITCH_DEVICE_ID: return "Dimmer Switch Device";
388364
case ESP_ZB_HA_COLOR_DIMMER_SWITCH_DEVICE_ID: return "Color Dimmer Switch Device";
365+
case ESP_ZB_HA_LIGHT_SENSOR_DEVICE_ID: return "Light Sensor";
389366
case ESP_ZB_HA_SHADE_DEVICE_ID: return "Shade";
390367
case ESP_ZB_HA_SHADE_CONTROLLER_DEVICE_ID: return "Shade controller";
391368
case ESP_ZB_HA_WINDOW_COVERING_DEVICE_ID: return "Window Covering client";

libraries/Zigbee/src/Zigbee_ep.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Zigbee_EP::~Zigbee_EP() {
1818

1919
}
2020

21+
void Zigbee_EP::setVersion(uint8_t version) {
22+
_ep_config.app_device_version = version;
23+
}
24+
2125
void Zigbee_EP::setManufacturerAndModel(const char *name, const char *model) {
2226
// Convert manufacturer to ZCL string
2327
size_t length = strlen(name);
@@ -74,6 +78,14 @@ void Zigbee_EP::readManufacturerAndModel(uint8_t endpoint, uint16_t short_addr)
7478
esp_zb_zcl_read_attr_cmd_req(&read_req);
7579
}
7680

81+
void Zigbee_EP::printBoundDevices() {
82+
log_i("Bound devices:");
83+
for(const auto& device : _bound_devices) {
84+
log_i("Device on endpoint %d, short address: 0x%x", device->endpoint, device->short_addr);
85+
print_ieee_addr(device->ieee_addr);
86+
}
87+
}
88+
7789
void Zigbee_EP::readBasicCluster(uint16_t cluster_id, const esp_zb_zcl_attribute_t *attribute) {
7890
/* Basic cluster attributes */
7991
if (attribute->id == ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_CHAR_STRING && attribute->data.value) {

libraries/Zigbee/src/Zigbee_ep.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ typedef struct zbstring_s {
3131
} ESP_ZB_PACKED_STRUCT
3232
zbstring_t;
3333

34+
typedef struct zb_device_params_s {
35+
esp_zb_ieee_addr_t ieee_addr;
36+
uint8_t endpoint;
37+
uint16_t short_addr;
38+
} zb_device_params_t;
39+
3440
/* Zigbee End Device Class */
3541
class Zigbee_EP {
3642
public:
@@ -42,19 +48,23 @@ class Zigbee_EP {
4248

4349
static uint8_t _endpoint;
4450
esp_zb_ha_standard_devices_t _device_id; //type of device
45-
uint8_t _version;
4651

4752
esp_zb_endpoint_config_t _ep_config;
4853
esp_zb_cluster_list_t *_cluster_list;
54+
std::list<zb_device_params_t*> _bound_devices;
55+
56+
static bool _is_bound;
4957

5058
// Set ep config and cluster list
5159
void set_ep_config(esp_zb_endpoint_config_t ep_config, esp_zb_cluster_list_t *cluster_list) {
5260
_ep_config = ep_config;
5361
_cluster_list = cluster_list;
5462
}
5563

56-
static bool _is_bound;
64+
void setVersion(uint8_t version);
65+
5766
static bool is_bound() { return _is_bound; }
67+
void printBoundDevices();
5868

5969
static bool _allow_multiple_binding;
6070
static void allowMultipleBinding(bool bind) { _allow_multiple_binding = bind; }
@@ -72,7 +82,4 @@ class Zigbee_EP {
7282
virtual void readBasicCluster(uint16_t cluster_id, const esp_zb_zcl_attribute_t *attribute); //already implemented
7383

7484
friend class ZigbeeCore;
75-
76-
// List of Zigbee EP classes
77-
friend class ZigbeeLight;
7885
};

libraries/Zigbee/src/ep/ep_color_dimmable_light.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
ZigbeeColorDimmableLight::ZigbeeColorDimmableLight(uint8_t endpoint) : Zigbee_EP(endpoint) {
44
_device_id = ESP_ZB_HA_COLOR_DIMMABLE_LIGHT_DEVICE_ID;
5-
_version = 0;
65

76
esp_zb_color_dimmable_light_cfg_t light_cfg = ESP_ZB_DEFAULT_COLOR_DIMMABLE_LIGHT_CONFIG();
87
_cluster_list = esp_zb_color_dimmable_light_clusters_create(&light_cfg);
98
_ep_config = {
109
.endpoint = _endpoint,
1110
.app_profile_id = ESP_ZB_AF_HA_PROFILE_ID,
1211
.app_device_id = ESP_ZB_HA_COLOR_DIMMABLE_LIGHT_DEVICE_ID,
13-
.app_device_version = _version
12+
.app_device_version = 0
1413
};
1514
}
1615

0 commit comments

Comments
 (0)