Hi Dialog,
I want get surrounding Bluetooth scan results using DA14680 .
ble_gap_scan_start(GAP_SCAN_PASSIVE,GAP_SCAN_OBSERVER_MODE,defaultBLE_SCAN_INTERVAL,defaultBLE_SCAN_WINDOW,0,1);
timer for 5 sec
ble_gap_scan_stop();
when can i expect the BLE_EVT_GAP_SCAN_COMPLETED? will it come only after scan_stop()?
Normally How much time will it take to get adv_report complete buffer?
Device:
Hi vengatesan,
The scanning procedure starts as soon as the ble_gap_scan_start() function is executed, when you are using the GAP_SCAN_OBSERVER_MODE then the procedure doesn't have a timeout, it will keep on scanning until you explictly cancel it, when using the GAP_SCAN_GEN_DISC_MODE or GAP_SCAN_LIM_DISC_MODE, then the procedure will automatically time out after about 10 seconds. Regarding when the BLE_EVT_GAP_SCAN_COMPLETED, yes after you invoke the ble_gap_scan_stop() the code will send a cancel command and stop the scanning procedure then the SDK will reply with the BLE_EVT_GAP_SCAN_COMPLETED message as soon as the scanning has stopped, this message occurs as well when the scanning timeout occurs. Regarding the question how much time it will take to complete the buffer, the device will report whatever device can find in the air at a time (every advertising string on air will be reported), it wont fill up any buffer that it will eventually be filled and will stop reporting devices.
Thanks MT_dialog
Hi Dialog,
thank you for information.
static void handle_evt_gap_adv_report(ble_evt_gap_adv_report_t *evt)
{
printf("%s: %s signal strength : %d address : %d:%d:%d:%d:%d:%d \r\n", __func__,evt->data,evt->rssi,evt->address.addr[0],evt->address.addr[1],evt->address.addr[2],evt->address.addr[3],evt->address.addr[4],evt->address.addr[5]);
}
I got some scan results.
handle_evt_gap_adv_report: TestBLEname signal strength : 168 address : 81:47:29:85:5:43
handle_evt_gap_adv_report:
信号强度:170地址:18:30:11:25:39:14
handle_evt_gap_adv_report:
/*¦½ØVR¬.ÆþíÿÍ« signal strength : 164 address : 51:12:81:04:83:6
But evt->data have some junk ASCII value. In event data BLE name starting byte from which byte is it from evt->data[2] or evt->data[9]?...
what will happen If BLE name exceeds more then 32 character ?
Hi vengatesan,
The data that you can place in the advertising string are defined by the BLE specification and are limited to 31bytes from this length 3 bytes are reserved so you left only 28 bytes, there is no device that will advertise with more data than 31 bytes and comply with the BLE specification. Also what data and how the data are stored in the advertising string is defined again by the BLE specification for example if you would like to include the name of the device in the advertising string you should declare the length of the name in bytes and the tag 0x09, which corresponds to the devices name. Please check the BLE specification for more info on this.
Thanks MT_dialog