Hello,
I'm working on an ultra low consumption purposes with which NRF51822 commnunique in BT4 with softdevice version 5.2.1.
I compile with GCC 4.7 2013q1. Unfortunately I can not debug.
I need to connect to a smartphone to send an alert by IAS and then disconnect immediately to preserve battery (CR1216).
I expect a disconnection event to power off my NRF51822.
static void on_ias_c_evt(ble_ias_c_t * p_ias_c, ble_ias_c_evt_t * p_evt)
{
uint32_t err_code = NRF_SUCCESS;
switch (p_evt->evt_type)
{
case BLE_IAS_C_EVT_SRV_DISCOVERED:
err_code = ble_ias_c_send_alert_level(&m_ias_c, 1);
err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
break;
case BLE_IAS_C_EVT_SRV_NOT_FOUND:
// IAS is not found on peer. The Find Me Locator functionality of this app will NOT work.
break;
case BLE_IAS_C_EVT_DISCONN_COMPLETE:
PowerOff();
break;
default:
break;
}
APP_ERROR_CHECK(err_code);
}
I added a safety with a timer that calls the PowerOff () function after 10 seconds.
According to the log of my iPhone app, disconnection is taken into account by phone (about 50ms between the receipt of the alert and disconnection), but NRF51822 does not cover the event.
I also added the call PowerOff () in the on_ble_evt () function: BLE_GAP_EVT_DISCONNECTED case:
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code = NRF_SUCCESS;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
m_advertising_mode = BLE_NO_ADV;
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break;
case BLE_GAP_EVT_DISCONNECTED:
m_conn_handle = BLE_CONN_HANDLE_INVALID;
PowerOff();
break;
.........
}
}
But my NRF51822, only power off when the timer runs 10 seconds !
Would you suggest me an idea so I can turn off the NRF51822 from disconnecting ?
Best Regards,