No changes
Fork of nRF51822 by
Diff: source/btle/btle.cpp
- Revision:
- 571:bbf6410b6a89
- Parent:
- 570:f162898cb6c4
- Child:
- 572:b726baee23c2
diff -r f162898cb6c4 -r bbf6410b6a89 source/btle/btle.cpp --- a/source/btle/btle.cpp Mon Jan 11 10:19:21 2016 +0000 +++ b/source/btle/btle.cpp Mon Jan 11 10:19:22 2016 +0000 @@ -27,7 +27,9 @@ #include "custom/custom_helper.h" #include "ble/GapEvents.h" -#include "nRF5xn.h" +#include "nRF5xGap.h" +#include "nRF5xGattServer.h" +#include "nRF5xSecurityManager.h" extern "C" { #include "pstorage.h" @@ -136,11 +138,6 @@ bleGattcEventHandler(p_ble_evt); #endif - nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE); - nRF5xGap &gap = (nRF5xGap &) ble.getGap(); - nRF5xGattServer &gattServer = (nRF5xGattServer &) ble.getGattServer(); - nRF5xSecurityManager &securityManager = (nRF5xSecurityManager &) ble.getSecurityManager(); - /* Custom event handler */ switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: { @@ -151,14 +148,14 @@ #else Gap::Role_t role = static_cast<Gap::Role_t>(p_ble_evt->evt.gap_evt.params.connected.role); #endif - gap.setConnectionHandle(handle); + nRF5xGap::getInstance().setConnectionHandle(handle); const Gap::ConnectionParams_t *params = reinterpret_cast<Gap::ConnectionParams_t *>(&(p_ble_evt->evt.gap_evt.params.connected.conn_params)); const ble_gap_addr_t *peer = &p_ble_evt->evt.gap_evt.params.connected.peer_addr; const ble_gap_addr_t *own = &p_ble_evt->evt.gap_evt.params.connected.own_addr; - gap.processConnectionEvent(handle, + nRF5xGap::getInstance().processConnectionEvent(handle, role, - static_cast<Gap::AddressType_t>(peer->addr_type), peer->addr, - static_cast<Gap::AddressType_t>(own->addr_type), own->addr, + static_cast<BLEProtocol::AddressType::Type>(peer->addr_type), peer->addr, + static_cast<BLEProtocol::AddressType::Type>(own->addr_type), own->addr, params); break; } @@ -167,7 +164,7 @@ Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle; // Since we are not in a connection and have not started advertising, // store bonds - gap.setConnectionHandle (BLE_CONN_HANDLE_INVALID); + nRF5xGap::getInstance().setConnectionHandle (BLE_CONN_HANDLE_INVALID); Gap::DisconnectionReason_t reason; switch (p_ble_evt->evt.gap_evt.params.disconnected.reason) { @@ -186,16 +183,16 @@ reason = static_cast<Gap::DisconnectionReason_t>(p_ble_evt->evt.gap_evt.params.disconnected.reason); break; } - gap.processDisconnectionEvent(handle, reason); + nRF5xGap::getInstance().processDisconnectionEvent(handle, reason); break; } case BLE_GAP_EVT_PASSKEY_DISPLAY: - securityManager.processPasskeyDisplayEvent(p_ble_evt->evt.gap_evt.conn_handle, p_ble_evt->evt.gap_evt.params.passkey_display.passkey); + nRF5xSecurityManager::getInstance().processPasskeyDisplayEvent(p_ble_evt->evt.gap_evt.conn_handle, p_ble_evt->evt.gap_evt.params.passkey_display.passkey); break; case BLE_GAP_EVT_TIMEOUT: - gap.processTimeoutEvent(static_cast<Gap::TimeoutSource_t>(p_ble_evt->evt.gap_evt.params.timeout.src)); + nRF5xGap::getInstance().processTimeoutEvent(static_cast<Gap::TimeoutSource_t>(p_ble_evt->evt.gap_evt.params.timeout.src)); break; case BLE_GATTC_EVT_TIMEOUT: @@ -207,12 +204,12 @@ case BLE_GAP_EVT_ADV_REPORT: { const ble_gap_evt_adv_report_t *advReport = &p_ble_evt->evt.gap_evt.params.adv_report; - gap.processAdvertisementReport(advReport->peer_addr.addr, - advReport->rssi, - advReport->scan_rsp, - static_cast<GapAdvertisingParams::AdvertisingType_t>(advReport->type), - advReport->dlen, - advReport->data); + nRF5xGap::getInstance().processAdvertisementReport(advReport->peer_addr.addr, + advReport->rssi, + advReport->scan_rsp, + static_cast<GapAdvertisingParams::AdvertisingType_t>(advReport->type), + advReport->dlen, + advReport->data); break; } @@ -220,7 +217,7 @@ break; } - gattServer.hwCallback(p_ble_evt); + nRF5xGattServer::getInstance().hwCallback(p_ble_evt); } /*! @brief Callback when an error occurs inside the SoftDevice */