rename nRF51... to nRF5x...

This prepares us to support nRF52.
This commit is contained in:
Rohit Grover 2015-07-06 14:17:22 +01:00
parent e408ce6f02
commit 0eb58d86f5
17 changed files with 151 additions and 151 deletions

View File

@ -31,9 +31,9 @@
#include "pstorage.h" #include "pstorage.h"
#include "ble/GapEvents.h" #include "ble/GapEvents.h"
#include "nRF51Gap.h" #include "nRF5xGap.h"
#include "nRF51GattServer.h" #include "nRF5xGattServer.h"
#include "nRF51SecurityManager.h" #include "nRF5xSecurityManager.h"
#include "device_manager.h" #include "device_manager.h"
@ -113,11 +113,11 @@ static void btle_handler(ble_evt_t *p_ble_evt)
switch (p_ble_evt->header.evt_id) { switch (p_ble_evt->header.evt_id) {
case BLE_GAP_EVT_CONNECTED: { case BLE_GAP_EVT_CONNECTED: {
Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle; Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle;
nRF51Gap::getInstance().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 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 *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; const ble_gap_addr_t *own = &p_ble_evt->evt.gap_evt.params.connected.own_addr;
nRF51Gap::getInstance().processConnectionEvent(handle, nRF5xGap::getInstance().processConnectionEvent(handle,
static_cast<Gap::Role_t>(p_ble_evt->evt.gap_evt.params.connected.role), static_cast<Gap::Role_t>(p_ble_evt->evt.gap_evt.params.connected.role),
static_cast<Gap::AddressType_t>(peer->addr_type), peer->addr, static_cast<Gap::AddressType_t>(peer->addr_type), peer->addr,
static_cast<Gap::AddressType_t>(own->addr_type), own->addr, static_cast<Gap::AddressType_t>(own->addr_type), own->addr,
@ -129,7 +129,7 @@ static void btle_handler(ble_evt_t *p_ble_evt)
Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle; Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle;
// Since we are not in a connection and have not started advertising, // Since we are not in a connection and have not started advertising,
// store bonds // store bonds
nRF51Gap::getInstance().setConnectionHandle (BLE_CONN_HANDLE_INVALID); nRF5xGap::getInstance().setConnectionHandle (BLE_CONN_HANDLE_INVALID);
Gap::DisconnectionReason_t reason; Gap::DisconnectionReason_t reason;
switch (p_ble_evt->evt.gap_evt.params.disconnected.reason) { switch (p_ble_evt->evt.gap_evt.params.disconnected.reason) {
@ -148,16 +148,16 @@ static void btle_handler(ble_evt_t *p_ble_evt)
reason = static_cast<Gap::DisconnectionReason_t>(p_ble_evt->evt.gap_evt.params.disconnected.reason); reason = static_cast<Gap::DisconnectionReason_t>(p_ble_evt->evt.gap_evt.params.disconnected.reason);
break; break;
} }
nRF51Gap::getInstance().processDisconnectionEvent(handle, reason); nRF5xGap::getInstance().processDisconnectionEvent(handle, reason);
break; break;
} }
case BLE_GAP_EVT_PASSKEY_DISPLAY: case BLE_GAP_EVT_PASSKEY_DISPLAY:
nRF51SecurityManager::getInstance().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; break;
case BLE_GAP_EVT_TIMEOUT: case BLE_GAP_EVT_TIMEOUT:
nRF51Gap::getInstance().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; break;
case BLE_GATTC_EVT_TIMEOUT: case BLE_GATTC_EVT_TIMEOUT:
@ -169,7 +169,7 @@ static void btle_handler(ble_evt_t *p_ble_evt)
case BLE_GAP_EVT_ADV_REPORT: { case BLE_GAP_EVT_ADV_REPORT: {
const ble_gap_evt_adv_report_t *advReport = &p_ble_evt->evt.gap_evt.params.adv_report; const ble_gap_evt_adv_report_t *advReport = &p_ble_evt->evt.gap_evt.params.adv_report;
nRF51Gap::getInstance().processAdvertisementReport(advReport->peer_addr.addr, nRF5xGap::getInstance().processAdvertisementReport(advReport->peer_addr.addr,
advReport->rssi, advReport->rssi,
advReport->scan_rsp, advReport->scan_rsp,
static_cast<GapAdvertisingParams::AdvertisingType_t>(advReport->type), static_cast<GapAdvertisingParams::AdvertisingType_t>(advReport->type),
@ -182,7 +182,7 @@ static void btle_handler(ble_evt_t *p_ble_evt)
break; break;
} }
nRF51GattServer::getInstance().hwCallback(p_ble_evt); nRF5xGattServer::getInstance().hwCallback(p_ble_evt);
} }
/*! @brief Callback when an error occurs inside the SoftDevice */ /*! @brief Callback when an error occurs inside the SoftDevice */

View File

@ -14,12 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
#include "nRF51ServiceDiscovery.h" #include "nRF5xServiceDiscovery.h"
#include "nRF51GattClient.h" #include "nRF5xGattClient.h"
void bleGattcEventHandler(const ble_evt_t *p_ble_evt) void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
{ {
nRF51ServiceDiscovery &sdSingleton = nRF51GattClient::getInstance().discovery; nRF5xServiceDiscovery &sdSingleton = nRF5xGattClient::getInstance().discovery;
switch (p_ble_evt->header.evt_id) { switch (p_ble_evt->header.evt_id) {
case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP:
@ -61,7 +61,7 @@ void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
.len = p_ble_evt->evt.gattc_evt.params.read_rsp.len, .len = p_ble_evt->evt.gattc_evt.params.read_rsp.len,
.data = p_ble_evt->evt.gattc_evt.params.read_rsp.data, .data = p_ble_evt->evt.gattc_evt.params.read_rsp.data,
}; };
nRF51GattClient::getInstance().processReadResponse(&response); nRF5xGattClient::getInstance().processReadResponse(&response);
} }
break; break;
@ -73,7 +73,7 @@ void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
.len = p_ble_evt->evt.gattc_evt.params.write_rsp.len, .len = p_ble_evt->evt.gattc_evt.params.write_rsp.len,
.data = p_ble_evt->evt.gattc_evt.params.write_rsp.data, .data = p_ble_evt->evt.gattc_evt.params.write_rsp.data,
}; };
nRF51GattClient::getInstance().processWriteResponse(&response); nRF5xGattClient::getInstance().processWriteResponse(&response);
} }
break; break;
@ -84,7 +84,7 @@ void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
params.len = p_ble_evt->evt.gattc_evt.params.hvx.len; params.len = p_ble_evt->evt.gattc_evt.params.hvx.len;
params.data = p_ble_evt->evt.gattc_evt.params.hvx.data; params.data = p_ble_evt->evt.gattc_evt.params.hvx.data;
nRF51GattClient::getInstance().processHVXEvent(&params); nRF5xGattClient::getInstance().processHVXEvent(&params);
} }
break; break;
} }

