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

Using NUS/CTS/BAS together

Hey guys,

I'm using the SDK 14.0 on my nRF52832 with the SoftDevice 132, my IDE is Keil.

And I merged the ble_app_uart example with the ble_app_cts_c example and the ble_app_proximity example from the SDK.

If I start my app, I get the following err_code: Error Code: 7: Function return code: NRF_ERROR_INVALID_PARAM from my ble_advertising_init.

I figured out, that the problem is at using a BT SIG Service UUID with an own Service UUID, like the NUS Service.

My main() looks like this:

int main(void)
     {
    ret_code_t	err_code;
    bool     		erase_bonds;
    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT(); 
	
    // Initialize.
    err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);
    
    log_init();
    uart_init();
    pwm_init();
    saadc_init();
    twi_init(SCL_PIN, SDA_PIN);
    mpu_6050_init();
	
    timers_init();
    buttons_leds_init(&erase_bonds);
    scheduler_init();
    ble_stack_init();
    gap_params_init();
    gatt_init(); 		
    db_discovery_init(); 
    // No Error with NUS:
    //		services_init(); 
    //		advertising_init(); 		
    // Gives Error: 		
    advertising_init(); 		
    services_init();
	
    peer_manager_init();
    conn_params_init();

    err_code = app_timer_start(m_battery_timer_id, BATTERY_LEVEL_MEAS_INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);

    advertising_start(erase_bonds);
		
    // Enter main loop.
    for (;;)
    {			
				app_sched_execute();
				power_manage();
				
				if(is_connected())
				{				
						if(nxtaEvent.pending)
						{
								handle_nxtaEvent(&nxtaEvent);
						}
				}			
    } }

And this is my advertising_init()

static void advertising_init()
{
    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_LIMITED_DISC_MODE;
	// Gives Error:
    init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
	
    // No Error:
    //    init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    //    init.srdata.uuids_complete.p_uuids  = m_adv_uuids;

    init.config.ble_adv_whitelist_enabled = true;
    init.config.ble_adv_fast_enabled      = true;
    init.config.ble_adv_fast_interval     = APP_ADV_FAST_INTERVAL;
    init.config.ble_adv_fast_timeout      = APP_ADV_FAST_TIMEOUT;
    init.config.ble_adv_slow_enabled      = true;
    init.config.ble_adv_slow_interval     = APP_ADV_SLOW_INTERVAL;
    init.config.ble_adv_slow_timeout      = APP_ADV_SLOW_TIMEOUT;

    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&m_advertising, &init);
		read_error(err_code);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}

Is it not possible using advdata with NUS/CTS/BAS together?

Forgive me if the question sounds stupid, but I'm still a beginner. Thanks for your help!

Parents
  • Could it be because the NUS UUID is added in ble_nus_init() in services_init()?

    sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type);
    

    Try calling services_init() before advertising_init(). Also, be aware that the amount of advertising data is limited, so you might not be able to advertise all those UUIDs. However, you don't need to advertise the UUIDs of all the services you have.

Reply
  • Could it be because the NUS UUID is added in ble_nus_init() in services_init()?

    sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type);
    

    Try calling services_init() before advertising_init(). Also, be aware that the amount of advertising data is limited, so you might not be able to advertise all those UUIDs. However, you don't need to advertise the UUIDs of all the services you have.

Children
Related