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.
This commit is contained in:
btsimonh 2024-10-20 11:13:07 +01:00 committed by GitHub
parent 923ed91c9c
commit 7ea96eb005
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 6 deletions

View File

@ -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;