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

Sleep in connected mode

Question:

From ble device I have to send some data or character to mobile in connected mode. After sending that data the device is not going to sleep mode while connected condition.

if I use sleep mode function, the device gets disconnected with the mobile. so how can I make the device go to sleep mode while in connected mode.

What function I have to use?

Parents
  • I have added the sleep code inside BLE_GAP_EVENT_CONNECTED

    switch (p_ble_evt->header.evt_id)    
    {    
        case BLE_GAP_EVT_CONNECTED:    
            err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);    
            APP_ERROR_CHECK(err_code);    
            
            m_advertising_mode = BLE_NO_ADV;   
            m_conn_handle      = p_ble_evt->evt.gap_evt.conn_handle;    
    			
    	nrf_delay_ms(2000);   
    		      
    uint32_t err_code = bsp_indication_set(BSP_INDICATE_IDLE);
    APP_ERROR_CHECK(err_code);
    
    // Prepare wakeup buttons.    
    err_code = bsp_btn_ble_sleep_mode_prepare();    
    APP_ERROR_CHECK(err_code);      
    
    // Go to system-off mode (this function will not return; wakeup will cause a reset).    
    err_code = sd_power_system_off();    
    APP_ERROR_CHECK(err_code);   
    	       
     break;
    
Reply
  • I have added the sleep code inside BLE_GAP_EVENT_CONNECTED

    switch (p_ble_evt->header.evt_id)    
    {    
        case BLE_GAP_EVT_CONNECTED:    
            err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);    
            APP_ERROR_CHECK(err_code);    
            
            m_advertising_mode = BLE_NO_ADV;   
            m_conn_handle      = p_ble_evt->evt.gap_evt.conn_handle;    
    			
    	nrf_delay_ms(2000);   
    		      
    uint32_t err_code = bsp_indication_set(BSP_INDICATE_IDLE);
    APP_ERROR_CHECK(err_code);
    
    // Prepare wakeup buttons.    
    err_code = bsp_btn_ble_sleep_mode_prepare();    
    APP_ERROR_CHECK(err_code);      
    
    // Go to system-off mode (this function will not return; wakeup will cause a reset).    
    err_code = sd_power_system_off();    
    APP_ERROR_CHECK(err_code);   
    	       
     break;
    
Children
No Data
Related