Skip to content

Commit

Permalink
Merge pull request #15 from matthias-bs/refactor-ble-addr-init
Browse files Browse the repository at this point in the history
Refactored BLE address initialization
  • Loading branch information
matthias-bs committed Apr 26, 2024
2 parents 7dd204d + 03a54bc commit 01aa454
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/AppLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}
Expand Down
18 changes: 16 additions & 2 deletions src/AppLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
// -
Expand Down Expand Up @@ -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;
Expand All @@ -167,6 +180,7 @@ class AppLayer
#endif
};


/*!
* \brief Decode app layer specific downlink messages
*
Expand Down

0 comments on commit 01aa454

Please sign in to comment.