Skip to content

Commit 8143717

Browse files
authored
fix(zigbee): Fixes in handlers, destructors and co2 sensor delta reporting (#10834)
* fix(zigbee): Fix co2 sensor delta in reporting * fix(zigbee): Declare default empty destructors * fix(zigbee): Return on error in zigbee handlers
1 parent 2f423af commit 8143717

17 files changed

+26
-17
lines changed

libraries/Zigbee/src/ZigbeeCore.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ ZigbeeCore::ZigbeeCore() {
2929
}
3030
}
3131
}
32-
ZigbeeCore::~ZigbeeCore() {}
3332

3433
//forward declaration
3534
static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id, const void *message);

libraries/Zigbee/src/ZigbeeCore.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ZigbeeCore {
8686

8787
public:
8888
ZigbeeCore();
89-
~ZigbeeCore();
89+
~ZigbeeCore() {}
9090

9191
std::list<ZigbeeEP *> ep_objects;
9292

libraries/Zigbee/src/ZigbeeEP.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ ZigbeeEP::ZigbeeEP(uint8_t endpoint) {
2727
}
2828
}
2929

30-
ZigbeeEP::~ZigbeeEP() {}
31-
3230
void ZigbeeEP::setVersion(uint8_t version) {
3331
_ep_config.app_device_version = version;
3432
}

