Closed joosbuijsNL closed 1 year ago
Joos, Please check if this solution works:
// Called for each advertising BLE server.
void BLEDeviceCallbacks::onResult(NimBLEAdvertisedDevice *advertisedDevice)
{
// We have found a device, let's see if it has an address we are looking for.
for (BLEHub *hub : _hubs) {
if (advertisedDevice->getAddress().equals(*hub->_config->DeviceAddress)) {
log4MC::vlogf(LOG_INFO, "BLE : Discovered hub: %s (%s).", advertisedDevice->getName().c_str(), advertisedDevice->getAddress().toString().c_str());
hub->_advertisedDevice = advertisedDevice;
hub->_isDiscovered = true;
return;
}
}
log4MC::vlogf(LOG_INFO, "BLE : Discovered unknown device: %s (%s).", advertisedDevice->getName().c_str(), advertisedDevice->getAddress().toString().c_str());
NimBLEDevice::addIgnored(advertisedDevice->getAddress());
}
Tested by Mattze yesterday - works well.
Limit was user error, the ignoring did not solve it, but is a nice improvement. The user my_platformio.ini overruled the one in platformio.ini. I think we could close this one.
Thanks, @Hilbert70.
Unknown discovered devices count towards the BLE connection limit, 9 by default. This causes that known devices are unable to connect if too many unknown discovered devices are detected. Therefore unknown discovered devices should not count towards the maximum connection limit.
In the serial output below there are 3 known devices connected, 9 unknown devices, and a fourth known device which cannot connect anymore.