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

How to change the peripheral depends on battery level?

Hello All,

We have One central device and four peripheral devices. From every peripheral device we are transmitting battery level.

I want to change the peripheral or want to connect to other peripheral when the battery level of connected peripheral goes goes below threshold value.

currently I am trying with HRS central code and Nordic SDK14.1 Can you please guide me on the same.

Best Regards, Hrushi

Parents
  • Hello Peter, I did the below modifications

    case BLE_BAS_C_EVT_BATT_READ_RESP:
                NRF_LOG_INFO("Battery Level Read as %d %%.", p_bas_c_evt->params.battery_level);
    	    if(p_bas_c_evt->params.battery_level < 40 )
    	    {
    		err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    		APP_ERROR_CHECK(err_code);
    
    		scan_start();
    	    }
    

    will it work? Currently HRS example is connecting with the help of service UUID. Then how can I connect to other peripheral?

Reply
  • Hello Peter, I did the below modifications

    case BLE_BAS_C_EVT_BATT_READ_RESP:
                NRF_LOG_INFO("Battery Level Read as %d %%.", p_bas_c_evt->params.battery_level);
    	    if(p_bas_c_evt->params.battery_level < 40 )
    	    {
    		err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    		APP_ERROR_CHECK(err_code);
    
    		scan_start();
    	    }
    

    will it work? Currently HRS example is connecting with the help of service UUID. Then how can I connect to other peripheral?

Children
No Data
Related