libraries/Zigbee/src/ZigbeeEP.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ typedef enum {
5555
class ZigbeeEP {
5656
public:
5757
ZigbeeEP(uint8_t endpoint = 10);
58-
~ZigbeeEP();
58+
~ZigbeeEP() {}
5959

6060
// Set ep config and cluster list
6161
void setEpConfig(esp_zb_endpoint_config_t ep_config, esp_zb_cluster_list_t *cluster_list) {

libraries/Zigbee/src/ZigbeeHandlers.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id,
2929
static esp_err_t zb_attribute_set_handler(const esp_zb_zcl_set_attr_value_message_t *message) {
3030
if (!message) {
3131
log_e("Empty message");
32+
return ESP_FAIL;
3233
}
3334
if (message->info.status != ESP_ZB_ZCL_STATUS_SUCCESS) {
3435
log_e("Received message: error status(%d)", message->info.status);
36+
return ESP_ERR_INVALID_ARG;
3537
}
3638

3739
log_v(
@@ -55,9 +57,11 @@ static esp_err_t zb_attribute_set_handler(const esp_zb_zcl_set_attr_value_messag
5557
static esp_err_t zb_attribute_reporting_handler(const esp_zb_zcl_report_attr_message_t *message) {
5658
if (!message) {
5759
log_e("Empty message");
60+
return ESP_FAIL;
5861
}
5962
if (message->status != ESP_ZB_ZCL_STATUS_SUCCESS) {
6063
log_e("Received message: error status(%d)", message->status);
64+
return ESP_ERR_INVALID_ARG;
6165
}
6266
log_v(
6367
"Received report from address(0x%x) src endpoint(%d) to dst endpoint(%d) cluster(0x%x)", message->src_address.u.short_addr, message->src_endpoint,
@@ -75,9 +79,11 @@ static esp_err_t zb_attribute_reporting_handler(const esp_zb_zcl_report_attr_mes
7579
static esp_err_t zb_cmd_read_attr_resp_handler(const esp_zb_zcl_cmd_read_attr_resp_message_t *message) {
7680
if (!message) {
7781
log_e("Empty message");
82+
return ESP_FAIL;
7883
}
7984
if (message->info.status != ESP_ZB_ZCL_STATUS_SUCCESS) {
8085
log_e("Received message: error status(%d)", message->info.status);
86+
return ESP_ERR_INVALID_ARG;
8187
}
8288
log_v(
8389
"Read attribute response: from address(0x%x) src endpoint(%d) to dst endpoint(%d) cluster(0x%x)", message->info.src_address.u.short_addr,
@@ -109,9 +115,11 @@ static esp_err_t zb_cmd_read_attr_resp_handler(const esp_zb_zcl_cmd_read_attr_re
109115
static esp_err_t zb_configure_report_resp_handler(const esp_zb_zcl_cmd_config_report_resp_message_t *message) {
110116
if (!message) {
111117
log_e("Empty message");
118+
return ESP_FAIL;
112119
}
113120
if (message->info.status != ESP_ZB_ZCL_STATUS_SUCCESS) {
114121
log_e("Received message: error status(%d)", message->info.status);
122+
return ESP_ERR_INVALID_ARG;
115123
}
116124
esp_zb_zcl_config_report_resp_variable_t *variable = message->variables;
117125
while (variable) {
@@ -127,9 +135,11 @@ static esp_err_t zb_configure_report_resp_handler(const esp_zb_zcl_cmd_config_re
127135
static esp_err_t zb_cmd_default_resp_handler(const esp_zb_zcl_cmd_default_resp_message_t *message) {
128136
if (!message) {
129137
log_e("Empty message");
138+
return ESP_FAIL;
130139
}
131140
if (message->info.status != ESP_ZB_ZCL_STATUS_SUCCESS) {
132141
log_e("Received message: error status(%d)", message->info.status);
142+
return ESP_ERR_INVALID_ARG;
133143
}
134144
log_v(
135145
"Received default response: from address(0x%x), src_endpoint(%d) to dst_endpoint(%d), cluster(0x%x) with status 0x%x",

libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ void ZigbeeCarbonDioxideSensor::setReporting(uint16_t min_interval, uint16_t max
5656
reporting_info.u.send_info.max_interval = max_interval;
5757
reporting_info.u.send_info.def_min_interval = min_interval;
5858
reporting_info.u.send_info.def_max_interval = max_interval;
59-
reporting_info.u.send_info.delta.u16 = delta;
6059
reporting_info.dst.profile_id = ESP_ZB_AF_HA_PROFILE_ID;
6160
reporting_info.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC;
61+
float delta_f = delta / 1000000.0f;
62+
memcpy(&reporting_info.u.send_info.delta.s32, &delta_f, sizeof(float));
63+
6264
esp_zb_lock_acquire(portMAX_DELAY);
6365
esp_zb_zcl_update_reporting_info(&reporting_info);
6466
esp_zb_lock_release();

libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct zigbee_carbon_dioxide_sensor_cfg_s {
3939
class ZigbeeCarbonDioxideSensor : public ZigbeeEP {
4040
public:
4141
ZigbeeCarbonDioxideSensor(uint8_t endpoint);
42-
~ZigbeeCarbonDioxideSensor();
42+
~ZigbeeCarbonDioxideSensor() {}
4343

4444
// Set the carbon dioxide value in ppm
4545
void setCarbonDioxide(float carbon_dioxide);

libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class ZigbeeColorDimmableLight : public ZigbeeEP {
1313
public:
1414
ZigbeeColorDimmableLight(uint8_t endpoint);
15-
~ZigbeeColorDimmableLight();
15+
~ZigbeeColorDimmableLight() {}
1616

1717
void onLightChange(void (*callback)(bool, uint8_t, uint8_t, uint8_t, uint8_t)) {
1818
_on_light_change = callback;

libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class ZigbeeColorDimmerSwitch : public ZigbeeEP {
1313
public:
1414
ZigbeeColorDimmerSwitch(uint8_t endpoint);
15-
~ZigbeeColorDimmerSwitch();
15+
~ZigbeeColorDimmerSwitch() {}
1616

1717
// methods to control the color dimmable light
1818
void lightToggle();

libraries/Zigbee/src/ep/ZigbeeDimmableLight.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ typedef struct zigbee_dimmable_light_cfg_s {
6767
class ZigbeeDimmableLight : public ZigbeeEP {
6868
public:
6969
ZigbeeDimmableLight(uint8_t endpoint);
70-
~ZigbeeDimmableLight();
70+
~ZigbeeDimmableLight() {}
7171

7272
void onLightChange(void (*callback)(bool, uint8_t)) {
7373
_on_light_change = callback;

libraries/Zigbee/src/ep/ZigbeeFlowSensor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct zigbee_flow_sensor_cfg_s {
3939
class ZigbeeFlowSensor : public ZigbeeEP {
4040
public:
4141
ZigbeeFlowSensor(uint8_t endpoint);
42-
~ZigbeeFlowSensor();
42+
~ZigbeeFlowSensor() {}
4343

4444
// Set the flow value in 0,1 m3/h
4545
void setFlow(float value);

libraries/Zigbee/src/ep/ZigbeeLight.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class ZigbeeLight : public ZigbeeEP {
1313
public:
1414
ZigbeeLight(uint8_t endpoint);
15-
~ZigbeeLight();
15+
~ZigbeeLight() {}
1616

1717
// Use to set a cb function to be called on light change
1818
void onLightChange(void (*callback)(bool)) {

libraries/Zigbee/src/ep/ZigbeeOccupancySensor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct zigbee_occupancy_sensor_cfg_s {
3939
class ZigbeeOccupancySensor : public ZigbeeEP {
4040
public:
4141
ZigbeeOccupancySensor(uint8_t endpoint);
42-
~ZigbeeOccupancySensor();
42+
~ZigbeeOccupancySensor() {}
4343

4444
// Set the occupancy value. True for occupied, false for unoccupied
4545
void setOccupancy(bool occupied);

libraries/Zigbee/src/ep/ZigbeePressureSensor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct zigbee_pressure_sensor_cfg_s {
3939
class ZigbeePressureSensor : public ZigbeeEP {
4040
public:
4141
ZigbeePressureSensor(uint8_t endpoint);
42-
~ZigbeePressureSensor();
42+
~ZigbeePressureSensor() {}
4343

4444
// Set the pressure value in 1 hPa
4545
void setPressure(int16_t value);

libraries/Zigbee/src/ep/ZigbeeSwitch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class ZigbeeSwitch : public ZigbeeEP {
1313
public:
1414
ZigbeeSwitch(uint8_t endpoint);
15-
~ZigbeeSwitch();
15+
~ZigbeeSwitch() {}
1616

1717
// methods to control the on/off light
1818
void lightToggle();

libraries/Zigbee/src/ep/ZigbeeTempSensor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class ZigbeeTempSensor : public ZigbeeEP {
1313
public:
1414
ZigbeeTempSensor(uint8_t endpoint);
15-
~ZigbeeTempSensor();
15+
~ZigbeeTempSensor() {}
1616

1717
// Set the temperature value in 0,01°C
1818
void setTemperature(float value);

libraries/Zigbee/src/ep/ZigbeeThermostat.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
class ZigbeeThermostat : public ZigbeeEP {
3333
public:
3434
ZigbeeThermostat(uint8_t endpoint);
35-
~ZigbeeThermostat();
35+
~ZigbeeThermostat() {}
3636

3737
void onTempRecieve(void (*callback)(float)) {
3838
_on_temp_recieve = callback;

0 commit comments

Comments
 (0)