@@ -282,18 +282,19 @@ bool ZigbeeWindowCovering::setLiftPosition(uint16_t lift_position) {
282
282
);
283
283
if (ret != ESP_ZB_ZCL_STATUS_SUCCESS) {
284
284
log_e (" Failed to set lift position: 0x%x: %s" , ret, esp_zb_zcl_status_to_name (ret));
285
- return false ;
285
+ goto unlock_and_return ;
286
286
}
287
287
ret = esp_zb_zcl_set_attribute_val (
288
288
_endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_ID,
289
289
&_current_lift_percentage, false
290
290
);
291
291
if (ret != ESP_ZB_ZCL_STATUS_SUCCESS) {
292
292
log_e (" Failed to set lift percentage: 0x%x: %s" , ret, esp_zb_zcl_status_to_name (ret));
293
- return false ;
293
+ goto unlock_and_return ;
294
294
}
295
+ unlock_and_return:
295
296
esp_zb_lock_release ();
296
- return true ;
297
+ return ret == ESP_ZB_ZCL_STATUS_SUCCESS ;
297
298
}
298
299
299
300
bool ZigbeeWindowCovering::setLiftPercentage (uint8_t lift_percentage) {
@@ -310,18 +311,19 @@ bool ZigbeeWindowCovering::setLiftPercentage(uint8_t lift_percentage) {
310
311
);
311
312
if (ret != ESP_ZB_ZCL_STATUS_SUCCESS) {
312
313
log_e (" Failed to set lift position: 0x%x: %s" , ret, esp_zb_zcl_status_to_name (ret));
313
- return false ;
314
+ goto unlock_and_return ;
314
315
}
315
316
ret = esp_zb_zcl_set_attribute_val (
316
317
_endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_ID,
317
318
&_current_lift_percentage, false
318
319
);
319
320
if (ret != ESP_ZB_ZCL_STATUS_SUCCESS) {
320
321
log_e (" Failed to set lift percentage: 0x%x: %s" , ret, esp_zb_zcl_status_to_name (ret));
321
- return false ;
322
+ goto unlock_and_return ;
322
323
}
324
+ unlock_and_return:
323
325
esp_zb_lock_release ();
324
- return true ;
326
+ return ret == ESP_ZB_ZCL_STATUS_SUCCESS ;
325
327
}
326
328
327
329
bool ZigbeeWindowCovering::setTiltPosition (uint16_t tilt_position) {
@@ -339,18 +341,19 @@ bool ZigbeeWindowCovering::setTiltPosition(uint16_t tilt_position) {
339
341
);
340
342
if (ret != ESP_ZB_ZCL_STATUS_SUCCESS) {
341
343
log_e (" Failed to set tilt position: 0x%x: %s" , ret, esp_zb_zcl_status_to_name (ret));
342
- return false ;
344
+ goto unlock_and_return ;
343
345
}
344
346
ret = esp_zb_zcl_set_attribute_val (
345
347
_endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_ID,
346
348
&_current_tilt_percentage, false
347
349
);
348
350
if (ret != ESP_ZB_ZCL_STATUS_SUCCESS) {
349
351
log_e (" Failed to set tilt percentage: 0x%x: %s" , ret, esp_zb_zcl_status_to_name (ret));
350
- return false ;
352
+ goto unlock_and_return ;
351
353
}
354
+ unlock_and_return:
352
355
esp_zb_lock_release ();
353
- return true ;
356
+ return ret == ESP_ZB_ZCL_STATUS_SUCCESS ;
354
357
}
355
358
356
359
bool ZigbeeWindowCovering::setTiltPercentage (uint8_t tilt_percentage) {
@@ -368,18 +371,19 @@ bool ZigbeeWindowCovering::setTiltPercentage(uint8_t tilt_percentage) {
368
371
);
369
372
if (ret != ESP_ZB_ZCL_STATUS_SUCCESS) {
370
373
log_e (" Failed to set tilt position: 0x%x: %s" , ret, esp_zb_zcl_status_to_name (ret));
371
- return false ;
374
+ goto unlock_and_return ;
372
375
}
373
376
ret = esp_zb_zcl_set_attribute_val (
374
377
_endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_ID,
375
378
&_current_tilt_percentage, false
376
379
);
377
380
if (ret != ESP_ZB_ZCL_STATUS_SUCCESS) {
378
381
log_e (" Failed to set tilt percentage: 0x%x: %s" , ret, esp_zb_zcl_status_to_name (ret));
379
- return false ;
382
+ goto unlock_and_return ;
380
383
}
384
+ unlock_and_return:
381
385
esp_zb_lock_release ();
382
- return true ;
386
+ return ret == ESP_ZB_ZCL_STATUS_SUCCESS ;
383
387
}
384
388
385
389
#endif // CONFIG_ZB_ENABLED
0 commit comments