feat(client): extend MyScanCallbacks with UUID prefix matching

This commit is contained in:
eddy 2026-08-04 00:29:32 +02:00
commit 67979ecce6

View file

@ -76,12 +76,18 @@ static size_t ecdhNotifyLen = 0;
class MyScanCallbacks : public NimBLEScanCallbacks { class MyScanCallbacks : public NimBLEScanCallbacks {
void onResult(const NimBLEAdvertisedDevice *advertisedDevice) override { void onResult(const NimBLEAdvertisedDevice *advertisedDevice) override {
if (advertisedDevice->isAdvertisingService(NimBLEUUID(SERVICE_UUID))) { 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(); serverAddress = advertisedDevice->getAddress();
serverFound = true; serverFound = true;
ESP_LOGI(TAG, "BLE: server found at %s", serverAddress.toString().c_str());
NimBLEDevice::getScan()->stop(); NimBLEDevice::getScan()->stop();
} }
} }
}
}
}; };
class MyClientCallbacks : public NimBLEClientCallbacks { class MyClientCallbacks : public NimBLEClientCallbacks {