From 67979ecce6ade3760a4c47b538c3f08a9d889129 Mon Sep 17 00:00:00 2001 From: eddy Date: Tue, 4 Aug 2026 00:29:32 +0200 Subject: [PATCH] feat(client): extend MyScanCallbacks with UUID prefix matching --- src/client.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index c1ebf5e..b302c20 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -76,10 +76,16 @@ static size_t ecdhNotifyLen = 0; class MyScanCallbacks : public NimBLEScanCallbacks { void onResult(const NimBLEAdvertisedDevice *advertisedDevice) override { - if (advertisedDevice->isAdvertisingService(NimBLEUUID(SERVICE_UUID))) { - serverAddress = advertisedDevice->getAddress(); - serverFound = true; - NimBLEDevice::getScan()->stop(); + if (scanning && advertisedDevice->isAdvertisingService(NimBLEUUID(SERVICE_UUID))) { + std::string mfgData = advertisedDevice->getManufacturerData(); + if (mfgData.length() >= 4) { + if (memcmp(mfgData.data(), deviceUuid, 4) == 0) { + serverAddress = advertisedDevice->getAddress(); + serverFound = true; + ESP_LOGI(TAG, "BLE: server found at %s", serverAddress.toString().c_str()); + NimBLEDevice::getScan()->stop(); + } + } } } };