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

Queries regarding Advertisement module initialization

Hi,

I am using the following tools and resources, 

1. Segger embedded studio

2. SDK 16.

3. SD version 7. 

4. nrf52 Development kit PC410040. 

5. nrf Connect app in iPhone

I am trying to develop a simple non connectable simple advertisement sequence , with no scan response data. the following is the Advertisement initialization function. 

static void advertising_init(void)
{
    ret_code_t             err_code;
    ble_advertising_init_t init;

    memset(&init, 0, sizeof(init));

    init.advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance      = true;
    init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

    init.config.ble_adv_fast_enabled     = true;
    init.config.ble_adv_fast_interval    = APP_ADV_INTERVAL;
    init.config.ble_adv_fast_timeout     = 0;
    
    //init.evt_handler                     = adv_event;

    m_advertising.initialized           = 0;
    //m_advertising.evt_handler           = adv_event;
    m_advertising.adv_params
                  .properties.type      = BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED;
    m_advertising.adv_params
                  .p_peer_addr          = NULL;
    m_advertising.adv_params
                  .interval             = APP_ADV_INTERVAL;
    m_advertising.adv_params                   
                  .duration             = 0;

    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);

}

1. my understanding of this function "ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);" is just a tag created for a particular advertisement configuration, and unique tag ID can be created for multiple configuration. The problem is, if i dont use this function, my app runs into some kind of run time error, which i can see it in RTT viewer, please find the below screenshot from the RTT viewer. But ideally even without the function the program should work fine, shouldnt it?

2. when I use configuration tag function, the app is working fine, I am able to see the device listed on nrf connect app, but RTT viewer is just blank, I am not able to see any NRF_LOG / APP_ERROR outputs, is that supposed to happen?

3. In the examples I have there is a function to initialize GAP parameters directly using the SD API instead of SDK APIs. And certain parameters such as structures like device name couldnt be found in the SDK data structures, so is it correct that we have use to SD API to set some critical parameters such as device name? or Have I missed something? 

4. "init.evt_handler                     = adv_event;" if i try to assign a event handler for advertisement module, i am getting a linker error, I am not sure whats the problem. Please find the error statement below. 

"'adv_event' undeclared (first use in this function)"

Parents
  • Hi, 

    1. my understanding of this function "ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);" is just a tag created for a particular advertisement configuration, and unique tag ID can be created for multiple configuration. The problem is, if i dont use this function, my app runs into some kind of run time error, which i can see it in RTT viewer, please find the below screenshot from the RTT viewer. But ideally even without the function the program should work fine, shouldnt it?

    Ans. ble_advertising_conn_cfg_tag_set() is the function for changing the connection settings tag that will be used for upcoming connections. Please see the note in the Bluetooth low energy examples:
    When setting connection-specific configurations using sd_ble_cfg_set, you must create a tag for each configuration. This tag must be supplied when calling sd_ble_gap_adv_start() and sd_ble_gap_connect(). If your application uses the Advertising Module, you must call ble_advertising_conn_cfg_tag_set before starting advertising.

    2. when I use configuration tag function, the app is working fine, I am able to see the device listed on nrf connect app, but RTT viewer is just blank, I am not able to see any NRF_LOG / APP_ERROR outputs, is that supposed to happen?

     Ans. Please enable NRF_LOG_BACKEND_RTT_ENABLED and NRF_LOG_ENABLED in the sdk_config.h

    //==========================================================
    // <e> NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend
    //==========================================================
    #ifndef NRF_LOG_BACKEND_RTT_ENABLED
    #define NRF_LOG_BACKEND_RTT_ENABLED 1
    #endif
    
    // <e> NRF_LOG_ENABLED - nrf_log - Logger
    //==========================================================
    #ifndef NRF_LOG_ENABLED
    #define NRF_LOG_ENABLED 1
    #endif
    
    

        

    3. In the examples I have there is a function to initialize GAP parameters directly using the SD API instead of SDK APIs. And certain parameters such as structures like device name couldnt be found in the SDK data structures, so is it correct that we have use to SD API to set some critical parameters such as device name? or Have I missed something?

     For device_name, you should use sd_ble_gap_device_name_set to set GAP device name. Could you elaborate the critical parameters more than the device name?

     

    4. "init.evt_handler                     = adv_event;" if i try to assign a event handler for advertisement module, i am getting a linker error, I am not sure whats the problem. Please find the error statement below. 

    As the error indicates, do you declare the function adv_event? You should declare the function before it is used. 

    -Amanda H.

     

     

     

Reply Children
No Data
Related