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

Is it possible keep advertising when ancs connecting?

Hi, I'm using SDK12.1 example ble_app_ancs_c. Is it possible keep advertising (non-connectable is ok) when ancs connecting? And how to do it?

I tried call advertising_start() at on_ble_evt->BLE_GAP_EVT_CONNECTED. But got error.

Sincerely, Kirby

Parents
  • OK, after try and error, now it can advertising when ancs connecting... I'm not sure it's right or not, please help me check it~

    1. Add another initial.
    
    static void non_connectable_advertising_init(void)
    {
        uint32_t             err_code;    
    		ble_gap_adv_params_t adv_params;
    		
    		memset(&adv_params, 0, sizeof(ble_gap_adv_params_t));
    		adv_params.type        = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND ;
    		adv_params.p_peer_addr = NULL;
    		adv_params.fp          = BLE_GAP_ADV_FP_ANY;
    		adv_params.interval    = 200 ;
    		adv_params.timeout     = 0;
    		adv_params.p_whitelist =NULL;
    		
    		err_code = sd_ble_gap_adv_start(&adv_params);
    		APP_ERROR_CHECK(err_code);
    		
    }
    

    And call this new function when connected.

    static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
        uint32_t err_code = NRF_SUCCESS;
    
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                NRF_LOG_INFO("Connected.\r\n");
                err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
                APP_ERROR_CHECK(err_code);
                m_cur_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
                err_code = app_timer_start(m_sec_req_timer_id, SECURITY_REQUEST_DELAY, NULL);
                APP_ERROR_CHECK(err_code);
    				
    	        non_connectable_advertising_init();  //<===here.
                break; // BLE_GAP_EVT_CONNECTED
    

    Now, it will keep advertising after connected. But...you can connect it again, I already set to BLE_GAP_ADV_TYPE_ADV_NONCONN_IND . Still don't know why still can connect.

  • Hi Petter, I test it again, First time I connected with my iPhone6 and paired. Open Lightblue can see the advertising and also can connect it.( I think this should be normal?) But I tried my iPad air and failed to connect it.

    I think iPhone6 still connected to nrf51822 and that's why Lightblue can connect it again.

Reply Children
No Data
Related