View File

@ -17,8 +17,8 @@
#include "btle.h" #include "btle.h"
#include "pstorage.h" #include "pstorage.h"
#include "nRF51Gap.h" #include "nRF5xGap.h"
#include "nRF51SecurityManager.h" #include "nRF5xSecurityManager.h"
#include "device_manager.h" #include "device_manager.h"
#include "btle_security.h" #include "btle_security.h"
@ -154,14 +154,14 @@ dm_handler(dm_handle_t const *p_handle, dm_event_t const *p_event, ret_code_t ev
switch (p_event->event_id) { switch (p_event->event_id) {
case DM_EVT_SECURITY_SETUP: /* started */ { case DM_EVT_SECURITY_SETUP: /* started */ {
const ble_gap_sec_params_t *peerParams = &p_event->event_param.p_gap_param->params.sec_params_request.peer_params; const ble_gap_sec_params_t *peerParams = &p_event->event_param.p_gap_param->params.sec_params_request.peer_params;
nRF51SecurityManager::getInstance().processSecuritySetupInitiatedEvent(p_event->event_param.p_gap_param->conn_handle, nRF5xSecurityManager::getInstance().processSecuritySetupInitiatedEvent(p_event->event_param.p_gap_param->conn_handle,
peerParams->bond, peerParams->bond,
peerParams->mitm, peerParams->mitm,
(SecurityManager::SecurityIOCapabilities_t)peerParams->io_caps); (SecurityManager::SecurityIOCapabilities_t)peerParams->io_caps);
break; break;
} }
case DM_EVT_SECURITY_SETUP_COMPLETE: case DM_EVT_SECURITY_SETUP_COMPLETE:
nRF51SecurityManager::getInstance(). nRF5xSecurityManager::getInstance().
processSecuritySetupCompletedEvent(p_event->event_param.p_gap_param->conn_handle, processSecuritySetupCompletedEvent(p_event->event_param.p_gap_param->conn_handle,
(SecurityManager::SecurityCompletionStatus_t)(p_event->event_param.p_gap_param->params.auth_status.auth_status)); (SecurityManager::SecurityCompletionStatus_t)(p_event->event_param.p_gap_param->params.auth_status.auth_status));
break; break;
@ -195,11 +195,11 @@ dm_handler(dm_handle_t const *p_handle, dm_event_t const *p_event, ret_code_t ev
break; break;
} }
nRF51SecurityManager::getInstance().processLinkSecuredEvent(p_event->event_param.p_gap_param->conn_handle, resolvedSecurityMode); nRF5xSecurityManager::getInstance().processLinkSecuredEvent(p_event->event_param.p_gap_param->conn_handle, resolvedSecurityMode);
break; break;
} }
case DM_EVT_DEVICE_CONTEXT_STORED: case DM_EVT_DEVICE_CONTEXT_STORED:
nRF51SecurityManager::getInstance().processSecurityContextStoredEvent(p_event->event_param.p_gap_param->conn_handle); nRF5xSecurityManager::getInstance().processSecurityContextStoredEvent(p_event->event_param.p_gap_param->conn_handle);
break; break;
default: default:
break; break;

View File

