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

nRF52840 Dongle with Raspberry Pi B+ for Beacon scanning

Team,

For asset tracking I am using nRF52840 Beacons as tags in asserts and Raspberry Pi B+ for scanning Beacon's MAC, UID, Major, Minor, Tx,  and RSSI values.

To calculate Beacon distance with more accuracy I am planning to use 'Channel Diversity' approach, so I want to scan nRF52840 Beacons for any one of specific channel (from 37, 38, 39).  How I can use nRF52840 Dongle along with Raspberry Pi B+ to filter specific channel of nRF52840 Beacon advertisement data.

Ashiq Mohammed

Parents
  • Hi Ashiq.

    Here is an example in using the ble_app_blinky example in the nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_blinky\pca10059\s140 folder.

    In the function static void advertising_init(void), channel masking can be done by adding one of the code snippets below:

    adv_params.channel_mask[4] = 0x80; // Dont advertise on ch 39
    adv_params.channel_mask[4] = 0x40; // Dont advertise on ch 38
    adv_params.channel_mask[4] = 0x20; // Dont advertise on ch 37
    
    
    adv_params.channel_mask[4] = 0xA0; // Dont advertise on ch 39 and 37
    adv_params.channel_mask[4] = 0xC0; // Dont advertise on ch 38 and 39
    adv_params.channel_mask[4] = 0x60; // Dont advertise on ch 37 and 38

    If i want to for example mask channel 37 and 38 my static void advertising_init(void) function would look like this:

    static void advertising_init(void)
    {
        ret_code_t    err_code;
        ble_advdata_t advdata;
        ble_advdata_t srdata;
    
        ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}};
    
        // Build and set advertising data.
        memset(&advdata, 0, sizeof(advdata));
    
        advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        advdata.include_appearance = true;
        advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    
    
        memset(&srdata, 0, sizeof(srdata));
        srdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
        srdata.uuids_complete.p_uuids  = adv_uuids;
    
        err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        err_code = ble_advdata_encode(&srdata, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len);
        APP_ERROR_CHECK(err_code);
    
        ble_gap_adv_params_t adv_params;
    
        // Set advertising parameters.
        memset(&adv_params, 0, sizeof(adv_params));
    
        adv_params.primary_phy     = BLE_GAP_PHY_1MBPS;
        adv_params.duration        = APP_ADV_DURATION;
        adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
        adv_params.p_peer_addr     = NULL;
        adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        adv_params.interval        = APP_ADV_INTERVAL;
        adv_params.channel_mask[4] = 0x60; //The code i added to mask channel 37 and 38
    
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
        APP_ERROR_CHECK(err_code);
    }

    Note that using RSSI to calculate distance is very inaccurate.

    Hope this helps.

    - Andreas

  • Thanks Andreas. Do you have any idea How to communicate nRF52840 Dongle with Raspberry Pi B+.Assume nRF52840 Dongle placed in USB drive of Raspberry Pi B+. Please help.

Reply Children
No Data
Related