Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of nRF51822 by
Revision 416:5b7d26035f2b, committed 2015-08-11
- Comitter:
- rgrover1
- Date:
- Tue Aug 11 15:14:23 2015 +0100
- Parent:
- 415:92bda1851be2
- Child:
- 417:d79a89cccddd
- Commit message:
- Synchronized with git rev 3eabc779
Author: Jean-Philippe Brucker
Disable GattClient features when using S110 SoftDevice
S110 compatibility is already present, but this patch adds proper handling
of observer/central related features:
* Gap::startScan will return BLE_ERRROR_NOT_IMPLEMENTED (instead of
PARAM_OUT_OF_RANGE)
* nRF5xGattClient uses the default GattClient implementation when S110 is
in use. All if its methods return NOT_IMPLEMENTED.
Example: for an application that acts as both a central and a peripheral,
using S110 will make the ble.gap().startScan() call return
BLE_ERROR_NOT_IMPLEMENTED, and advertisement features will continue
running normally.
In addition, with GCC, this patch will free 344 bytes of RAM and 2504
bytes of flash.
Changed in this revision
--- a/source/btle/btle.cpp Tue Aug 11 15:14:23 2015 +0100
+++ b/source/btle/btle.cpp Tue Aug 11 15:14:23 2015 +0100
@@ -107,7 +107,9 @@
dm_ble_evt_handler(p_ble_evt);
+#if !defined(MCU_NORDIC_16K_S110) && !defined(MCU_NORDIC_32K_S110)
bleGattcEventHandler(p_ble_evt);
+#endif
/* Custom event handler */
switch (p_ble_evt->header.evt_id) {
--- a/source/btle/btle_discovery.cpp Tue Aug 11 15:14:23 2015 +0100
+++ b/source/btle/btle_discovery.cpp Tue Aug 11 15:14:23 2015 +0100
@@ -17,6 +17,7 @@
#include "nRF5xServiceDiscovery.h"
#include "nRF5xGattClient.h"
+#if !defined(MCU_NORDIC_16K_S110) && !defined(MCU_NORDIC_32K_S110)
void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
{
nRF5xServiceDiscovery &sdSingleton = nRF5xGattClient::getInstance().discovery;
@@ -56,11 +57,10 @@
case BLE_GATTC_EVT_READ_RSP: {
GattReadCallbackParams response = {
- .connHandle = p_ble_evt->evt.gattc_evt.conn_handle,
- .handle = p_ble_evt->evt.gattc_evt.params.read_rsp.handle,
- .offset = p_ble_evt->evt.gattc_evt.params.read_rsp.offset,
- .len = p_ble_evt->evt.gattc_evt.params.read_rsp.len,
- .data = p_ble_evt->evt.gattc_evt.params.read_rsp.data,
+ .handle = p_ble_evt->evt.gattc_evt.params.read_rsp.handle,
+ .offset = p_ble_evt->evt.gattc_evt.params.read_rsp.offset,
+ .len = p_ble_evt->evt.gattc_evt.params.read_rsp.len,
+ .data = p_ble_evt->evt.gattc_evt.params.read_rsp.data,
};
nRF5xGattClient::getInstance().processReadResponse(&response);
}
@@ -68,12 +68,11 @@
case BLE_GATTC_EVT_WRITE_RSP: {
GattWriteCallbackParams response = {
- .connHandle = p_ble_evt->evt.gattc_evt.conn_handle,
- .handle = p_ble_evt->evt.gattc_evt.params.write_rsp.handle,
- .writeOp = (GattWriteCallbackParams::WriteOp_t)(p_ble_evt->evt.gattc_evt.params.write_rsp.write_op),
- .offset = p_ble_evt->evt.gattc_evt.params.write_rsp.offset,
- .len = p_ble_evt->evt.gattc_evt.params.write_rsp.len,
- .data = p_ble_evt->evt.gattc_evt.params.write_rsp.data,
+ .handle = p_ble_evt->evt.gattc_evt.params.write_rsp.handle,
+ .writeOp = (GattWriteCallbackParams::WriteOp_t)(p_ble_evt->evt.gattc_evt.params.write_rsp.write_op),
+ .offset = p_ble_evt->evt.gattc_evt.params.write_rsp.offset,
+ .len = p_ble_evt->evt.gattc_evt.params.write_rsp.len,
+ .data = p_ble_evt->evt.gattc_evt.params.write_rsp.data,
};
nRF5xGattClient::getInstance().processWriteResponse(&response);
}
@@ -81,11 +80,10 @@
case BLE_GATTC_EVT_HVX: {
GattHVXCallbackParams params;
- params.connHandle = p_ble_evt->evt.gattc_evt.conn_handle;
- params.handle = p_ble_evt->evt.gattc_evt.params.hvx.handle;
- params.type = static_cast<HVXType_t>(p_ble_evt->evt.gattc_evt.params.hvx.type);
- params.len = p_ble_evt->evt.gattc_evt.params.hvx.len;
- params.data = p_ble_evt->evt.gattc_evt.params.hvx.data;
+ params.handle = p_ble_evt->evt.gattc_evt.params.hvx.handle;
+ params.type = static_cast<HVXType_t>(p_ble_evt->evt.gattc_evt.params.hvx.type);
+ params.len = p_ble_evt->evt.gattc_evt.params.hvx.len;
+ params.data = p_ble_evt->evt.gattc_evt.params.hvx.data;
nRF5xGattClient::getInstance().processHVXEvent(¶ms);
}
@@ -95,3 +93,4 @@
sdSingleton.progressCharacteristicDiscovery();
sdSingleton.progressServiceDiscovery();
}
+#endif
--- a/source/nRF5xGap.h Tue Aug 11 15:14:23 2015 +0100
+++ b/source/nRF5xGap.h Tue Aug 11 15:14:23 2015 +0100
@@ -80,6 +80,8 @@
return BLE_ERROR_UNSPECIFIED;
}
+/* Observer role is not supported by S110, return BLE_ERROR_NOT_IMPLEMENTED */
+#if !defined(MCU_NORDIC_16K_S110) && !defined(MCU_NORDIC_32K_S110)
virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams) {
ble_gap_scan_params_t scanParams = {
.active = scanningParams.getActiveScanning(), /**< If 1, perform active scanning (scan requests). */
@@ -104,6 +106,7 @@
return BLE_STACK_BUSY;
}
+#endif
private:
/**
--- a/source/nRF5xGattClient.cpp Tue Aug 11 15:14:23 2015 +0100
+++ b/source/nRF5xGattClient.cpp Tue Aug 11 15:14:23 2015 +0100
@@ -23,6 +23,7 @@
return nRFGattClientSingleton;
}
+#if !defined(MCU_NORDIC_16K_S110) && !defined(MCU_NORDIC_32K_S110)
ble_error_t
nRF5xGattClient::launchServiceDiscovery(Gap::Handle_t connectionHandle,
ServiceDiscovery::ServiceCallback_t sc,
@@ -31,4 +32,5 @@
const UUID &matchingCharacteristicUUIDIn)
{
return discovery.launch(connectionHandle, sc, cc, matchingServiceUUIDIn, matchingCharacteristicUUIDIn);
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
--- a/source/nRF5xGattClient.h Tue Aug 11 15:14:23 2015 +0100
+++ b/source/nRF5xGattClient.h Tue Aug 11 15:14:23 2015 +0100
@@ -26,6 +26,12 @@
static nRF5xGattClient &getInstance();
/**
+ * When using S110, all Gatt client features will return
+ * BLE_ERROR_NOT_IMPLEMENTED
+ */
+#if !defined(MCU_NORDIC_16K_S110) && !defined(MCU_NORDIC_32K_S110)
+
+ /**
* Launch service discovery. Once launched, service discovery will remain
* active with callbacks being issued back into the application for matching
* services/characteristics. isActive() can be used to determine status; and
@@ -152,6 +158,8 @@
private:
nRF5xServiceDiscovery discovery;
+
+#endif // if !S110
};
#endif // ifndef __NRF51822_GATT_CLIENT_H__
\ No newline at end of file
--- a/source/nRF5xGattServer.cpp Tue Aug 11 15:14:23 2015 +0100
+++ b/source/nRF5xGattServer.cpp Tue Aug 11 15:14:23 2015 +0100
@@ -375,23 +375,21 @@
switch (eventType) {
case GattServerEvents::GATT_EVENT_DATA_WRITTEN: {
GattWriteCallbackParams cbParams = {
- .connHandle = gattsEventP->conn_handle,
- .handle = handle_value,
- .writeOp = static_cast<GattWriteCallbackParams::WriteOp_t>(gattsEventP->params.write.op),
- .offset = gattsEventP->params.write.offset,
- .len = gattsEventP->params.write.len,
- .data = gattsEventP->params.write.data
+ .handle = handle_value,
+ .writeOp = static_cast<GattWriteCallbackParams::WriteOp_t>(gattsEventP->params.write.op),
+ .offset = gattsEventP->params.write.offset,
+ .len = gattsEventP->params.write.len,
+ .data = gattsEventP->params.write.data
};
handleDataWrittenEvent(&cbParams);
break;
}
case GattServerEvents::GATT_EVENT_WRITE_AUTHORIZATION_REQ: {
GattWriteAuthCallbackParams cbParams = {
- .connHandle = gattsEventP->conn_handle,
- .handle = handle_value,
- .offset = gattsEventP->params.authorize_request.request.write.offset,
- .len = gattsEventP->params.authorize_request.request.write.len,
- .data = gattsEventP->params.authorize_request.request.write.data,
+ .handle = handle_value,
+ .offset = gattsEventP->params.authorize_request.request.write.offset,
+ .len = gattsEventP->params.authorize_request.request.write.len,
+ .data = gattsEventP->params.authorize_request.request.write.data,
};
ble_gatts_rw_authorize_reply_params_t reply = {
.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE,
@@ -412,12 +410,11 @@
*/
if (reply.params.write.gatt_status == BLE_GATT_STATUS_SUCCESS) {
GattWriteCallbackParams cbParams = {
- .connHandle = gattsEventP->conn_handle,
- .handle = handle_value,
- .writeOp = static_cast<GattWriteCallbackParams::WriteOp_t>(gattsEventP->params.authorize_request.request.write.op),
- .offset = gattsEventP->params.authorize_request.request.write.offset,
- .len = gattsEventP->params.authorize_request.request.write.len,
- .data = gattsEventP->params.authorize_request.request.write.data,
+ .handle = handle_value,
+ .writeOp = static_cast<GattWriteCallbackParams::WriteOp_t>(gattsEventP->params.authorize_request.request.write.op),
+ .offset = gattsEventP->params.authorize_request.request.write.offset,
+ .len = gattsEventP->params.authorize_request.request.write.len,
+ .data = gattsEventP->params.authorize_request.request.write.data,
};
handleDataWrittenEvent(&cbParams);
}
@@ -425,11 +422,10 @@
}
case GattServerEvents::GATT_EVENT_READ_AUTHORIZATION_REQ: {
GattReadAuthCallbackParams cbParams = {
- .connHandle = gattsEventP->conn_handle,
- .handle = handle_value,
- .offset = gattsEventP->params.authorize_request.request.read.offset,
- .len = 0,
- .data = NULL
+ .handle = handle_value,
+ .offset = gattsEventP->params.authorize_request.request.read.offset,
+ .len = 0,
+ .data = NULL
};
ble_gatts_rw_authorize_reply_params_t reply = {
