Skip to content

Commit

Permalink
Fixed using BLE addresses from preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-bs committed Jun 13, 2024
1 parent b663b6b commit f39d1d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 9 additions & 5 deletions BresserWeatherSensorLWCfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,20 @@ const uint8_t UBATT_SAMPLES = 10;
// BLE battery o.k. threshold in percent
#define BLE_BATT_OK 5

/*
// List of known sensors' BLE addresses
// #define KNOWN_BLE_ADDRESSES \
// { \
// "a4:c1:38:b8:1f:7f" \
// }
// #endif
#define KNOWN_BLE_ADDRESSES \
{ \
"a4:c1:38:b8:1f:7f" \
}
*/

// Empty list - BLE disabled
#define KNOWN_BLE_ADDRESSES \
{ \
\
}

#endif

/// Maximum number of 868 MHz sensors - should match the default configuration below
Expand Down
14 changes: 7 additions & 7 deletions src/PayloadBLE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ std::vector<std::string> PayloadBLE::getBleAddr(void)
for (size_t i = 0; i < size; i += 6)
{
char addr[18];
snprintf(addr, 18, "%02X:%02X:%02X:%02X:%02X:%02X",
snprintf(addr, 18, "%02x:%02x:%02x:%02x:%02x:%02x",
addrBytes[i], addrBytes[i + 1], addrBytes[i + 2], addrBytes[i + 3], addrBytes[i + 4], addrBytes[i + 5]);
bleAddr.push_back(addr);
}
Expand All @@ -106,19 +106,19 @@ void PayloadBLE::bleAddrInit(void)
{
knownBLEAddressesDef = KNOWN_BLE_ADDRESSES;
knownBLEAddresses = getBleAddr();
if (knownBLEAddresses.size() == 0)
if (knownBLEAddresses.size() != 0)
{
log_d("Using BLE addresses from Preferences:");
}
else if (knownBLEAddressesDef.size() != 0)
{
// No addresses stored in Preferences, use default
knownBLEAddresses = knownBLEAddressesDef;
log_d("Using BLE addresses from BresserWeatherSensorLWCfg.h:");
}
else if (knownBLEAddressesDef.size() == 0)
{
log_d("No BLE addresses specified.");
}
else
{
log_d("Using BLE addresses from Preferences:");
log_d("No BLE addresses specified.");
}
bleSensors = BleSensors(knownBLEAddresses);

Expand Down

0 comments on commit f39d1d7

Please sign in to comment.