Merge pull request 'Scan on service UUID instead of device name (issue #10)' (#14) from fix/issue-10-ble-scan-service-uuid into main
This commit is contained in:
commit
68aec28fe2
1 changed files with 3 additions and 3 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue