static void battery_level_update(void) { ret_code_t err_code; uint8_t battery_level; //TODO:This line need to be replaced with actual function reading the battery level battery_level = (uint8_t)sensorsim_measure(&m_battery_sim_state, &m_battery_sim_cfg); err_code = ble_bas_battery_level_update(&m_bas, battery_level, BLE_CONN_HANDLE_ALL); if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_RESOURCES) && (err_code != NRF_ERROR_BUSY) && (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING) ) { APP_ERROR_HANDLER(err_code); } }
The added one-by-one the required piece of code and able to compile successfully. I passed actual battery ADC values in battery_level_update() function. The three main functions added in main section as following:
void main(void) { .... .... // Start execution. NRF_LOG_INFO("Heart Rate Sensor example started."); printf("Heart Rate Sensor example started."); application_timers_start(); advertising_start(erase_bonds); //Additional function calls for SAADC battery service saadc_init(); saadc_sampling_event_init(); saadc_sampling_event_enable(); // Enter main loop. for (;;) { idle_state_handle(); } }