feat(client): extend MyScanCallbacks with UUID prefix matching
This commit is contained in:
parent
f07d305621
commit
67979ecce6
1 changed files with 10 additions and 4 deletions
|
|
@ -76,10 +76,16 @@ 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))) {
|
||||||
serverAddress = advertisedDevice->getAddress();
|
std::string mfgData = advertisedDevice->getManufacturerData();
|
||||||
serverFound = true;
|
if (mfgData.length() >= 4) {
|
||||||
NimBLEDevice::getScan()->stop();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue