/**@brief Function for handling events from the BSP module. * * @param[in] event Event generated when button is pressed. */ static void bsp_event_handler(bsp_event_t event) { uint32_t err_code; switch (event) { case BSP_EVENT_SLEEP: sleep_mode_enter(); break; case BSP_EVENT_DISCONNECT: err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); if (err_code != NRF_ERROR_INVALID_STATE) { APP_ERROR_CHECK(err_code); } break; case BSP_EVENT_KEY_0: if (m_is_ias_present) { if (!m_is_high_alert_signalled) { err_code = ble_ias_c_send_alert_level(&m_ias_c, BLE_CHAR_ALERT_LEVEL_HIGH_ALERT); } else { err_code = ble_ias_c_send_alert_level(&m_ias_c, BLE_CHAR_ALERT_LEVEL_NO_ALERT); } if (err_code == NRF_SUCCESS) { m_is_high_alert_signalled = !m_is_high_alert_signalled; } else if ( (err_code != BLE_ERROR_NO_TX_PACKETS) && (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING) && (err_code != NRF_ERROR_NOT_FOUND) ) { APP_ERROR_HANDLER(err_code); } } break; case BSP_EVENT_KEY_1: //STOP_ALERTING_BUTTON_ID err_code = bsp_indication_set(BSP_INDICATE_ALERT_OFF); APP_ERROR_CHECK(err_code); break; default: break; } }
/**@brief Function for handling button events. * * @param[in] event Event generated when button is pressed. */ static void button_event_handler(bsp_event_t event) { uint32_t err_code; switch (event) { case BSP_EVENT_KEY_0: //SIGNAL_ALERT_BOND_DELETE_BUTTON_ID if (!m_is_high_alert_signalled) { err_code = ble_ias_c_send_alert_level(&m_ias_c, BLE_CHAR_ALERT_LEVEL_HIGH_ALERT); } else { err_code = ble_ias_c_send_alert_level(&m_ias_c, BLE_CHAR_ALERT_LEVEL_NO_ALERT); } if (err_code == NRF_SUCCESS) { m_is_high_alert_signalled = !m_is_high_alert_signalled; } else if ( (err_code != BLE_ERROR_NO_TX_BUFFERS) && (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING) && (err_code != NRF_ERROR_NOT_FOUND) ) { APP_ERROR_HANDLER(err_code); } break; case BSP_EVENT_KEY_1: //STOP_ALERTING_BUTTON_ID err_code = bsp_indication_set(BSP_INDICATE_ALERT_OFF); APP_ERROR_CHECK(err_code); break; default: break; } }
/**@brief Button event handler. * * @param[in] pin_no The pin number of the button pressed. */ static void button_event_handler(uint8_t pin_no) { uint32_t err_code; switch (pin_no) { case SIGNAL_ALERT_BUTTON: if (!m_is_high_alert_signalled) { err_code = ble_ias_c_send_alert_level(&m_ias_c, BLE_CHAR_ALERT_LEVEL_HIGH_ALERT); } else { err_code = ble_ias_c_send_alert_level(&m_ias_c, BLE_CHAR_ALERT_LEVEL_NO_ALERT); } if (err_code == NRF_SUCCESS) { m_is_high_alert_signalled = !m_is_high_alert_signalled; } else if ( (err_code != BLE_ERROR_NO_TX_BUFFERS) && (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING) && (err_code != NRF_ERROR_NOT_FOUND) ) { APP_ERROR_HANDLER(err_code); } break; case STOP_ALERTING_BUTTON: alert_led_blink_stop(); break; default: APP_ERROR_HANDLER(pin_no); } }
*/ static void button_event_handler(uint8_t pin_no) { uint32_t err_code; switch (pin_no) { case SIGNAL_ALERT_BUTTON: if (!m_is_high_alert_signalled) { err_code = ble_ias_c_send_alert_level(&m_ias_c, BLE_CHAR_ALERT_LEVEL_HIGH_ALERT); } else { err_code = ble_ias_c_send_alert_level(&m_ias_c, BLE_CHAR_ALERT_LEVEL_NO_ALERT); } if (err_code == NRF_SUCCESS) { m_is_high_alert_signalled = !m_is_high_alert_signalled; } else if ((err_code != BLE_ERROR_NO_TX_BUFFERS) && (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING) && (err_code != NRF_ERROR_NOT_FOUND) ) { APP_ERROR_HANDLER(err_code); } else { // Other errors are expected errors and should not be processed. } break; default: APP_ERROR_HANDLER(pin_no); break; }