Beispiel #1
0
/**@brief Alert Notification Service Client handler.
 *
 * @details This function will be called for all events in the Alert Notification Client which
 *          are passed to the application.
 *
 * @param[in]   p_evt   Event received from the Alert Notification Service Client.
 */
static void on_ans_c_evt(ble_ans_c_evt_t * p_evt)
{
    uint32_t err_code = NRF_SUCCESS;

    switch (p_evt->evt_type)
    {
        case BLE_ANS_C_EVT_NOTIFICATION:
            handle_alert_notification(p_evt);
            break;

        case BLE_ANS_C_EVT_DISCOVER_COMPLETE:
            read_supported_alert_notification();
            setup_alert_notification();

            // Start handling button presses
            break;

        case BLE_ANS_C_EVT_RECONNECT:
            break;

        case BLE_ANS_C_EVT_READ_RESP:
            setup_control_point(p_evt);
            break;

        case BLE_ANS_C_EVT_DISCONN_COMPLETE:
            m_new_alert_state    = ALERT_NOTIFICATION_DISABLED;
            m_unread_alert_state = ALERT_NOTIFICATION_DISABLED;

            nrf_gpio_pin_clear(NEW_ALERT_NOTIF_LED_PIN_NO);
            nrf_gpio_pin_clear(UNREAD_ALERT_NOTIF_LED_PIN_NO);
            break;

        // The BLE_ANS_C_EVT_DISCOVER_FAILED will occur if a master, not supporting the Alert
        // Notification Service, connects to the Alert Notification Client.
        case BLE_ANS_C_EVT_DISCOVER_FAILED:
        default:
            break;
    }

    APP_ERROR_CHECK(err_code);
}
Beispiel #2
0
/**@brief Function for handling the Alert Notification Service Client.
 *
 * @details This function will be called for all events in the Alert Notification Client which
 *          are passed to the application.
 *
 * @param[in]   p_evt   Event received from the Alert Notification Service Client.
 */
static void on_ans_c_evt(ble_ans_c_evt_t * p_evt)
{
    uint32_t err_code;

    switch (p_evt->evt_type)
    {
        case BLE_ANS_C_EVT_NOTIFICATION:
            handle_alert_notification(p_evt);
            break; // BLE_ANS_C_EVT_NOTIFICATION

        case BLE_ANS_C_EVT_DISCOVERY_COMPLETE:
            err_code = ble_ans_c_handles_assign(&m_ans_c,
                                                p_evt->conn_handle,
                                                &p_evt->data.service);
            APP_ERROR_CHECK(err_code);
            supported_alert_notification_read();
            alert_notification_setup();
            break; // BLE_ANS_C_EVT_DISCOVERY_COMPLETE

        case BLE_ANS_C_EVT_READ_RESP:
            control_point_setup(p_evt);
            break; // BLE_ANS_C_EVT_READ_RESP

        case BLE_ANS_C_EVT_DISCONN_COMPLETE:
            m_new_alert_state    = ALERT_NOTIFICATION_DISABLED;
            m_unread_alert_state = ALERT_NOTIFICATION_DISABLED;

            err_code = bsp_indication_set(BSP_INDICATE_IDLE);
            APP_ERROR_CHECK(err_code);
            break; // BLE_ANS_C_EVT_DISCONN_COMPLETE

        default:
            // No implementation needed.
            break;
    }
}