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

Setting advertisement parameter's for custom profile

Hi, How to set the advertisement parameter's (uuid's list) , while using both custom and SIG adopted services?

I modified the source code as below, but it is not showing the advertising data parameters and scan response data parameters while advertising.

ble_uuid_t adv_uuids[] =
    {
        {BLE_UUID_ACCEL_SERVICE ,         		m_accel.uuid_type},    
        {BLE_UUID_BATTERY_SERVICE,                      BLE_UUID_TYPE_BLE},
        {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}
    };
	
    // Build and set advertising data
    memset(&advdata, 0, sizeof(advdata));

    advdata.name_type                        = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance            = true;
    advdata.flags.size                          = sizeof(flags);
    advdata.flags.p_data                       = &flags;

   memset(&scanrsp, 0, sizeof(scanrsp));
    scanrsp.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
    scanrsp.uuids_complete.p_uuids  = adv_uuids;
    
    err_code = ble_advdata_set(&advdata, &scanrsp);

     // Initialize advertising parameters (used when starting advertising)
    memset(&m_adv_params, 0, sizeof(m_adv_params));
    
    m_adv_params.type                = BLE_GAP_ADV_TYPE_ADV_IND;
    m_adv_params.p_peer_addr     = NULL;                           // Undirected advertisement
    m_adv_params.fp                  = BLE_GAP_ADV_FP_ANY;
    m_adv_params.interval            = APP_ADV_INTERVAL;
    m_adv_params.timeout             = NULL;

Regards, Balaji

ADV_MCP.png

Parents
  • There shouldn't be any particular problems with this, and it can be done for example as follows (modified from the nAN-36 code):

    
        ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type},
                                  {BLE_UUID_HEART_RATE_SERVICE, BLE_UUID_TYPE_BLE}};
    
        // Build and set advertising data
        memset(&advdata, 0, sizeof(advdata));
        advdata.name_type               = BLE_ADVDATA_FULL_NAME;
        advdata.include_appearance      = true;
        advdata.flags.size              = sizeof(flags);
        advdata.flags.p_data            = &flags;
        
        memset(&scanrsp, 0, sizeof(scanrsp));
        scanrsp.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
        scanrsp.uuids_complete.p_uuids  = adv_uuids;
        
        err_code = ble_advdata_set(&advdata, &scanrsp);
        APP_ERROR_CHECK(err_code);
    
    

    Edit: Your added code snippet does not check the error code of ble_advdata_set(), and based on your screenshots, it's pretty likely that advdata_set() returned an error and didn't do anything. You should always check error codes!

  • ... which is exactly why you should have it there, catch the error and make sure you understand it, fix the cause of it, and then see everything working as it's supposed to.

    Also, as I've told you before, you should remove the reset from app_error_handler, and use the debug_assert_handler, so that you can easily catch such errors.

Reply Children
No Data
Related