This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

the scan result is imcompleted

the nrf51822 is working as a peripheral advertising the data like

0x0201061416FFCB113C01271119359426040A6E189C000000050852545F54,

which contains three data typs:

020106

1416FFCB113C01271119359426040A6E189C000000

050852545F54

they can be scanned by the nRF Connect app.

And a nrf52832 is working as a central scanning the peripheral.

However, it only finds the first two types, as below,

<debug> peripheral: 02 01 06 14 16 FF CB 11|........

<debug> peripheral: 3C 01 27 11 19 35 94 26|<.'..5.&

<debug> peripheral: 04 0A 6E 18 9C 00 00 00|..n.....

How does this happen, and how to fix it?

Thank you.

Parents Reply Children
  • Hi, 

    I modify my test code and now it look likes below

    static void scan_evt_handler(scan_evt_t const * p_scan_evt)
    {
    ret_code_t err_code;

    switch(p_scan_evt->scan_evt_id)
    {
    case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:
    {
    err_code = p_scan_evt->params.connecting_err.err_code;
    NRF_LOG_DEBUG("connecting error = %d", err_code);
    }
    break;
    case NRF_BLE_SCAN_EVT_NOT_FOUND:
    {
    uint8_t addr[] = {0x01, 0x86, 0xAD, 0xC2, 0x1F, 0xE2};
    if(!memcmp(addr, p_scan_evt->params.p_not_found->peer_addr.addr, 6))
    {
    NRF_LOG_DEBUG("address matched");
    NRF_LOG_HEXDUMP_DEBUG(p_scan_evt->params.p_not_found->data.p_data, p_scan_evt->params.p_not_found->data.len);
    }

    ...

    }

    And the result shows the adv is divided into two NRF_BLE_SCAN_EVT_NOT_FOUND events:

    00> <debug> app: address matched
    00>
    00> <debug> app: 02 01 06 14 16 FF CB 11|........
    00>
    00> <debug> app: 3C 01 27 11 19 35 94 26|<.'..5.&
    00>
    00> <debug> app: 04 0A 3C 17 D4 00 00 00|..<.....
    00>
    00> <debug> app: address matched
    00>
    00> <debug> app: 05 08 52 54 5F 54 |..RT_T

    The second one is its name.

    Why does it happen? And is there any way to make it pass all the data in one NRF_BLE_SCAN_EVT_NOT_FOUND?

    Thank you.

  • zhengrongfan said:
    Why does it happen? And is there any way to make it pass all the data in one NRF_BLE_SCAN_EVT_NOT_FOUND?

    The advertising packet can consist of no more than 31 bytes. Because of this limit, the advertising name and/or UUID are often placed in the scan response packet. If the packet that is scanned is a scan response packet, the "p_scan_evt->params.p_not_found->type.scan_response" bit field will be set to 1.

  • But the packet seems less than 31 bytes, acutally it has only 30 bytes.

  • zhengrongfan said:
    But the packet seems less than 31 bytes, acutally it has only 30 bytes.

     A device is still allowed to split these 30 bytes into 2 packets(regular advertising packet + scan response packet). The scan response packet is only sent when requested by the scanner. Again, If the packet that is scanned is a scan response packet, the "p_scan_evt->params.p_not_found->type.scan_response" bit field will be set to 1.

Related