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

Manufacturer data read fails

SDK 15.2 API 6.1 SES

I am trying to read manufacturer data. I know i am advertising it because i can see it on the nRF connect app on my phone. When i try an dparse the data it is like data is not there. My info line for p_adv_report->data.len = 18 and manuf_data = 0x0011.  Is there something i am missing that is preventing my code from seeing the manufacturer data. i should see 0x250D for data or 00FE for manufacturer

The ble_advdata_search function doesnt seem to do anything. I set offset to 12 and it remains 12. 

BLE_GAP_EVT_ADV_REPORT:
        {
            const ble_gap_evt_adv_report_t *p_adv_report = &p_gap_evt->params.adv_report;
            
            //NRF_LOG_INFO("RSSI: %d", p_adv_report->rssi);
            

            if (is_uuid_present(&m_adv_uuids_c[0], p_adv_report))
            {   
                NRF_LOG_INFO("adv data: len: %d", *(uint8_t*)p_adv_report->data.len);
                uint8_t manuf_data_length;
                uint8_t * manuf_data = ble_advdata_manuf_data_find(&p_adv_report->data, &manuf_data_length);
....
static uint8_t * ble_advdata_manuf_data_find(const ble_data_t * p_adv_data, uint8_t * manuf_data_length)
{
    uint16_t data_offset = 0;
    *manuf_data_length = ble_advdata_search(p_adv_data->p_data,
                                         p_adv_data->len,
                                         &data_offset,
                                         BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA);
    
    return &p_adv_data->p_data[data_offset];
}

I tried cycling through the data and it gives nothing that resembles data i am sending

for(int i = 0; i < p_adv_report->data.len; i++){
    NRF_LOG_INFO("0x%02X", *(uint8_t*)(p_adv_report->data.p_data[i]));
}

Parents
  • Hello,

    It may be that the UUIDs and the manufacturer data are not present in the same advertising packets. If the manufacturer data or the uuids are in the scan response, and the other is in the "normal" advertising packet, these will be two different advertising reports. 

    How is the advertisement set up in the peripheral?

    Best Regards,

    Edvin

  • Here is my advertising_init function. Looking at it,it appears i wrap the UUID i am looking for in srdata and the manuf data in advdata and then encode those separately. Are these encode advertising packets you speak of? 

    I am looking for the TB_UUID_SERVICE and parsing the packet with that information. However it appears the manufacturing data appears in the packet with the m_adv_data[0] UUID. 

    /**@brief Function for initializing the Advertising functionality.
     */ 
    static void advertising_init(void)
    {
        ret_code_t      err_code;
        ble_advdata_t   advdata;
        ble_advdata_t   srdata;
        
        is_advertising                      = false;
        
        ble_advdata_manuf_data_t            manuf_data; //Variable to hold manufacturer specific data
        uint8_t data[]                      = {25,13}; //Our data to advertise
        manuf_data.company_identifier       =  MANUFACTURER_COMPANY_ID;
        manuf_data.data.p_data              = data;
        manuf_data.data.size                = sizeof(data);
        
        ble_uuid_t adv_uuids[] = {{TB_UUID_SERVICE, m_tlbx.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;
        advdata.uuids_complete.uuid_cnt     = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        advdata.uuids_complete.p_uuids      = m_adv_uuids;
        advdata.p_manuf_specific_data       = &manuf_data;
        
        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;
    
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
        APP_ERROR_CHECK(err_code);
     
    }

  • Hi Dmleone

    did you solve your problem? could you share to me?

    thanks..

    Ricardo

Reply Children
No Data
Related