/**@brief Function for handling the application's BLE stack events. * * @param[in] p_ble_evt Bluetooth stack event. */ static void on_ble_evt(ble_evt_t * p_ble_evt) { QS_BEGIN(TRACE_BLE_EVT, &l_SD) QS_U8(0, p_ble_evt->header.evt_id); QS_END() QS_START_TX(); uint32_t err_code = NRF_SUCCESS; switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_DISCONNECTED: if (p_ble_evt->evt.gap_evt.conn_handle == m_ancs_c.conn_handle) { m_ancs_c.conn_handle = BLE_CONN_HANDLE_INVALID; } break; case BLE_GATTS_EVT_TIMEOUT: // Disconnect on GATT Server and Client time-out events. err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle , BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); APP_ERROR_CHECK(err_code); break; case BLE_GATTC_EVT_TIMEOUT: // Disconnect on GATT Server and Client time-out events. err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gattc_evt.conn_handle , BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); APP_ERROR_CHECK(err_code); break; } APP_ERROR_CHECK(err_code); }
/**@brief Function for handling advertising events. * * @details This function is called for advertising events that are passed to the application. * * @param[in] ble_adv_evt Advertising event. */ static void on_adv_evt(ble_adv_evt_t ble_adv_evt) { uint32_t err_code; QS_BEGIN(TRACE_ADV_EVT, &l_SD) QS_U8(0, ble_adv_evt); QS_END() QS_START_TX(); switch (ble_adv_evt) { case BLE_ADV_EVT_IDLE: BSP_stop(); break; case BLE_ADV_EVT_WHITELIST_REQUEST: { ble_gap_whitelist_t whitelist; ble_gap_addr_t * p_whitelist_addr[BLE_GAP_WHITELIST_ADDR_MAX_COUNT]; ble_gap_irk_t * p_whitelist_irk[BLE_GAP_WHITELIST_IRK_MAX_COUNT]; whitelist.addr_count = BLE_GAP_WHITELIST_ADDR_MAX_COUNT; whitelist.irk_count = BLE_GAP_WHITELIST_IRK_MAX_COUNT; whitelist.pp_addrs = p_whitelist_addr; whitelist.pp_irks = p_whitelist_irk; err_code = dm_whitelist_create(&m_app_handle, &whitelist); APP_ERROR_CHECK(err_code); err_code = ble_advertising_whitelist_reply(&whitelist); APP_ERROR_CHECK(err_code); break; } } }
/**@brief Function for handling the Device Manager events. * * @param[in] p_evt Data associated to the Device Manager event. */ static uint32_t device_manager_evt_handler(dm_handle_t const * p_handle, dm_event_t const * p_evt, ret_code_t event_result) { QS_BEGIN(TRACE_DM_EVT, &l_SD) QS_U8(0, p_evt->event_id); QS_END() QS_START_TX(); uint32_t err_code; switch (p_evt->event_id) { case DM_EVT_CONNECTION: m_peer_handle = (*p_handle); err_code = app_timer_start(m_sec_req_timer_id, SECURITY_REQUEST_DELAY, NULL); APP_ERROR_CHECK(err_code); break; case DM_EVT_LINK_SECURED: err_code = ble_db_discovery_start(&m_ble_db_discovery, p_evt->event_param.p_gap_param->conn_handle); APP_ERROR_CHECK(err_code); break; default: break; } return NRF_SUCCESS; }
static void btn1_event_handler(nrf_drv_gpiote_pin_t pin , nrf_gpiote_polarity_t action) { QS_BEGIN(TRACE_SDK_EVT, NULL) QS_U8(0, 1); QS_U8(0, BSP_readButton()); QS_END() QS_START_TX(); }
/**@brief Function for handling the Apple Notification Service client. * * @details This function is called for all events in the Apple Notification client that * are passed to the application. * * @param[in] p_evt Event received from the Apple Notification Service client. */ static void on_ancs_c_evt(ble_ancs_c_evt_t * p_evt) { uint32_t err_code = NRF_SUCCESS; switch (p_evt->evt_type) { case BLE_ANCS_C_EVT_DISCOVERY_COMPLETE: QS_BEGIN(TRACE_ANCS_EVT, &l_SD) QS_U8(0, p_evt->evt_type); QS_END() QS_START_TX(); err_code = ble_ancs_c_handles_assign(&m_ancs_c,p_evt->conn_handle , &p_evt->service); APP_ERROR_CHECK(err_code); #if 0 apple_notification_setup(); #else QACTIVE_POST(AO_ble, ANCS_SIG, p_evt->evt_type); #endif break; case BLE_ANCS_C_EVT_NOTIF: { struct AncsNotification* status = &l_Ble.ancs_status[p_evt->notif.category_id]; status->flags = p_evt->notif.evt_flags; status->category_count = p_evt->notif.category_count; QS_BEGIN(TRACE_ANCS_EVT, &l_SD) QS_U8(0, p_evt->evt_type); QS_U8(0, p_evt->notif.evt_id); QS_MEM((uint8_t*)&status->flags, sizeof(status->flags)); QS_END() QS_START_TX(); QACTIVE_POST(AO_ble, ANCS_SIG , ((uint32_t)p_evt->notif.evt_id << 24) //Add/Mod/Remove | 0 // flags might not fit into 8 bits if compiler doesn't pack | ((uint16_t)p_evt->notif.category_id << 8)//email, etc | p_evt->evt_type); } break; //case BLE_ANCS_C_EVT_NOTIF_ATTRIBUTE: //title, message, date, etc default: QS_BEGIN(TRACE_ANCS_EVT, &l_SD) QS_U8(0, p_evt->evt_type); QS_END() QS_START_TX(); break; } }
/*..........................................................................*/ static void Cache_read(Cache *me, QEvent const *e) { CacheRWEvt *pe = (CacheRWEvt *)e; CacheRWRly *re; int reply = CACHE_READ_REPLY_SIG; re = Q_NEW(CacheRWRly, reply); QS_BEGIN(QS_CACHE_RW, QS_apObj_); QS_U32_HEX(8, pe->sector); QS_U32_HEX(8, pe->track); QS_U32_HEX(4, pe->offset); QS_U32_HEX(4, pe->len); QS_U32_HEX(2, pe->flags); QS_END(); Track_dispatch(pe->conf, e); /* doing a fake bio finish */ re->conf = pe->conf; re->errno = 0; re->buf.bio.bi = pe->buf.bio.bi; QACTIVE_POST(pe->ao, (QEvent *)re, AO_cache); }