@@ -35,6 +35,11 @@ void ZigbeeEP::setVersion(uint8_t version) {
35
35
}
36
36
37
37
bool ZigbeeEP::setManufacturerAndModel (const char *name, const char *model) {
38
+ // Allocate a new array of size length + 2 (1 for the length, 1 for null terminator)
39
+ // This memory space can't be deleted or overwritten, therefore using static
40
+ static char zb_name[ZB_MAX_NAME_LENGTH + 2 ];
41
+ static char zb_model[ZB_MAX_NAME_LENGTH + 2 ];
42
+
38
43
// Convert manufacturer to ZCL string
39
44
size_t name_length = strlen (name);
40
45
size_t model_length = strlen (model);
@@ -48,9 +53,6 @@ bool ZigbeeEP::setManufacturerAndModel(const char *name, const char *model) {
48
53
log_e (" Failed to get basic cluster" );
49
54
return false ;
50
55
}
51
- // Allocate a new array of size length + 2 (1 for the length, 1 for null terminator)
52
- char zb_name[ZB_MAX_NAME_LENGTH + 2 ];
53
- char zb_model[ZB_MAX_NAME_LENGTH + 2 ];
54
56
// Store the length as the first element
55
57
zb_name[0 ] = static_cast <char >(name_length); // Cast size_t to char
56
58
zb_model[0 ] = static_cast <char >(model_length);
@@ -245,14 +247,14 @@ void ZigbeeEP::zbReadBasicCluster(const esp_zb_zcl_attribute_t *attribute) {
245
247
zbstring_t *zbstr = (zbstring_t *)attribute->data .value ;
246
248
memcpy (_read_manufacturer, zbstr->data , zbstr->len );
247
249
_read_manufacturer[zbstr->len ] = ' \0 ' ;
248
- log_i (" Peer Manufacturer is \" %s\" " , zb_manufacturer );
250
+ log_i (" Peer Manufacturer is \" %s\" " , _read_manufacturer );
249
251
xSemaphoreGive (lock);
250
252
}
251
253
if (attribute->id == ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID && attribute->data .type == ESP_ZB_ZCL_ATTR_TYPE_CHAR_STRING && attribute->data .value ) {
252
254
zbstring_t *zbstr = (zbstring_t *)attribute->data .value ;
253
255
memcpy (_read_model, zbstr->data , zbstr->len );
254
256
_read_model[zbstr->len ] = ' \0 ' ;
255
- log_i (" Peer Model is \" %s\" " , zb_model );
257
+ log_i (" Peer Model is \" %s\" " , _read_model );
256
258
xSemaphoreGive (lock);
257
259
}
258
260
}
0 commit comments