From 7ea96eb0054530e64a1303fcc0cfa8ccbf552124 Mon Sep 17 00:00:00 2001 From: btsimonh Date: Sun, 20 Oct 2024 11:13:07 +0100 Subject: [PATCH] EQ3 TRV firmware version 1.46 fails if the default true is used in ->subscribe on the notify characteristic. (#22328) So pass false always - then it works with both new and old EQ3 firmware. --- .../tasmota_xdrv_driver/xdrv_79_esp32_ble.ino | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_79_esp32_ble.ino b/tasmota/tasmota_xdrv_driver/xdrv_79_esp32_ble.ino index 763ffc4772fc..bb3cd2caaa8b 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_79_esp32_ble.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_79_esp32_ble.ino @@ -1905,12 +1905,27 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: got notify characteristic")); #endif op->notifylen = 0; + bool response = false; + + /* although it FEELS like this would do the job, it does not for EQ3. + // when SHOULD we pass the default true? Is it just that EQ3 is a bad BLE implementation? + bool response = true; + if (pNCharacteristic->canWriteNoResponse()){ + response = false; + } + */ + uint8_t props = pNCharacteristic->getProperties(); +#ifdef BLE_ESP32_DEBUG + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: characteristic props 0x%02X"), props); +#endif + if(pNCharacteristic->canNotify()) { uint64_t now = esp_timer_get_time(); op->notifytimer = now; - if(pNCharacteristic->subscribe(true, BLE_ESP32::BLEGenNotifyCB)) { + + if(pNCharacteristic->subscribe(true, BLE_ESP32::BLEGenNotifyCB, response)) { #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for notify")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for notify - resp %d"), response? 1:0); #endif // this will get changed to read or write, // but here in case it's notify only (can that happen?) @@ -1918,7 +1933,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe waitNotify = true; } else { #ifdef BLE_ESP32_DEBUG - AddLog(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for notify")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for notify - resp %d"), response? 1:0); #endif newstate = GEN_STATE_FAILED_NOTIFY; op->notifytimer = 0L; @@ -1927,15 +1942,15 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe if(pNCharacteristic->canIndicate()) { uint64_t now = esp_timer_get_time(); op->notifytimer = now; - if(pNCharacteristic->subscribe(false, BLE_ESP32::BLEGenNotifyCB)) { + if(pNCharacteristic->subscribe(false, BLE_ESP32::BLEGenNotifyCB, response)) { #ifdef BLE_ESP32_DEBUG - AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for indicate")); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for indicate - resp %d"), response? 1:0); #endif notifystate = GEN_STATE_WAITINDICATE; waitNotify = true; } else { #ifdef BLE_ESP32_DEBUG - AddLog(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for indicate")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for indicate - resp %d"), response? 1:0); #endif newstate = GEN_STATE_FAILED_INDICATE; op->notifytimer = 0L;