From c72bf5aa096b051283ca2c7e122d8d830a405cc6 Mon Sep 17 00:00:00 2001 From: Simon Hailes Date: Tue, 26 Jan 2021 19:12:11 +0000 Subject: [PATCH 1/3] Make USE_BLE_ESP32 the default for sensors. --- tasmota/tasmota_configurations.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index fd04983ec..0f4a23d0e 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -170,6 +170,8 @@ #define USE_IBEACON // Add support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) //#define USE_GPS // Add support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #define USE_HM10 // (ESP8266 only) Add support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) + +#define USE_BLE_ESP32 // (ESP32 only) Add support for native BLE on ESP32 - use new driver #define USE_MI_ESP32 // (ESP32 only) Add support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #define USE_HRXL // Add support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) //#define USE_TASMOTA_CLIENT // Add support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) @@ -233,6 +235,7 @@ #undef USE_EMULATION_WEMO // Disable Belkin WeMo emulation for Alexa (+6k code, +2k mem common) #undef USE_DEEPSLEEP // Disable support for deepsleep (+1k code) #undef USE_DEVICE_GROUPS // Disable support for device groups (+3k5 code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #undef USE_PWM_DIMMER_REMOTE // Disbale support for remote switches to PWM Dimmer @@ -292,6 +295,7 @@ #undef USE_TELEINFO // Disable support for French Energy Provider metering telemetry #undef USE_IEM3000 // Disable support for Schneider Electric iEM3000-Modbus series energy monitor (+0k8 code) #undef USE_WE517 // Disable support for Orno WE517-Modbus energy monitor (+1k code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) @@ -416,6 +420,7 @@ #undef USE_IBEACON // Disable support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) #undef USE_GPS // Disable support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #undef USE_HM10 // (ESP8266 only) Disable support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #undef USE_HRXL // Disable support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) #undef USE_TASMOTA_CLIENT // Disable support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) @@ -544,6 +549,7 @@ #undef USE_IBEACON // Disable support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) #undef USE_GPS // Disable support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #undef USE_HM10 // (ESP8266 only) Disable support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #undef USE_HRXL // Disable support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) #undef USE_TASMOTA_CLIENT // Disable support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) @@ -681,6 +687,7 @@ #undef USE_IBEACON // Disable support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) #undef USE_GPS // Disable support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #undef USE_HM10 // (ESP8266 only) Disable support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #undef USE_HRXL // Disable support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) #undef USE_TASMOTA_CLIENT // Disable support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) @@ -820,6 +827,7 @@ #undef USE_IBEACON // Disable support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) #undef USE_GPS // Disable support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #undef USE_HM10 // (ESP8266 only) Disable support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) +#undef USE_BLE_ESP32 // (ESP32 only) Disable support for native BLE on ESP32 - use new driver #undef USE_MI_ESP32 // (ESP32 only) Disable support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) #undef USE_HRXL // Disable support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) #undef USE_TASMOTA_CLIENT // Disable support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) From 79bf2f6aa3e424aaf2898e4caa0d3bc7fcb83b5d Mon Sep 17 00:00:00 2001 From: Simon Hailes Date: Tue, 26 Jan 2021 20:02:42 +0000 Subject: [PATCH 2/3] belt and braces fix test failure --- tasmota/tasmota_configurations.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index 0f4a23d0e..de60b84e1 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -170,9 +170,10 @@ #define USE_IBEACON // Add support for bluetooth LE passive scan of ibeacon devices (uses HM17 module) //#define USE_GPS // Add support for GPS and NTP Server for becoming Stratus 1 Time Source (+ 3.1kb flash, +132 bytes RAM) #define USE_HM10 // (ESP8266 only) Add support for HM-10 as a BLE-bridge for the LYWSD03 (+5k1 code) - -#define USE_BLE_ESP32 // (ESP32 only) Add support for native BLE on ESP32 - use new driver -#define USE_MI_ESP32 // (ESP32 only) Add support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) +#ifdef ESP32 + #define USE_BLE_ESP32 // (ESP32 only) Add support for native BLE on ESP32 - use new driver + #define USE_MI_ESP32 // (ESP32 only) Add support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) +#endif #define USE_HRXL // Add support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7) //#define USE_TASMOTA_CLIENT // Add support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) //#define USE_OPENTHERM // Add support for OpenTherm (+15k code) From 60094eb0eed79e5931e2e984e73919558cc4d509 Mon Sep 17 00:00:00 2001 From: Simon Hailes Date: Wed, 27 Jan 2021 10:16:30 +0000 Subject: [PATCH 3/3] rename + soime explaination --- tasmota/xdrv_79_esp32_ble.ino | 38 ++++++++----------- ...SP32.ino => xsns_52_esp32_ibeacon_ble.ino} | 6 ++- ...s_62_MI_ESP32.ino => xsns_62_esp32_mi.ino} | 4 +- ...BLE_ESP32.ino => xsns_62_esp32_mi_ble.ino} | 9 ++++- 4 files changed, 30 insertions(+), 27 deletions(-) rename tasmota/{xsns_52_ibeacon_BLE_ESP32.ino => xsns_52_esp32_ibeacon_ble.ino} (99%) rename tasmota/{xsns_62_MI_ESP32.ino => xsns_62_esp32_mi.ino} (99%) rename tasmota/{xsns_62_MI_ESP32_BLE_ESP32.ino => xsns_62_esp32_mi_ble.ino} (99%) diff --git a/tasmota/xdrv_79_esp32_ble.ino b/tasmota/xdrv_79_esp32_ble.ino index 3452d67d5..9c96da9b0 100644 --- a/tasmota/xdrv_79_esp32_ble.ino +++ b/tasmota/xdrv_79_esp32_ble.ino @@ -45,34 +45,26 @@ connect/read/awaitnotify from a MAC/Service/Characteristic/NotifyCharacteristic Cmnds: - BLEOp0 - requests status of operations - BLEOp1 MAC - create an operation in preparation, and populate it's MAC address - BLEOp2 Service - add a serviceUUID to the operation in preparation - BLEOp3 Characteristic - add a CharacteristicUUID to the operation in preparation for read/write - BLEOp4 writedata - optional:add data to write to the operation in preparation - hex string - BLEOp5 - optional:signify that a read should be done - BLEOp6 NotifyCharacteristic - optional:add a NotifyCharacteristicUUID to the operation in preparation to wait for a notify - BLEOp9 - publish the 'operation in preparation' to MQTT. - BLEOp10 - add the 'operation in preparation' to the queue of operations to perform. + BLEPeriod + BLEAdv + BLEOp + BLEMode + BLEDetails + BLEScan + BLEAlias + BLEName + BLEDebug + BLEDevices + BLEMaxAge + BLEAddrFilter Other drivers can add callbacks to receive advertisements Other drivers can add 'operations' to be performed and receive callbacks from the operation's success or failure -Example: +Example BLEOp: Write and request next notify: -backlog BLEOp1 001A22092EE0; BLEOp2 3e135142-654f-9090-134a-a6ff5bb77046; BLEOp3 3fa4585a-ce4a-3bad-db4b-b8df8179ea09; BLEOp4 03; BLEOp6 d0e8434d-cd29-0996-af41-6c90f4e0eb2a; -BLEOp10 -> -19:25:08 RSL: tele/tasmota_E89E98/SENSOR = {"BLEOperation":{"opid":"3,"state":"1,"MAC":"001A22092EE0","svc":"3e135142-654f-9090-134a-a6ff5bb77046","char":"3fa4585a-ce4a-3bad-db4b-b8df8179ea09","wrote":"03}} -19:25:08 queued 0 sent {"BLEOperation":{"opid":"3,"state":"1,"MAC":"001A22092EE0","svc":"3e135142-654f-9090-134a-a6ff5bb77046","char":"3fa4585a-ce4a-3bad-db4b-b8df8179ea09","wrote":"03}} -19:25:08 RSL: stat/tasmota_E89E98/RESULT = {"BLEOp":"Done"} -..... -19:25:11 RSL: tele/tasmota_E89E98/SENSOR = {"BLEOperation":{"opid":"3,"state":"11,"MAC":"001A22092EE0","svc":"3e135142-654f-9090-134a-a6ff5bb77046","char":"3fa4585a-ce4a-3bad-db4b-b8df8179ea09","wrote":"03","notify":"020109000428}} - -state: 1 -> starting, -7 -> read complete -8 -> write complete -11 -> notify complete --ve + -> failure (see GEN_STATE_FAILED_XXXX constants below.) +BLEOp M:4C65A8DAF43A s:00001530-1212-efde-1523-785feabcd123 n:00001531-1212-efde-1523-785feabcd123 c:00001531-1212-efde-1523-785feabcd123 w:00 go +12:45:12 MQT: tele/tasmota_esp32/BLE = {"BLEOperation":{"opid":"11","stat":"7","state":"DONENOTIFIED","MAC":"4C65A8DAF43A","svc":"00001530-1212-efde-1523-785feabcd123","char":"00001531-1212-efde-1523-785feabcd123","notifychar":"00001531-1212-efde-1523-785feabcd123","write":"00","notify":"100003"}} The driver can also be used by other drivers, using the functions: diff --git a/tasmota/xsns_52_ibeacon_BLE_ESP32.ino b/tasmota/xsns_52_esp32_ibeacon_ble.ino similarity index 99% rename from tasmota/xsns_52_ibeacon_BLE_ESP32.ino rename to tasmota/xsns_52_esp32_ibeacon_ble.ino index f869e6a20..d509332c5 100644 --- a/tasmota/xsns_52_ibeacon_BLE_ESP32.ino +++ b/tasmota/xsns_52_esp32_ibeacon_ble.ino @@ -1,5 +1,9 @@ /* - xsns_52_ibeacon.ino - Support for HM17 BLE Module + ibeacon reader on Tasmota + xsns_52_esp32_ibeacon_ble.ino + if (!USE_IBEACON_ESP32 && USE_BLE_ESP32) + - Support for HM17 BLE Module + ibeacon reader on Tasmota (untested?) + if (USE_IBEACON_ESP32 && USE_BLE_ESP32) + - Support for BLE_ESP32 ibeacon reader on Tasmota Copyright (C) 2020 Gerhard Mutz and Theo Arends diff --git a/tasmota/xsns_62_MI_ESP32.ino b/tasmota/xsns_62_esp32_mi.ino similarity index 99% rename from tasmota/xsns_62_MI_ESP32.ino rename to tasmota/xsns_62_esp32_mi.ino index 9e1b423d1..8665d6905 100644 --- a/tasmota/xsns_62_MI_ESP32.ino +++ b/tasmota/xsns_62_esp32_mi.ino @@ -1,5 +1,7 @@ /* - xsns_62_MI_ESP32.ino - MI-BLE-sensors via ESP32 support for Tasmota + xsns_62_esp32_mi.ino - MI-BLE-sensors via ESP32 support for Tasmota + enabled by ESP32 && !USE_BLE_ESP32 + if (ESP32 && USE_BLE_ESP32) then xsns_62_esp32_mi_ble.ino is used Copyright (C) 2021 Christian Baars and Theo Arends diff --git a/tasmota/xsns_62_MI_ESP32_BLE_ESP32.ino b/tasmota/xsns_62_esp32_mi_ble.ino similarity index 99% rename from tasmota/xsns_62_MI_ESP32_BLE_ESP32.ino rename to tasmota/xsns_62_esp32_mi_ble.ino index f563e9f1a..528953e99 100644 --- a/tasmota/xsns_62_MI_ESP32_BLE_ESP32.ino +++ b/tasmota/xsns_62_esp32_mi_ble.ino @@ -1,5 +1,8 @@ /* - xsns_62_MI_ESP32.ino - MI-BLE-sensors via ESP32 support for Tasmota + xsns_62_esp32_mi_ble.ino - MI-BLE-sensors via ESP32 support for Tasmota + enabled by ESP32 && USE_BLE_ESP32 + if (ESP32 && !USE_BLE_ESP32) then xsns_62_esp32_mi.ino is used - the older driver + Copyright (C) 2020 Christian Baars and Theo Arends @@ -20,6 +23,8 @@ -------------------------------------------------------------------------------------------- Version yyyymmdd Action Description -------------------------------------------------------------------------------------------- + 0.9.2.0 20210127 changed - Officially includes as the mi driver when using USE_BLE_ESP32. + ------- 0.9.1.9 20201226 changed - All change now. ------- 0.9.1.7 20201116 changed - small bugfixes, add BLOCK and OPTION command, send BLE scan via MQTT @@ -2233,7 +2238,7 @@ void CmndMi32Keys(void){ * Presentation \*********************************************************************************************/ -const char HTTP_MI32[] PROGMEM = "{s}MI ESP32 v0918{m}%u%s / %u{e}"; +const char HTTP_MI32[] PROGMEM = "{s}MI ESP32 v0920{m}%u%s / %u{e}"; const char HTTP_MI32_ALIAS[] PROGMEM = "{s}%s Alias {m}%s{e}"; const char HTTP_MI32_MAC[] PROGMEM = "{s}%s %s{m}%s{e}"; const char HTTP_RSSI[] PROGMEM = "{s}%s " D_RSSI "{m}%d dBm{e}";