From 7bdd50b16ef75aeda50e42a52e0fc3dcedc0a4ef Mon Sep 17 00:00:00 2001 From: eddy Date: Sun, 2 Aug 2026 21:27:19 +0200 Subject: [PATCH] Scan on service UUID instead of device name (issue #10) - Replace name-based scan filter (getName() == 'SylDa_Server') with isAdvertisingService(SERVICE_UUID) to prevent BLE name spoofing - Post-connect UUID verification via UUID_CHAR_UUID was already in place - Update log messages to reflect service-UUID-based scanning --- src/client.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index dfed816..af513c3 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -62,7 +62,7 @@ static NimBLEAddress serverAddress; class MyScanCallbacks : public NimBLEScanCallbacks { void onResult(const NimBLEAdvertisedDevice *advertisedDevice) override { - if (advertisedDevice->haveName() && advertisedDevice->getName() == "SylDa_Server") { + if (advertisedDevice->isAdvertisingService(NimBLEUUID(SERVICE_UUID))) { serverAddress = advertisedDevice->getAddress(); serverFound = true; NimBLEDevice::getScan()->stop(); @@ -234,7 +234,7 @@ void setup() { pScan->setActiveScan(false); pScan->setMaxResults(0); bleReady = true; - ESP_LOGI(TAG, "BLE: initialized, will scan for SylDa_Server"); + ESP_LOGI(TAG, "BLE: initialized, scanning for service UUID"); } ESP_LOGI(TAG, "Setup done."); @@ -443,7 +443,7 @@ void loop() { if (!pScan->isScanning() && scanRunnable) { scanRunnable = false; if (serverFound) { - ESP_LOGI(TAG, "BLE: found SylDa_Server, connecting..."); + ESP_LOGI(TAG, "BLE: found server advertising service UUID, connecting..."); connectToServer(); } }