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

HOW TO DISCONNECT A LINK ON A PERIPHERAL?

Hi, It's needed to stop the advertisement in my project. I try to stop it directly by using interface sd_ble_gap_adv_stop(), but an error indicating NRF_ERROR_INVALID_STATE occurs if the connection is established. So, I attempt to disconnect first by using interface sd_ble_gap_disconnect(). No matter what hci_status_code I pass, it occurs errors indicating NRF_ERROR_INVALID_STATE, NRF_ERROR_INVALID_PARAM, or others. I don't know what mistakes mess my way. Anyone any clues? Best regards!

Addition: I just want to make a faked sleep mode aiming at there is no advertisement and connection.

Parents
  • Hi Carles, I just want to make a fake sleep mode. Code list below: void sys_fake_sleeping(void) { uint32_t err_code;

    m_advertising_mode = BLE_NO_ADVERTISING;
    
    err_code = sd_ble_gap_disconnect(m_conn_handle,       BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    APP_ERROR_CHECK(err_code);
    
    err_code = sd_ble_gap_adv_stop();
    APP_ERROR_CHECK(err_code);
    if (NRF_SUCCESS == err_code)
    {
    	lcd_sleep_in();
    	sys_fake_sleep_in();
    }  
    

    }

    It just called by a button event.

Reply
  • Hi Carles, I just want to make a fake sleep mode. Code list below: void sys_fake_sleeping(void) { uint32_t err_code;

    m_advertising_mode = BLE_NO_ADVERTISING;
    
    err_code = sd_ble_gap_disconnect(m_conn_handle,       BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    APP_ERROR_CHECK(err_code);
    
    err_code = sd_ble_gap_adv_stop();
    APP_ERROR_CHECK(err_code);
    if (NRF_SUCCESS == err_code)
    {
    	lcd_sleep_in();
    	sys_fake_sleep_in();
    }  
    

    }

    It just called by a button event.

Children
No Data
Related