@ -14,16 +14,16 @@
* limitations under the License. * limitations under the License.
*/ */
#include "nRF51DiscoveredCharacteristic.h" #include "nRF5xDiscoveredCharacteristic.h"
#include "nRF51GattClient.h" #include "nRF5xGattClient.h"
#include "ble_gatt.h" #include "ble_gatt.h"
void void
nRF51DiscoveredCharacteristic::setup(nRF51GattClient *gattcIn, nRF5xDiscoveredCharacteristic::setup(nRF5xGattClient *gattcIn,
Gap::Handle_t connectionHandleIn, Gap::Handle_t connectionHandleIn,
ble_gatt_char_props_t propsIn, ble_gatt_char_props_t propsIn,
GattAttribute::Handle_t declHandleIn, GattAttribute::Handle_t declHandleIn,
GattAttribute::Handle_t valueHandleIn) GattAttribute::Handle_t valueHandleIn)
{ {
gattc = gattcIn; gattc = gattcIn;
connHandle = connectionHandleIn; connHandle = connectionHandleIn;
@ -40,12 +40,12 @@ nRF51DiscoveredCharacteristic::setup(nRF51GattClient *gattcIn,
} }
void void
nRF51DiscoveredCharacteristic::setup(nRF51GattClient *gattcIn, nRF5xDiscoveredCharacteristic::setup(nRF5xGattClient *gattcIn,
Gap::Handle_t connectionHandleIn, Gap::Handle_t connectionHandleIn,
UUID::ShortUUIDBytes_t uuidIn, UUID::ShortUUIDBytes_t uuidIn,
ble_gatt_char_props_t propsIn, ble_gatt_char_props_t propsIn,
GattAttribute::Handle_t declHandleIn, GattAttribute::Handle_t declHandleIn,
GattAttribute::Handle_t valueHandleIn) GattAttribute::Handle_t valueHandleIn)
{ {
gattc = gattcIn; gattc = gattcIn;
connHandle = connectionHandleIn; connHandle = connectionHandleIn;

View File

@ -20,17 +20,17 @@
#include "ble/DiscoveredCharacteristic.h" #include "ble/DiscoveredCharacteristic.h"
#include "ble_gatt.h" #include "ble_gatt.h"
class nRF51GattClient; /* forward declaration */ class nRF5xGattClient; /* forward declaration */
class nRF51DiscoveredCharacteristic : public DiscoveredCharacteristic { class nRF5xDiscoveredCharacteristic : public DiscoveredCharacteristic {
public: public:
void setup(nRF51GattClient *gattcIn, void setup(nRF5xGattClient *gattcIn,
Gap::Handle_t connectionHandleIn, Gap::Handle_t connectionHandleIn,
ble_gatt_char_props_t propsIn, ble_gatt_char_props_t propsIn,
GattAttribute::Handle_t declHandleIn, GattAttribute::Handle_t declHandleIn,
GattAttribute::Handle_t valueHandleIn); GattAttribute::Handle_t valueHandleIn);
void setup(nRF51GattClient *gattcIn, void setup(nRF5xGattClient *gattcIn,
Gap::Handle_t connectionHandleIn, Gap::Handle_t connectionHandleIn,
UUID::ShortUUIDBytes_t uuidIn, UUID::ShortUUIDBytes_t uuidIn,
ble_gatt_char_props_t propsIn, ble_gatt_char_props_t propsIn,

View File

@ -14,15 +14,15 @@
* limitations under the License. * limitations under the License.
*/ */
#include "nRF51Gap.h" #include "nRF5xGap.h"
#include "mbed.h" #include "mbed.h"
#include "common/common.h" #include "common/common.h"
#include "ble_advdata.h" #include "ble_advdata.h"
#include "ble_hci.h" #include "ble_hci.h"
nRF51Gap &nRF51Gap::getInstance() { nRF5xGap &nRF5xGap::getInstance() {
static nRF51Gap m_instance; static nRF5xGap m_instance;
return m_instance; return m_instance;
} }
@ -63,7 +63,7 @@ nRF51Gap &nRF51Gap::getInstance() {
@endcode @endcode
*/ */
/**************************************************************************/ /**************************************************************************/
ble_error_t nRF51Gap::setAdvertisingData(const GapAdvertisingData &advData, const GapAdvertisingData &scanResponse) ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, const GapAdvertisingData &scanResponse)
{ {
/* Make sure we don't exceed the advertising payload length */ /* Make sure we don't exceed the advertising payload length */
if (advData.getPayloadLen() > GAP_ADVERTISING_DATA_MAX_PAYLOAD) { if (advData.getPayloadLen() > GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
@ -128,7 +128,7 @@ ble_error_t nRF51Gap::setAdvertisingData(const GapAdvertisingData &advData, cons
@endcode @endcode
*/ */
/**************************************************************************/ /**************************************************************************/
ble_error_t nRF51Gap::startAdvertising(const GapAdvertisingParams &params) ble_error_t nRF5xGap::startAdvertising(const GapAdvertisingParams &params)
{ {
/* Make sure we support the advertising type */ /* Make sure we support the advertising type */
if (params.getAdvertisingType() == GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) { if (params.getAdvertisingType() == GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) {
@ -196,7 +196,7 @@ ble_error_t nRF51Gap::startAdvertising(const GapAdvertisingParams &params)
@endcode @endcode
*/ */
/**************************************************************************/ /**************************************************************************/
ble_error_t nRF51Gap::stopAdvertising(void) ble_error_t nRF5xGap::stopAdvertising(void)
{ {
/* Stop Advertising */ /* Stop Advertising */
ASSERT(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE); ASSERT(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
@ -206,7 +206,7 @@ ble_error_t nRF51Gap::stopAdvertising(void)
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
ble_error_t nRF51Gap::connect(const Address_t peerAddr, ble_error_t nRF5xGap::connect(const Address_t peerAddr,
Gap::AddressType_t peerAddrType, Gap::AddressType_t peerAddrType,
const ConnectionParams_t *connectionParams, const ConnectionParams_t *connectionParams,
const GapScanningParams *scanParamsIn) const GapScanningParams *scanParamsIn)
@ -265,7 +265,7 @@ ble_error_t nRF51Gap::connect(const Address_t peerAddr,
} }
} }
ble_error_t nRF51Gap::disconnect(Handle_t connectionHandle, DisconnectionReason_t reason) ble_error_t nRF5xGap::disconnect(Handle_t connectionHandle, DisconnectionReason_t reason)
{ {
state.advertising = 0; state.advertising = 0;
state.connected = 0; state.connected = 0;
@ -296,12 +296,12 @@ ble_error_t nRF51Gap::disconnect(Handle_t connectionHandle, DisconnectionReason_
@retval BLE_ERROR_NONE @retval BLE_ERROR_NONE
Everything executed properly Everything executed properly
*/ */
ble_error_t nRF51Gap::disconnect(DisconnectionReason_t reason) ble_error_t nRF5xGap::disconnect(DisconnectionReason_t reason)
{ {
return disconnect(m_connectionHandle, reason); return disconnect(m_connectionHandle, reason);
} }
ble_error_t nRF51Gap::getPreferredConnectionParams(ConnectionParams_t *params) ble_error_t nRF5xGap::getPreferredConnectionParams(ConnectionParams_t *params)
{ {
ASSERT_INT(NRF_SUCCESS, ASSERT_INT(NRF_SUCCESS,
sd_ble_gap_ppcp_get(reinterpret_cast<ble_gap_conn_params_t *>(params)), sd_ble_gap_ppcp_get(reinterpret_cast<ble_gap_conn_params_t *>(params)),
@ -310,7 +310,7 @@ ble_error_t nRF51Gap::getPreferredConnectionParams(ConnectionParams_t *params)
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
ble_error_t nRF51Gap::setPreferredConnectionParams(const ConnectionParams_t *params) ble_error_t nRF5xGap::setPreferredConnectionParams(const ConnectionParams_t *params)
{ {
ASSERT_INT(NRF_SUCCESS, ASSERT_INT(NRF_SUCCESS,
sd_ble_gap_ppcp_set(reinterpret_cast<const ble_gap_conn_params_t *>(params)), sd_ble_gap_ppcp_set(reinterpret_cast<const ble_gap_conn_params_t *>(params)),
@ -319,7 +319,7 @@ ble_error_t nRF51Gap::setPreferredConnectionParams(const ConnectionParams_t *par
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
ble_error_t nRF51Gap::updateConnectionParams(Handle_t handle, const ConnectionParams_t *newParams) ble_error_t nRF5xGap::updateConnectionParams(Handle_t handle, const ConnectionParams_t *newParams)
{ {
uint32_t rc; uint32_t rc;
@ -336,7 +336,7 @@ ble_error_t nRF51Gap::updateConnectionParams(Handle_t handle, const ConnectionPa
@brief Sets the 16-bit connection handle @brief Sets the 16-bit connection handle
*/ */
/**************************************************************************/ /**************************************************************************/
void nRF51Gap::setConnectionHandle(uint16_t con_handle) void nRF5xGap::setConnectionHandle(uint16_t con_handle)
{ {
m_connectionHandle = con_handle; m_connectionHandle = con_handle;
} }
@ -346,7 +346,7 @@ void nRF51Gap::setConnectionHandle(uint16_t con_handle)
@brief Gets the 16-bit connection handle @brief Gets the 16-bit connection handle
*/ */
/**************************************************************************/ /**************************************************************************/
uint16_t nRF51Gap::getConnectionHandle(void) uint16_t nRF5xGap::getConnectionHandle(void)
{ {
return m_connectionHandle; return m_connectionHandle;
} }
@ -367,7 +367,7 @@ uint16_t nRF51Gap::getConnectionHandle(void)
@endcode @endcode
*/ */
/**************************************************************************/ /**************************************************************************/
ble_error_t nRF51Gap::setAddress(AddressType_t type, const Address_t address) ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
{ {
if (type > ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE) { if (type > ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE) {
return BLE_ERROR_PARAM_OUT_OF_RANGE; return BLE_ERROR_PARAM_OUT_OF_RANGE;
@ -382,7 +382,7 @@ ble_error_t nRF51Gap::setAddress(AddressType_t type, const Address_t address)
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
ble_error_t nRF51Gap::getAddress(AddressType_t *typeP, Address_t address) ble_error_t nRF5xGap::getAddress(AddressType_t *typeP, Address_t address)
{ {
ble_gap_addr_t dev_addr; ble_gap_addr_t dev_addr;
if (sd_ble_gap_address_get(&dev_addr) != NRF_SUCCESS) { if (sd_ble_gap_address_get(&dev_addr) != NRF_SUCCESS) {
@ -398,7 +398,7 @@ ble_error_t nRF51Gap::getAddress(AddressType_t *typeP, Address_t address)
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
ble_error_t nRF51Gap::setDeviceName(const uint8_t *deviceName) ble_error_t nRF5xGap::setDeviceName(const uint8_t *deviceName)
{ {
ble_gap_conn_sec_mode_t sec_mode; ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed
@ -410,7 +410,7 @@ ble_error_t nRF51Gap::setDeviceName(const uint8_t *deviceName)
} }
} }
ble_error_t nRF51Gap::getDeviceName(uint8_t *deviceName, unsigned *lengthP) ble_error_t nRF5xGap::getDeviceName(uint8_t *deviceName, unsigned *lengthP)
{ {
if (sd_ble_gap_device_name_get(deviceName, (uint16_t *)lengthP) == NRF_SUCCESS) { if (sd_ble_gap_device_name_get(deviceName, (uint16_t *)lengthP) == NRF_SUCCESS) {
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
@ -419,7 +419,7 @@ ble_error_t nRF51Gap::getDeviceName(uint8_t *deviceName, unsigned *lengthP)
} }
} }
ble_error_t nRF51Gap::setAppearance(GapAdvertisingData::Appearance appearance) ble_error_t nRF5xGap::setAppearance(GapAdvertisingData::Appearance appearance)
{ {
if (sd_ble_gap_appearance_set(appearance) == NRF_SUCCESS) { if (sd_ble_gap_appearance_set(appearance) == NRF_SUCCESS) {
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
@ -428,7 +428,7 @@ ble_error_t nRF51Gap::setAppearance(GapAdvertisingData::Appearance appearance)
} }
} }
ble_error_t nRF51Gap::getAppearance(GapAdvertisingData::Appearance *appearanceP) ble_error_t nRF5xGap::getAppearance(GapAdvertisingData::Appearance *appearanceP)
{ {
if (sd_ble_gap_appearance_get(reinterpret_cast<uint16_t *>(appearanceP))) { if (sd_ble_gap_appearance_get(reinterpret_cast<uint16_t *>(appearanceP))) {
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
@ -438,7 +438,7 @@ ble_error_t nRF51Gap::getAppearance(GapAdvertisingData::Appearance *appearanceP)
} }
/* (Valid values are -40, -20, -16, -12, -8, -4, 0, 4) */ /* (Valid values are -40, -20, -16, -12, -8, -4, 0, 4) */
ble_error_t nRF51Gap::setTxPower(int8_t txPower) ble_error_t nRF5xGap::setTxPower(int8_t txPower)
{ {
unsigned rc; unsigned rc;
if ((rc = sd_ble_gap_tx_power_set(txPower)) != NRF_SUCCESS) { if ((rc = sd_ble_gap_tx_power_set(txPower)) != NRF_SUCCESS) {
@ -454,7 +454,7 @@ ble_error_t nRF51Gap::setTxPower(int8_t txPower)
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
void nRF51Gap::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP) void nRF5xGap::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP)
{ {
static const int8_t permittedTxValues[] = { static const int8_t permittedTxValues[] = {
-40, -30, -20, -16, -12, -8, -4, 0, 4 -40, -30, -20, -16, -12, -8, -4, 0, 4

View File

@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef __NRF51822_GAP_H__ #ifndef __NRF5x_GAP_H__
#define __NRF51822_GAP_H__ #define __NRF5x_GAP_H__
#include "mbed.h" #include "mbed.h"
#include "ble/blecommon.h" #include "ble/blecommon.h"
@ -35,10 +35,10 @@
*/ */
/**************************************************************************/ /**************************************************************************/
class nRF51Gap : public Gap class nRF5xGap : public Gap
{ {
public: public:
static nRF51Gap &getInstance(); static nRF5xGap &getInstance();
/* Functions that must be implemented from Gap */ /* Functions that must be implemented from Gap */
virtual ble_error_t setAddress(AddressType_t type, const Address_t address); virtual ble_error_t setAddress(AddressType_t type, const Address_t address);
@ -102,12 +102,12 @@ public:
private: private:
uint16_t m_connectionHandle; uint16_t m_connectionHandle;
nRF51Gap() { nRF5xGap() {
m_connectionHandle = BLE_CONN_HANDLE_INVALID; m_connectionHandle = BLE_CONN_HANDLE_INVALID;
} }
nRF51Gap(nRF51Gap const &); nRF5xGap(nRF5xGap const &);
void operator=(nRF51Gap const &); void operator=(nRF5xGap const &);
}; };
#endif // ifndef __NRF51822_GAP_H__ #endif // ifndef __NRF5x_GAP_H__

View File

@ -14,17 +14,17 @@
* limitations under the License. * limitations under the License.
*/ */
#include "nRF51GattClient.h" #include "nRF5xGattClient.h"
nRF51GattClient nRFGattClientSingleton; nRF5xGattClient nRFGattClientSingleton;
nRF51GattClient & nRF5xGattClient &
nRF51GattClient::getInstance(void) { nRF5xGattClient::getInstance(void) {
return nRFGattClientSingleton; return nRFGattClientSingleton;
} }
ble_error_t ble_error_t
nRF51GattClient::launchServiceDiscovery(Gap::Handle_t connectionHandle, nRF5xGattClient::launchServiceDiscovery(Gap::Handle_t connectionHandle,
ServiceDiscovery::ServiceCallback_t sc, ServiceDiscovery::ServiceCallback_t sc,
ServiceDiscovery::CharacteristicCallback_t cc, ServiceDiscovery::CharacteristicCallback_t cc,
const UUID &matchingServiceUUIDIn, const UUID &matchingServiceUUIDIn,

View File

@ -18,12 +18,12 @@
#define __NRF51822_GATT_CLIENT_H__ #define __NRF51822_GATT_CLIENT_H__
#include "ble/GattClient.h" #include "ble/GattClient.h"
#include "nRF51ServiceDiscovery.h" #include "nRF5xServiceDiscovery.h"
class nRF51GattClient : public GattClient class nRF5xGattClient : public GattClient
{ {
public: public:
static nRF51GattClient &getInstance(); static nRF5xGattClient &getInstance();
/** /**
* Launch service discovery. Once launched, service discovery will remain * Launch service discovery. Once launched, service discovery will remain
@ -140,18 +140,18 @@ public:
} }
public: public:
nRF51GattClient() : discovery(this) { nRF5xGattClient() : discovery(this) {
/* empty */ /* empty */
} }
friend void bleGattcEventHandler(const ble_evt_t *p_ble_evt); friend void bleGattcEventHandler(const ble_evt_t *p_ble_evt);
private: private:
nRF51GattClient(const nRF51GattClient &); nRF5xGattClient(const nRF5xGattClient &);
const nRF51GattClient& operator=(const nRF51GattClient &); const nRF5xGattClient& operator=(const nRF5xGattClient &);
private: private:
nRF51ServiceDiscovery discovery; nRF5xServiceDiscovery discovery;
}; };
#endif // ifndef __NRF51822_GATT_CLIENT_H__ #endif // ifndef __NRF51822_GATT_CLIENT_H__

View File

@ -14,16 +14,16 @@
* limitations under the License. * limitations under the License.
*/ */
#include "nRF51GattServer.h" #include "nRF5xGattServer.h"
#include "mbed.h" #include "mbed.h"
#include "common/common.h" #include "common/common.h"
#include "btle/custom/custom_helper.h" #include "btle/custom/custom_helper.h"
#include "nRF51Gap.h" #include "nRF5xGap.h"
nRF51GattServer &nRF51GattServer::getInstance(void) { nRF5xGattServer &nRF5xGattServer::getInstance(void) {
static nRF51GattServer m_instance; static nRF5xGattServer m_instance;
return m_instance; return m_instance;
} }
@ -43,7 +43,7 @@ nRF51GattServer &nRF51GattServer::getInstance(void) {
@endcode @endcode
*/ */
/**************************************************************************/ /**************************************************************************/
ble_error_t nRF51GattServer::addService(GattService &service) ble_error_t nRF5xGattServer::addService(GattService &service)
{ {
/* ToDo: Make sure we don't overflow the array, etc. */ /* ToDo: Make sure we don't overflow the array, etc. */
/* ToDo: Make sure this service UUID doesn't already exist (?) */ /* ToDo: Make sure this service UUID doesn't already exist (?) */
@ -157,12 +157,12 @@ ble_error_t nRF51GattServer::addService(GattService &service)
Everything executed properly Everything executed properly
*/ */
/**************************************************************************/ /**************************************************************************/
ble_error_t nRF51GattServer::read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) ble_error_t nRF5xGattServer::read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP)
{ {
return read(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, lengthP); return read(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, lengthP);
} }
ble_error_t nRF51GattServer::read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) ble_error_t nRF5xGattServer::read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP)
{ {
ble_gatts_value_t value = { ble_gatts_value_t value = {
.len = *lengthP, .len = *lengthP,
@ -197,14 +197,14 @@ ble_error_t nRF51GattServer::read(Gap::Handle_t connectionHandle, GattAttribute:
Everything executed properly Everything executed properly
*/ */
/**************************************************************************/ /**************************************************************************/
ble_error_t nRF51GattServer::write(GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly) ble_error_t nRF5xGattServer::write(GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly)
{ {
return write(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, len, localOnly); return write(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, len, localOnly);
} }
ble_error_t nRF51GattServer::write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly) ble_error_t nRF5xGattServer::write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly)
{ {
uint16_t gapConnectionHandle = nRF51Gap::getInstance().getConnectionHandle(); uint16_t gapConnectionHandle = nRF5xGap::getInstance().getConnectionHandle();
ble_error_t returnValue = BLE_ERROR_NONE; ble_error_t returnValue = BLE_ERROR_NONE;
ble_gatts_value_t value = { ble_gatts_value_t value = {
@ -259,13 +259,13 @@ ble_error_t nRF51GattServer::write(Gap::Handle_t connectionHandle, GattAttribute
return returnValue; return returnValue;
} }
ble_error_t nRF51GattServer::areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP) ble_error_t nRF5xGattServer::areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP)
{ {
/* Forward the call with the default connection handle. */ /* Forward the call with the default connection handle. */
return areUpdatesEnabled(nRF51Gap::getInstance().getConnectionHandle(), characteristic, enabledP); return areUpdatesEnabled(nRF5xGap::getInstance().getConnectionHandle(), characteristic, enabledP);
} }
ble_error_t nRF51GattServer::areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP) ble_error_t nRF5xGattServer::areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP)
{ {
int characteristicIndex = resolveValueHandleToCharIndex(characteristic.getValueHandle()); int characteristicIndex = resolveValueHandleToCharIndex(characteristic.getValueHandle());
if (characteristicIndex == -1) { if (characteristicIndex == -1) {
@ -297,7 +297,7 @@ ble_error_t nRF51GattServer::areUpdatesEnabled(Gap::Handle_t connectionHandle, c
@brief Callback handler for events getting pushed up from the SD @brief Callback handler for events getting pushed up from the SD
*/ */
/**************************************************************************/ /**************************************************************************/
void nRF51GattServer::hwCallback(ble_evt_t *p_ble_evt) void nRF5xGattServer::hwCallback(ble_evt_t *p_ble_evt)
{ {
GattAttribute::Handle_t handle_value; GattAttribute::Handle_t handle_value;
GattServerEvents::gattEvent_t eventType; GattServerEvents::gattEvent_t eventType;

View File

@ -24,10 +24,10 @@
#include "ble/Gap.h" #include "ble/Gap.h"
#include "ble/GattServer.h" #include "ble/GattServer.h"
class nRF51GattServer : public GattServer class nRF5xGattServer : public GattServer
{ {
public: public:
static nRF51GattServer &getInstance(); static nRF5xGattServer &getInstance();
/* Functions that must be implemented from GattServer */ /* Functions that must be implemented from GattServer */
virtual ble_error_t addService(GattService &); virtual ble_error_t addService(GattService &);
@ -86,13 +86,13 @@ private:
uint8_t descriptorCount; uint8_t descriptorCount;
uint16_t nrfDescriptorHandles[BLE_TOTAL_DESCRIPTORS]; uint16_t nrfDescriptorHandles[BLE_TOTAL_DESCRIPTORS];
nRF51GattServer() : GattServer(), p_characteristics(), nrfCharacteristicHandles(), p_descriptors(), descriptorCount(0), nrfDescriptorHandles() { nRF5xGattServer() : GattServer(), p_characteristics(), nrfCharacteristicHandles(), p_descriptors(), descriptorCount(0), nrfDescriptorHandles() {
/* empty */ /* empty */
} }
private: private:
nRF51GattServer(const nRF51GattServer &); nRF5xGattServer(const nRF5xGattServer &);
const nRF51GattServer& operator=(const nRF51GattServer &); const nRF5xGattServer& operator=(const nRF5xGattServer &);
}; };
#endif // ifndef __NRF51822_GATT_SERVER_H__ #endif // ifndef __NRF51822_GATT_SERVER_H__

View File

@ -14,9 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
#include "nRF51SecurityManager.h" #include "nRF5xSecurityManager.h"
nRF51SecurityManager &nRF51SecurityManager::getInstance(void) { nRF5xSecurityManager &nRF5xSecurityManager::getInstance(void) {
static nRF51SecurityManager m_instance; static nRF5xSecurityManager m_instance;
return m_instance; return m_instance;
} }

View File

@ -22,10 +22,10 @@
#include "ble/SecurityManager.h" #include "ble/SecurityManager.h"
#include "btle_security.h" #include "btle_security.h"
class nRF51SecurityManager : public SecurityManager class nRF5xSecurityManager : public SecurityManager
{ {
public: public:
static nRF51SecurityManager &getInstance(); static nRF5xSecurityManager &getInstance();
/* Functions that must be implemented from SecurityManager */ /* Functions that must be implemented from SecurityManager */
virtual ble_error_t init(bool enableBonding, virtual ble_error_t init(bool enableBonding,
@ -44,13 +44,13 @@ public:
} }
public: public:
nRF51SecurityManager() { nRF5xSecurityManager() {
/* empty */ /* empty */
} }
private: private:
nRF51SecurityManager(const nRF51SecurityManager &); nRF5xSecurityManager(const nRF5xSecurityManager &);
const nRF51SecurityManager& operator=(const nRF51SecurityManager &); const nRF5xSecurityManager& operator=(const nRF5xSecurityManager &);
}; };
#endif // ifndef __NRF51822_SECURITY_MANAGER_H__ #endif // ifndef __NRF51822_SECURITY_MANAGER_H__

View File

@ -14,10 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "nRF51ServiceDiscovery.h" #include "nRF5xServiceDiscovery.h"
ble_error_t ble_error_t
nRF51ServiceDiscovery::launchCharacteristicDiscovery(Gap::Handle_t connectionHandle, nRF5xServiceDiscovery::launchCharacteristicDiscovery(Gap::Handle_t connectionHandle,
Gap::Handle_t startHandle, Gap::Handle_t startHandle,
Gap::Handle_t endHandle) Gap::Handle_t endHandle)
{ {
@ -46,7 +46,7 @@ nRF51ServiceDiscovery::launchCharacteristicDiscovery(Gap::Handle_t connectionHan
} }
void void
nRF51ServiceDiscovery::setupDiscoveredServices(const ble_gattc_evt_prim_srvc_disc_rsp_t *response) nRF5xServiceDiscovery::setupDiscoveredServices(const ble_gattc_evt_prim_srvc_disc_rsp_t *response)
{ {
serviceIndex = 0; serviceIndex = 0;
numServices = response->count; numServices = response->count;
@ -76,7 +76,7 @@ nRF51ServiceDiscovery::setupDiscoveredServices(const ble_gattc_evt_prim_srvc_dis
} }
void void
nRF51ServiceDiscovery::setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response) nRF5xServiceDiscovery::setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response)
{ {
characteristicIndex = 0; characteristicIndex = 0;
numCharacteristics = response->count; numCharacteristics = response->count;
@ -112,7 +112,7 @@ nRF51ServiceDiscovery::setupDiscoveredCharacteristics(const ble_gattc_evt_char_d
} }
void void
nRF51ServiceDiscovery::progressCharacteristicDiscovery(void) nRF5xServiceDiscovery::progressCharacteristicDiscovery(void)
{ {
/* Iterate through the previously discovered characteristics cached in characteristics[]. */ /* Iterate through the previously discovered characteristics cached in characteristics[]. */
while ((state == CHARACTERISTIC_DISCOVERY_ACTIVE) && (characteristicIndex < numCharacteristics)) { while ((state == CHARACTERISTIC_DISCOVERY_ACTIVE) && (characteristicIndex < numCharacteristics)) {
@ -149,7 +149,7 @@ nRF51ServiceDiscovery::progressCharacteristicDiscovery(void)
} }
void void
nRF51ServiceDiscovery::progressServiceDiscovery(void) nRF5xServiceDiscovery::progressServiceDiscovery(void)
{ {
/* Iterate through the previously discovered services cached in services[]. */ /* Iterate through the previously discovered services cached in services[]. */
while ((state == SERVICE_DISCOVERY_ACTIVE) && (serviceIndex < numServices)) { while ((state == SERVICE_DISCOVERY_ACTIVE) && (serviceIndex < numServices)) {
@ -187,7 +187,7 @@ nRF51ServiceDiscovery::progressServiceDiscovery(void)
} }
void void
nRF51ServiceDiscovery::ServiceUUIDDiscoveryQueue::triggerFirst(void) nRF5xServiceDiscovery::ServiceUUIDDiscoveryQueue::triggerFirst(void)
{ {
while (numIndices) { /* loop until a call to char_value_by_uuid_read() succeeds or we run out of pending indices. */ while (numIndices) { /* loop until a call to char_value_by_uuid_read() succeeds or we run out of pending indices. */
parentDiscoveryObject->state = DISCOVER_SERVICE_UUIDS; parentDiscoveryObject->state = DISCOVER_SERVICE_UUIDS;
@ -217,7 +217,7 @@ nRF51ServiceDiscovery::ServiceUUIDDiscoveryQueue::triggerFirst(void)
} }
void void
nRF51ServiceDiscovery::CharUUIDDiscoveryQueue::triggerFirst(void) nRF5xServiceDiscovery::CharUUIDDiscoveryQueue::triggerFirst(void)
{ {
while (numIndices) { /* loop until a call to char_value_by_uuid_read() succeeds or we run out of pending indices. */ while (numIndices) { /* loop until a call to char_value_by_uuid_read() succeeds or we run out of pending indices. */
parentDiscoveryObject->state = DISCOVER_CHARACTERISTIC_UUIDS; parentDiscoveryObject->state = DISCOVER_CHARACTERISTIC_UUIDS;
@ -246,7 +246,7 @@ nRF51ServiceDiscovery::CharUUIDDiscoveryQueue::triggerFirst(void)
} }
void void
nRF51ServiceDiscovery::processDiscoverUUIDResponse(const ble_gattc_evt_char_val_by_uuid_read_rsp_t *response) nRF5xServiceDiscovery::processDiscoverUUIDResponse(const ble_gattc_evt_char_val_by_uuid_read_rsp_t *response)
{ {
if (state == DISCOVER_SERVICE_UUIDS) { if (state == DISCOVER_SERVICE_UUIDS) {
if ((response->count == 1) && (response->value_len == UUID::LENGTH_OF_LONG_UUID)) { if ((response->count == 1) && (response->value_len == UUID::LENGTH_OF_LONG_UUID)) {

View File

@ -19,14 +19,14 @@
#include "ble/ServiceDiscovery.h" #include "ble/ServiceDiscovery.h"
#include "ble/DiscoveredService.h" #include "ble/DiscoveredService.h"
#include "nRF51DiscoveredCharacteristic.h" #include "nRF5xDiscoveredCharacteristic.h"
#include "ble.h" #include "ble.h"
#include "ble_gattc.h" #include "ble_gattc.h"
class nRF51GattClient; /* forward declaration */ class nRF5xGattClient; /* forward declaration */
class nRF51ServiceDiscovery : public ServiceDiscovery class nRF5xServiceDiscovery : public ServiceDiscovery
{ {
public: public:
static const uint16_t SRV_DISC_START_HANDLE = 0x0001; /**< The start handle value used during service discovery. */ static const uint16_t SRV_DISC_START_HANDLE = 0x0001; /**< The start handle value used during service discovery. */
@ -37,7 +37,7 @@ public:
static const unsigned BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV = 4; /**< Maximum number of characteristics per service we can retain information for. */ static const unsigned BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV = 4; /**< Maximum number of characteristics per service we can retain information for. */
public: public:
nRF51ServiceDiscovery(nRF51GattClient *gattcIn) : nRF5xServiceDiscovery(nRF5xGattClient *gattcIn) :
gattc(gattcIn), gattc(gattcIn),
serviceIndex(0), serviceIndex(0),
numServices(0), numServices(0),
@ -158,7 +158,7 @@ private:
*/ */
class ServiceUUIDDiscoveryQueue { class ServiceUUIDDiscoveryQueue {
public: public:
ServiceUUIDDiscoveryQueue(nRF51ServiceDiscovery *parent) : ServiceUUIDDiscoveryQueue(nRF5xServiceDiscovery *parent) :
numIndices(0), numIndices(0),
serviceIndices(), serviceIndices(),
parentDiscoveryObject(parent) { parentDiscoveryObject(parent) {
@ -207,7 +207,7 @@ private:
size_t numIndices; size_t numIndices;
int serviceIndices[BLE_DB_DISCOVERY_MAX_SRV]; int serviceIndices[BLE_DB_DISCOVERY_MAX_SRV];
nRF51ServiceDiscovery *parentDiscoveryObject; nRF5xServiceDiscovery *parentDiscoveryObject;
}; };
friend class ServiceUUIDDiscoveryQueue; friend class ServiceUUIDDiscoveryQueue;
@ -217,7 +217,7 @@ private:
*/ */
class CharUUIDDiscoveryQueue { class CharUUIDDiscoveryQueue {
public: public:
CharUUIDDiscoveryQueue(nRF51ServiceDiscovery *parent) : CharUUIDDiscoveryQueue(nRF5xServiceDiscovery *parent) :
numIndices(0), numIndices(0),
charIndices(), charIndices(),
parentDiscoveryObject(parent) { parentDiscoveryObject(parent) {
@ -266,7 +266,7 @@ private:
size_t numIndices; size_t numIndices;
int charIndices[BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV]; int charIndices[BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV];
nRF51ServiceDiscovery *parentDiscoveryObject; nRF5xServiceDiscovery *parentDiscoveryObject;
}; };
friend class CharUUIDDiscoveryQueue; friend class CharUUIDDiscoveryQueue;
@ -276,7 +276,7 @@ private:
void progressServiceDiscovery(void); void progressServiceDiscovery(void);
private: private:
nRF51GattClient *gattc; nRF5xGattClient *gattc;
private: private:
uint8_t serviceIndex; /**< Index of the current service being discovered. This is intended for internal use during service discovery.*/ uint8_t serviceIndex; /**< Index of the current service being discovered. This is intended for internal use during service discovery.*/
@ -294,7 +294,7 @@ private:
DiscoveredService services[BLE_DB_DISCOVERY_MAX_SRV]; /**< Information related to the current service being discovered. DiscoveredService services[BLE_DB_DISCOVERY_MAX_SRV]; /**< Information related to the current service being discovered.
* This is intended for internal use during service discovery. */ * This is intended for internal use during service discovery. */
nRF51DiscoveredCharacteristic characteristics[BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV]; nRF5xDiscoveredCharacteristic characteristics[BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV];
ServiceUUIDDiscoveryQueue serviceUUIDDiscoveryQueue; ServiceUUIDDiscoveryQueue serviceUUIDDiscoveryQueue;
CharUUIDDiscoveryQueue charUUIDDiscoveryQueue; CharUUIDDiscoveryQueue charUUIDDiscoveryQueue;

View File

@ -15,7 +15,7 @@
*/ */
#include "mbed.h" #include "mbed.h"
#include "nRF51822n.h" #include "nRF5xn.h"
#include "nrf_soc.h" #include "nrf_soc.h"
#include "btle/btle.h" #include "btle/btle.h"
@ -26,7 +26,7 @@
/** /**
* The singleton which represents the nRF51822 transport for the BLE. * The singleton which represents the nRF51822 transport for the BLE.
*/ */
static nRF51822n deviceInstance; static nRF5xn deviceInstance;
/** /**
* BLE-API requires an implementation of the following function in order to * BLE-API requires an implementation of the following function in order to
@ -38,15 +38,15 @@ createBLEInstance(void)
return (&deviceInstance); return (&deviceInstance);
} }
nRF51822n::nRF51822n(void) nRF5xn::nRF5xn(void)
{ {
} }
nRF51822n::~nRF51822n(void) nRF5xn::~nRF5xn(void)
{ {
} }
const char *nRF51822n::getVersion(void) const char *nRF5xn::getVersion(void)
{ {
static char versionString[32]; static char versionString[32];
static bool versionFetched = false; static bool versionFetched = false;
@ -71,7 +71,7 @@ const char *nRF51822n::getVersion(void)
return versionString; return versionString;
} }
ble_error_t nRF51822n::init(void) ble_error_t nRF5xn::init(void)
{ {
/* ToDo: Clear memory contents, reset the SD, etc. */ /* ToDo: Clear memory contents, reset the SD, etc. */
btle_init(); btle_init();
@ -79,13 +79,13 @@ ble_error_t nRF51822n::init(void)
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
ble_error_t nRF51822n::shutdown(void) ble_error_t nRF5xn::shutdown(void)
{ {
return (softdevice_handler_sd_disable() == NRF_SUCCESS) ? BLE_ERROR_NONE : BLE_STACK_BUSY; return (softdevice_handler_sd_disable() == NRF_SUCCESS) ? BLE_ERROR_NONE : BLE_STACK_BUSY;
} }
void void
nRF51822n::waitForEvent(void) nRF5xn::waitForEvent(void)
{ {
sd_app_evt_wait(); sd_app_evt_wait();
} }

View File

@ -20,44 +20,44 @@
#include "mbed.h" #include "mbed.h"
#include "ble/blecommon.h" #include "ble/blecommon.h"
#include "ble/BLE.h" #include "ble/BLE.h"
#include "nRF51Gap.h" #include "nRF5xGap.h"
#include "nRF51GattServer.h" #include "nRF5xGattServer.h"
#include "nRF51GattClient.h" #include "nRF5xGattClient.h"
#include "nRF51SecurityManager.h" #include "nRF5xSecurityManager.h"
#include "btle.h" #include "btle.h"
class nRF51822n : public BLEInstanceBase class nRF5xn : public BLEInstanceBase
{ {
public: public:
nRF51822n(void); nRF5xn(void);
virtual ~nRF51822n(void); virtual ~nRF5xn(void);
virtual ble_error_t init(void); virtual ble_error_t init(void);
virtual ble_error_t shutdown(void); virtual ble_error_t shutdown(void);
virtual const char *getVersion(void); virtual const char *getVersion(void);
virtual Gap &getGap() { virtual Gap &getGap() {
return nRF51Gap::getInstance(); return nRF5xGap::getInstance();
}; };
virtual const Gap &getGap() const { virtual const Gap &getGap() const {
return nRF51Gap::getInstance(); return nRF5xGap::getInstance();
}; };
virtual GattServer &getGattServer() { virtual GattServer &getGattServer() {
return nRF51GattServer::getInstance(); return nRF5xGattServer::getInstance();
}; };
virtual const GattServer &getGattServer() const { virtual const GattServer &getGattServer() const {
return nRF51GattServer::getInstance(); return nRF5xGattServer::getInstance();
}; };
virtual GattClient &getGattClient() { virtual GattClient &getGattClient() {
return nRF51GattClient::getInstance(); return nRF5xGattClient::getInstance();
} }
virtual const SecurityManager &getSecurityManager() const { virtual const SecurityManager &getSecurityManager() const {
return nRF51SecurityManager::getInstance(); return nRF5xSecurityManager::getInstance();
} }
virtual SecurityManager &getSecurityManager() { virtual SecurityManager &getSecurityManager() {
return nRF51SecurityManager::getInstance(); return nRF5xSecurityManager::getInstance();
} }
virtual void waitForEvent(void); virtual void waitForEvent(void);
}; };
#endif #endif