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!