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

Unable to hexdump complete extended advertisement data

NRF_LOG_RAW_HEXDUMP_INFO() is not printing complete Extended Advertisement data in HEX format. It just prints first 80 bytes of whole advertisement packet.

I added below case in ble_evt_handler() function to catch advertisement.

case BLE_GAP_EVT_ADV_REPORT:
{
    NRF_LOG_RAW_HEXDUMP_INFO (m_scan.scan_buffer.p_data, m_scan.scan_buffer.len);
    NRF_LOG_RAW_INFO ("----------------------------------\r\n");
}
break;

I verified the length of received advertisement. The value of m_scan.scan_buffer.len is always 255.

Please help me resolve this issue.

Parents
  • Hi,

    I cannot see for sure which buffer you are printing. Are you sure it the same as ble_gap_evt_adv_report_t::data.p_data (which is passed with the BLE_GAP_EVT_ADV_REPORT event)?

  • Hi Einar,

    I`m also struggling with this issue.

    ble_pheriperal:

    static void advertising_init(void)
    {
        ret_code_t                  err_code;
        ble_advertising_init_t      init;
        ble_advdata_manuf_data_t    manuf_data;     //Variable to hold manufacturer specific data
    
        memset(&init, 0, sizeof(init));
        
        
        uint8_t data[]                       = "This is my extended manufacture-data which I always send with my advertise. May the force be with U"; //Our data to advertise
        manuf_data.company_identifier        = 0x0059;  //Nordic company ID
        manuf_data.data.p_data               = data;
        manuf_data.data.size                 = sizeof(data);
        init.advdata.p_manuf_specific_data   = &manuf_data;
    
        init.advdata.name_type               = BLE_ADVDATA_NO_NAME;
        init.advdata.include_appearance      = true;
        init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.config.ble_adv_fast_enabled     = true;
        init.config.ble_adv_fast_interval    = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout     = APP_ADV_DURATION;
    
        init.config.ble_adv_primary_phy      = BLE_GAP_PHY_1MBPS;
        init.config.ble_adv_secondary_phy    = BLE_GAP_PHY_1MBPS;
        init.config.ble_adv_extended_enabled = true;
    
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

    ble_central:

    static void scan_evt_handler(scan_evt_t const * p_scan_evt)
    {
        switch(p_scan_evt->scan_evt_id)
        {
            case NRF_BLE_SCAN_EVT_SCAN_TIMEOUT:
            {
                NRF_LOG_INFO("Scan timed out.");
                scan_start();
            } break;
            case NRF_BLE_SCAN_EVT_FILTER_MATCH:         // A filter is matched or all filters are matched in the multifilter mode
            {
                ble_gap_evt_adv_report_t const *p_adv_report = p_scan_evt->params.filter_match.p_adv_report;
                NRF_LOG_INFO("advertising data ID: %d", p_adv_report->data_id);
                NRF_LOG_INFO("Reported length of scan buffer: %d", p_adv_report->data.len);
                NRF_LOG_INFO("Extended advertising set: %d", p_adv_report->type.extended_pdu);            
                NRF_LOG_INFO("primary PHY: %d", p_adv_report->primary_phy);
                NRF_LOG_INFO("secondary PHY: %d", p_adv_report->secondary_phy);
                NRF_LOG_INFO("aux_offset: %d [uS] * 100", p_adv_report->aux_pointer.aux_offset);
                NRF_LOG_INFO("aux_phy: %d", p_adv_report->aux_pointer.aux_phy);
                NRF_LOG_RAW_HEXDUMP_INFO(p_adv_report->data.p_data, p_adv_report->data.len);
                NRF_LOG_RAW_INFO ("----------------------------------\r\n");
             } break;
            default:
              break;
        }
    }

    ble_central_scan_params:

    static ble_gap_scan_params_t m_scan_param =                 /**< Scan parameters requested for scanning and connection. */
    {
        .active        = 0x00,
        .interval      = SCAN_INTERVAL,
        .window        = SCAN_WINDOW,
        .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
        .timeout       = SCAN_DURATION,
    //    .scan_phys     = BLE_GAP_PHY_CODED,                                 // Choose only one of the following scan_phys
        .scan_phys     = BLE_GAP_PHY_1MBPS,
    //    .scan_phys     = BLE_GAP_PHY_2MBPS,
        .extended      = 1,
    };

    Log-output:

  • Hi,

    I see. This looks like a problem with the configuration of the logger module. The first thing I would try is to increase the value of NRF_LOG_MSGPOOL_ELEMENT_SIZE and/or NRF_LOG_MSGPOOL_ELEMENT_COUNT in your projects nrf_config.h

Reply Children
  • Hi,

    I can confirm that this was a problem with the config of the logger module.
    I found: 

    #define NRF_LOG_MAX_HEXDUMP            (NRF_LOG_MSGPOOL_ELEMENT_SIZE*NRF_LOG_MSGPOOL_ELEMENT_COUNT/2)
    Which in my case would evaluate to 80!.

    I adjusted the configs like this:

    //==========================================================
    // <o> NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. 
    // <i> If a small value is set, then performance of logs processing
    // <i> is degraded because data is fragmented. Bigger value impacts
    // <i> RAM memory utilization. The size is set to fit a message with
    // <i> a timestamp and up to 2 arguments in a single memory object.
    
    #ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE
    #define NRF_LOG_MSGPOOL_ELEMENT_SIZE 32
    #endif
    
    // <o> NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects 
    // <i> If a small value is set, then it may lead to a deadlock
    // <i> in certain cases if backend has high latency and holds
    // <i> multiple messages for long time. Bigger value impacts
    // <i> RAM memory usage.
    
    #ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT
    #define NRF_LOG_MSGPOOL_ELEMENT_COUNT 16
    #endif

Related