Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Detect and/or decode beacon advertisements on nRF Dev board

Hello,

I am trying to find an example application that I can run on my Dev board that will allow me to detect and decode advertising beacon and send the data out of the serial/log port when the event occurs.

I am working with the nRF5 SDK 17.1.0. The dev kit is nRF52-DK.

The examples that I have seen appear to want to connect to the target which the beacon does not do.

Any suggestions?

Thanks,

Allen

  • Hello Allen,

    You should use the Scanning Module to achieve this, and you can see an example of how this can be used in the BLE Blinky example.
    This way, you will have the advertising reports that match the filters you have added received in the scan module event handler.

    Best regards,
    Karl

  • Hello Karl,

    Thank you for pointing me in a direction to start.  Since this specific client application requires a device with the name "Nordic_Blinky", how can I go about looking for a specific UUID that would be embedded in the beacon advertising data instead?

  • Hello Karl,

    Just an update.  I made some changes to the example project ble_app_blinky_c.  Below are the changes made:

    // added to the variable section at the top of main
    
    static uint8_t const m_target_periph_UUID[16] = {0x21, 0xAD, 0x05, 0x3d, 0x0d, 0x9f, 0x4b, 0x55, 0xa1, 0xd6, 0x96, 0x3f, 0x0e, 0x3d, 0xd8, 0x70};
    
    // -----------------------------------------------------------------------------------------
    
    // added to the routine -> static void scan_init(void)
    
        // Setting filters for scanning.
        err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_UUID_FILTER, false);
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, m_target_periph_UUID);
        APP_ERROR_CHECK(err_code);
    
    //---------------------------------------------------------------------------------------
    
    // commented out the lines in routine -> 
    
    /*
        // Setting filters for scanning.
        err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_NAME_FILTER, false);
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name);
        APP_ERROR_CHECK(err_code);
    */
    
    

    Prior to making those changes, I ran the client application and saw this on the terminal window:

    <info> app_timer: RTC: initialized.

    <info> app: Blinky CENTRAL example started.

    After I made the changes for UUID detection as noted above in the code window, I see this come out on the terminal window:

    <info> app_timer: RTC: initialized.

    <error> app: Fatal error

    <warning> app: System reset

    <info> app_timer: RTC: initialized.

    <error> app: Fatal error

    <warning> app: System reset

    <info> app_timer: RTC: initialized.

    <error> app: Fatal error

    <warning> app: System reset

    Any suggestions?

    Thanks,

    Allen

  • Hello again, Allen

    AllenS said:
    Thank you for pointing me in a direction to start. 

    No problem at all, I am happy to help! :) 

    AllenS said:
    Since this specific client application requires a device with the name "Nordic_Blinky", how can I go about looking for a specific UUID that would be embedded in the beacon advertising data instead?

    Yes, you will have to modify the filter so that it matches the advertisements made by your beacon. For instance, if you beacon is advertising with a specific name you can change the Nordic_Blinky name used in the filter already, or if the Beacon advertises a specific address or appearance, you can filter on that instead.

    Do you already know the contents of the advertising of the beacon you are interested in?
    If not, then I would suggest using the nRF Sniffer tool to take a closer look at it.

    AllenS said:
    After I made the changes for UUID detection as noted above in the code window, I see this come out on the terminal window:

    Please make sure to add DEBUG to your preprocessor defines, like shown in the included image:

    This will make your logger module output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.
    Please do this, and let me know what this error message reads, and which line it is pointing to in your code.

    Best regards,
    Karl

  • Hello Karl,

    I do know the contents of the advertising beacon and thought the RF Sniffer would be a good tool to investigate.  I got the tool to run once I had installed Python and found the example.py file to experiment with.  Within the file, I found a spot where I could identify a specific name but am unable to figure out how to specify either the UUID or the MAC address for the beacon.  Can you assist with that.  Below is the lines of code from the example.py file:

    # Find device with name "Example".
    dev = d.find('Example')

    As for the debug, I will investigate that a little further soon and see what I can determine and report back.

Related