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 429:bff56e081b6e, committed 2015-09-25
- Comitter:
- rgrover1
- Date:
- Fri Sep 25 15:26:39 2015 +0100
- Parent:
- 428:ca9c9c2cfc6a
- Child:
- 430:db7edc9ad0bc
- Commit message:
- Synchronized with git rev 2294f555
Author: Rohit Grover
Release 0.4.5
=============
Enhancements
~~~~~~~~~~~~
* Renamed to GapAdvertisementParams::getIntervalInADVUnits() based on change in BLE API.
* Fix Gap::getAppearance() to checks for correct success code from sd_ble_gap_appearance_get().
Bugfixes
~~~~~~~~
none.
Changed in this revision
--- a/module.json Thu Aug 13 13:23:19 2015 +0100
+++ b/module.json Fri Sep 25 15:26:39 2015 +0100
@@ -1,6 +1,6 @@
{
"name": "ble-nrf51822",
- "version": "0.4.7",
+ "version": "0.4.5",
"description": "Nordic stack and drivers for the mbed BLE API.",
"keywords": [
"Bluetooth",
@@ -19,7 +19,7 @@
}
],
"dependencies": {
- "ble": "~0.4.7"
+ "ble": "~0.4.5"
},
"extraIncludes": [
"source/btle",
--- a/source/btle/btle.cpp Thu Aug 13 13:23:19 2015 +0100
+++ b/source/btle/btle.cpp Fri Sep 25 15:26:39 2015 +0100
@@ -50,39 +50,13 @@
pstorage_sys_event_handler(sys_evt);
}
-/**
- * This function is called in interrupt context to handle BLE events; i.e. pull
- * system and user events out of the pending events-queue of the BLE stack. The
- * BLE stack signals the availability of events by the triggering the SWI2
- * interrupt, which forwards the handling to this function.
- *
- * The event processing loop is implemented in intern_softdevice_events_execute().
- *
- * In mbed OS, a callback for intern_softdevice_events_execute() is posted
- * to the scheduler, which then executes in thread mode. In mbed-classic,
- * event processing happens right-away in interrupt context (which is more
- * risk-prone). In either case, the logic of event processing is identical.
- */
-static uint32_t eventHandler()
-{
-#ifdef YOTTA_CFG_MBED_OS
- minar::Scheduler::postCallback(intern_softdevice_events_execute);
-#else
- intern_softdevice_events_execute();
-#endif
-
- return NRF_SUCCESS;
-}
-
error_t btle_init(void)
{
- nrf_clock_lfclksrc_t clockSource;
if (NRF_CLOCK->LFCLKSRC & (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos)) {
- clockSource = NRF_CLOCK_LFCLKSRC_XTAL_20_PPM;
+ SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);
} else {
- clockSource = NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION;
+ SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, NULL);
}
- SOFTDEVICE_HANDLER_INIT(clockSource, eventHandler);
// Enable BLE stack
/**
@@ -133,9 +107,7 @@
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 Thu Aug 13 13:23:19 2015 +0100
+++ b/source/btle/btle_discovery.cpp Fri Sep 25 15:26:39 2015 +0100
@@ -17,7 +17,6 @@
#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;
@@ -57,11 +56,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);
}
@@ -69,12 +67,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);
}
@@ -82,11 +79,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);
}
@@ -96,4 +92,3 @@
sdSingleton.progressCharacteristicDiscovery();
sdSingleton.progressServiceDiscovery();
}
-#endif
--- a/source/nRF5xGap.h Thu Aug 13 13:23:19 2015 +0100
+++ b/source/nRF5xGap.h Fri Sep 25 15:26:39 2015 +0100
@@ -80,8 +80,6 @@
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). */
@@ -106,7 +104,6 @@
return BLE_STACK_BUSY;
}
-#endif
private:
/**
--- a/source/nRF5xGattClient.cpp Thu Aug 13 13:23:19 2015 +0100
+++ b/source/nRF5xGattClient.cpp Fri Sep 25 15:26:39 2015 +0100
@@ -16,13 +16,13 @@
#include "nRF5xGattClient.h"
+nRF5xGattClient nRFGattClientSingleton;
+
nRF5xGattClient &
nRF5xGattClient::getInstance(void) {
- static nRF5xGattClient nRFGattClientSingleton;
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,5 +31,4 @@
const UUID &matchingCharacteristicUUIDIn)
{
return discovery.launch(connectionHandle, sc, cc, matchingServiceUUIDIn, matchingCharacteristicUUIDIn);
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
--- a/source/nRF5xGattClient.h Thu Aug 13 13:23:19 2015 +0100
+++ b/source/nRF5xGattClient.h Fri Sep 25 15:26:39 2015 +0100
@@ -26,12 +26,6 @@
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
@@ -158,8 +152,6 @@
private:
nRF5xServiceDiscovery discovery;
-
-#endif // if !S110
};
#endif // ifndef __NRF51822_GATT_CLIENT_H__
\ No newline at end of file
--- a/source/nRF5xGattServer.cpp Thu Aug 13 13:23:19 2015 +0100
+++ b/source/nRF5xGattServer.cpp Fri Sep 25 15:26:39 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 = {
--- a/source/nordic-sdk/components/libraries/util/app_error.c Thu Aug 13 13:23:19 2015 +0100 +++ b/source/nordic-sdk/components/libraries/util/app_error.c Fri Sep 25 15:26:39 2015 +0100 @@ -44,6 +44,7 @@ #include "compiler_abstraction.h" #include "nordic_common.h" #ifdef DEBUG +#include "bsp.h" /* global error variables - in order to prevent removal by optimizers */ uint32_t m_error_code;
--- a/source/nordic-sdk/components/softdevice/common/softdevice_handler/softdevice_handler.h Thu Aug 13 13:23:19 2015 +0100
+++ b/source/nordic-sdk/components/softdevice/common/softdevice_handler/softdevice_handler.h Fri Sep 25 15:26:39 2015 +0100
@@ -89,7 +89,8 @@
* reinitialization).
*/
/*lint -emacro(506, SOFTDEVICE_HANDLER_INIT) */ /* Suppress "Constant value Boolean */
-#define SOFTDEVICE_HANDLER_INIT(CLOCK_SOURCE, EVT_HANDLER) \
+#define SOFTDEVICE_HANDLER_INIT(CLOCK_SOURCE, \
+ EVT_HANDLER) \
do \
{ \
static uint32_t BLE_EVT_BUFFER[CEIL_DIV(BLE_STACK_EVT_MSG_BUF_SIZE, sizeof(uint32_t))]; \
@@ -97,7 +98,7 @@
ERR_CODE = softdevice_handler_init((CLOCK_SOURCE), \
BLE_EVT_BUFFER, \
sizeof(BLE_EVT_BUFFER), \
- EVT_HANDLER); \
+ EVT_HANDLER); \
APP_ERROR_CHECK(ERR_CODE); \
} while (0)
@@ -116,7 +117,7 @@
* used, this buffer must be provided by the application. The
* buffer must be large enough to hold the biggest stack event the
* application is supposed to handle. The buffer must be aligned to
- * a 4 byte boundary. This parameter is unused if BLE stack support
+ * a 4 byte boundary. This parameter is unused if BLE stack support
* is not required.
* @param[in] ble_evt_buffer_size Size of SoftDevice BLE event buffer. This parameter is unused if
* BLE stack support is not required.
