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

How to add new servis to ble_app_uart example ?

Hello everyone,

I am trying to add new service into ble_app_uart example. I compile successfully. I do not get an error. But the device is not advertising. I can only advertise when I run the ble_app_uart example or when I just run my own example.But when I want to run two instances of services in one instance, the device does not advertise. My code as shown in below;

Function for advertising;

static void advertising_init(void)
{
    uint32_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 		= false;
    init.advdata.flags              		= BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;

    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_fast_enabled  = true;
    init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    init.config.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;

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

Function for initializing service;

static void services_init(void)
{
    uint32_t       err_code;
    ble_nus_init_t nus_init;

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

    nus_init.data_handler = nus_data_handler;

    err_code = ble_nus_init(&m_nus, &nus_init);
    APP_ERROR_CHECK(err_code);
	
		/*********************************************/
		ble_kls_init_t                     kls_init;

    // Initialize KALE Service init structure to zero.
    memset(&kls_init, 0, sizeof(kls_init));
		kls_init.evt_handler                = on_kls_evt;
    
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&kls_init.open_door_value_char_attr_md.cccd_write_perm);
		BLE_GAP_CONN_SEC_MODE_SET_OPEN(&kls_init.open_door_value_char_attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&kls_init.open_door_value_char_attr_md.write_perm);
    
    err_code = ble_kls_init(&m_kls, &kls_init);
    APP_ERROR_CHECK(err_code);	
	
}

UUID;

static ble_uuid_t m_adv_uuids[] =                                               	/**< Universally unique service identifiers. */
{
    {KLS_UUID_SERVICE, BLE_UUID_TYPE_VENDOR_BEGIN }
};

Added new service instance;

BLE_KLS_DEF(m_kls);	

Related