/* Function for performing battery measurement and updating the Battery Level characteristic in Battery Service.  */
static void battery_level_update(void)
/* Function for performing battery measurement and updating the Battery Level characteristic in Battery Service.  */
static void battery_level_update(void)
{
    uint32_t err_code;
    uint8_t  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);
    if ((err_code != NRF_SUCCESS) &&
        (err_code != NRF_ERROR_INVALID_STATE) &&
        (err_code != BLE_ERROR_NO_TX_PACKETS) &&
        (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
        )
    {
        APP_ERROR_HANDLER(err_code);
    }
}