diff --git a/src/AppLayer.cpp b/src/AppLayer.cpp index f185a6c..1065e65 100644 --- a/src/AppLayer.cpp +++ b/src/AppLayer.cpp @@ -41,6 +41,7 @@ // 20240424 Fixes in decodeDownlink() // Fixed getBleAddr() // Implemented resetting of knownBLEAddresses to defaults +// 20240426 Added BLE address initialization after updating via downlink // // // ToDo: @@ -141,8 +142,8 @@ AppLayer::decodeDownlink(uint8_t port, uint8_t *payload, size_t size) payload[i + 5]); } - // Note: New addresses will be applied only after restart. setBleAddr(payload, size); + bleAddrInit(); return 0; } diff --git a/src/AppLayer.h b/src/AppLayer.h index a61029b..cc378e9 100644 --- a/src/AppLayer.h +++ b/src/AppLayer.h @@ -36,6 +36,7 @@ // 20240417 Added sensor configuration functions // 20240419 Modified downlink decoding // 20240424 Fixed BLE address initialization from Preferences, added begin() +// 20240426 Moved bleAddrInit() out of begin() // // ToDo: // - @@ -140,11 +141,23 @@ class AppLayer /*! * \brief AppLayer initialization * + */ + void begin(void) + { + bleAddrInit(); + }; + + /* + * \brief Initialize list of known BLE addresses from defaults or Preferences + * + * If available, addresses from Preferences are used, otherwise defaults from + * BresserWeatherSensorLWCfg.h. + * * BleSensors() requires Preferences, which uses the Flash FS, * which is not available before the sketches' begin() is called - - * thus the following cannot be handled by the constructor. + * thus the following cannot be handled by the constructor! */ - void begin(void) + void bleAddrInit(void) { #if defined(MITHERMOMETER_EN) || defined(THEENGSDECODER_EN) knownBLEAddressesDef = KNOWN_BLE_ADDRESSES; @@ -167,6 +180,7 @@ class AppLayer #endif }; + /*! * \brief Decode app layer specific downlink messages *