Lost in scanning (BLE) -gapCallbackDefault L#14 gapCallbackDefault into-

With the correct firmware and all the libraries loaded in Arduino IDE, with BLE_scan.ino I get this in the Serial Monitor in an endless loop (I have trimmed the output and the mac addresses). Where I am wrong? Several days trying several things… headache. :face_with_thermometer:


ScanCallback: DEBUG: gapCallbackDefault L#14 gapCallbackDefault into

ScanCallback: DEBUG: gapCallbackDefault L#67 GAP_MSG_LE_SCAN_INFO:adv_type 0x4, bd_addr dd:45:d7:f8:b1, remote_addr_type 1, rssi -58, data_len 25
ScanCallback: DEBUG: gapCallbackDefault L#68 GAP_MSG_LE_SCAN_INFO:

ScanCallback: DEBUG: gapCallbackDefault L#14 gapCallbackDefault into

ScanCallback: DEBUG: gapCallbackDefault L#67 GAP_MSG_LE_SCAN_INFO:adv_type 0x4, bd_addr a0:6f:aa:a0:f8, remote_addr_type 0, rssi -74, data_len 16
ScanCallback: DEBUG: gapCallbackDefault L#68 GAP_MSG_LE_SCAN_INFO:

ScanCallback: DEBUG: gapCallbackDefault L#14 gapCallbackDefault into

ScanCallback: DEBUG: gapCallbackDefault L#67 GAP_MSG_LE_SCAN_INFO:adv_type 0x2, bd_addr 59:77:01:fb:b6, remote_addr_type 1, rssi -102, data_len 28
ScanCallback: DEBUG: gapCallbackDefault L#68 GAP_MSG_LE_SCAN_INFO:

AdvertisedDevice: DEBUG: parseAdvertisement L#250 Entry parseAdvertisement

AdvertisedDevice: DEBUG: parseAdvertisement L#288 GAP_ADTYPE_16BIT_COMPLETE

Advertised Device: Name: , Address: b6:fb:00:77:59, serviceUUID:
ScanCallback: DEBUG: gapCallbackDefault L#14 gapCallbackDefault into

ScanCallback: DEBUG: gapCallbackDefault L#67 GAP_MSG_LE_SCAN_INFO:adv_type 0x3, bd_addr d3:df:f0:48:bb, remote_addr_type 0, rssi -102, data_len 28
ScanCallback: DEBUG: gapCallbackDefault L#68 GAP_MSG_LE_SCAN_INFO:

AdvertisedDevice: DEBUG: parseAdvertisement L#250 Entry parseAdvertisement

Advertised Device: Name: , Address: bb:48:df:03:d0
ScanCallback: DEBUG: gapCallbackDefault L#14 gapCallbackDefault into

ScanCallback: DEBUG: gapCallbackDefault L#67 GAP_MSG_LE_SCAN_INFO:adv_type 0x3, bd_addr 32:8e:35:19:f2, remote_addr_type 1, rssi -102, data_len 15
ScanCallback: DEBUG: gapCallbackDefault L#68 GAP_MSG_LE_SCAN_INFO:

AdvertisedDevice: DEBUG: parseAdvertisement L#250 Entry parseAdvertisement
.
.
.

Hi Sleepin6

Please move 31 line ‘‘BLEScanResults foundDevices = pBLEScan->start(scanTime, false);’’ to the setup() last line.meanwihle, add “pBLEScan->clearResults();” behind it as well. It will just scan once then stop.

void setup() {
    Serial.begin(115200);
    Serial.printf("Scanning...");

    BLEDevice::init("");
    pBLEScan = BLEDevice::getScan(); //create new scan
    pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
    pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
    pBLEScan->setInterval(100);
    pBLEScan->setWindow(99);  // less or equal setInterval value
    BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
    pBLEScan->clearResults();
}

Best regards
fenyi

Hi @Sleepin6

I have turned off the default debugging message, please update your library and you will not see the debugging message in the Serial monitor.

0hotpotman0 Didn’t work.
“BLE_scan:36:20: error: ‘foundDevices’ was not declared in this scope”
Thank you for your time!

ansonhe97 Thank you very much. Now it makes sense. :slightly_smiling_face:

Hi Sleepin6

sorry for my mistake.

This code is for scan devices, and my colleague has updated the code to clear the debug message. If you just want to scan once, please put this code in the setup() and remove the same code from the loop().

    //scan device//
    //***************************************//
    BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
    Serial.print("Devices found: ");
    Serial.println(foundDevices.getCount());
    Serial.println("Scan done!");
    pBLEScan->clearResults();   // delete results fromBLEScan buffer to release memory
    //***************************************//

Best regards
fenyi

1 Like

Thank you very much Fenyi! I have copied it in my sketch collection.
B. R.