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

Use BLE_GAP_EVT_ADV_REPORT to scan for beacon

Setup:

Module: nRF51822.

SDK version:nRF5_SDK_11.0.0_89a8197.

Example: ble_app_uart.

Softdevice: S130.

I use ble_nus_string_send on the BLE_GAP_EVT_ADV_REPORT in on_ble_evt tring to scan for

beacon and found that it only outputs strings less than 20 bytes. Dig a little further, I found it's

because of

if (length > BLE_NUS_MAX_DATA_LEN)
{
return NRF_ERROR_INVALID_PARAM;
}

in ble_nus.c while BLE_NUS_MAX_DATA_LEN is defined as (GATT_MTU_SIZE_DEFAULT - 3) and

GATT_MTU_SIZE_DEFAULT is defined to be 23.

My question is how to modify so I can scan for beacon whose data length is about 30? Or it's just

not supported in S130 to scan for beacons this way?

Parents Reply Children
  • The problem is how do I get the beacon data with more than 20 bytes in nRF51. Not sending, please.
    In anther words, how to achieve the condition in BLE_GAP_EVT_ADV_REPORT events (line 336 of attached main.c)

    if ((p_adv_report->dlen == 30 ) && (ble_state == BLE_CONNECTED) && ...

    where p_adv_report->dlen could never be 30 due to S130 limitation.

  • Are you sure it was because of :

    if ((p_adv_report->dlen == 30 ) && (ble_state == BLE_CONNECTED)

    How do you know if you receive the beacon advertising packet or not ? If you simply call ble_nus_string_send() when it matched then it will never send out the notification to the phone because the length is over 20 bytes. 

    Please try to test again with just toggling a GPIO or printout the log. Also try to test with simple check for example only use "if ((p_adv_report->dlen == 30 )  " or just printout any advertising packet you receives.

    As far as I know the nRF51 shouldn't have any trouble scanning for beacon having more than 20 bytes payload. 

  • You're right. I wasn't thinking straight and misunderstood. Now I can wake up from BLE idle by a specific beacon signal. Thank you very much for the help.

Related