Whitelisting and/or setScanFilter of BLE server not working
Posted: Fri Jan 15, 2021 12:24 pm
Hi there,
I'm having simple BLE server and trying to allow connections only from whitelisted devices, but without success.
All actions are done in setup like this:
When I execute code in Nano32, created BLE server is visible for scans, but it doesn't allow connection from whitelisted device (or any other device). Everything works, if I change to
But of course connections from all devices are accepted.
Could someone explain what I'm doing wrong?
Thanks in advance!
I'm having simple BLE server and trying to allow connections only from whitelisted devices, but without success.
All actions are done in setup like this:
Code: Select all
void setup() {
Serial.begin(115200);
Serial.println("Starting...");
BLEDevice::init("Test dev");
BLEServer *pServer = BLEDevice::createServer();
BLEService *pService = pServer->createService(SERVICE_UUID);
pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_WRITE
);
pCharacteristic->setValue("Hello World!");
pService->start();
// Try to whitelist
BLEAddress adrr = BLEAddress("a0:28:ed:8d:dc:f3");
BLEDevice::whiteListAdd(adrr);
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->setScanFilter(false, true); // Allow connection only for devices on white list
pAdvertising->addServiceUUID(SERVICE_UUID);
pAdvertising->setScanResponse(true);
BLEDevice::startAdvertising();
Serial.println("Ready!");
}
Code: Select all
Advertising->setScanFilter(false, false);
Could someone explain what I'm doing wrong?
Thanks in advance!