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,12 +76,18 @@ static size_t ecdhNotifyLen = 0;
|
|||
|
||||
class MyScanCallbacks : public NimBLEScanCallbacks {
|
||||
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();
|
||||
serverFound = true;
|
||||
ESP_LOGI(TAG, "BLE: server found at %s", serverAddress.toString().c_str());
|
||||
NimBLEDevice::getScan()->stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class MyClientCallbacks : public NimBLEClientCallbacks {
|
||||
|
|
|
|||
Loading…
Reference in a new issue