config changes

Fork of nRF51822 by Nordic Semiconductor

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Tue Aug 11 15:14:23 2015 +0100
Parent:
414:d92da8b4c30c
Child:
416:5b7d26035f2b
Commit message:
Synchronized with git rev 73147b41
Author: Jean-Philippe Brucker
Fill connection handle in Gatt callbacks parameters

Changed in this revision

module.json Show annotated file Show diff for this revision Revisions of this file
source/btle/btle_discovery.cpp Show annotated file Show diff for this revision Revisions of this file
source/nRF5xGap.cpp Show annotated file Show diff for this revision Revisions of this file
source/nRF5xGattClient.cpp Show annotated file Show diff for this revision Revisions of this file
source/nRF5xGattServer.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/module.json	Tue Aug 11 15:14:22 2015 +0100
+++ b/module.json	Tue Aug 11 15:14:23 2015 +0100
@@ -1,6 +1,6 @@
 {
   "name": "ble-nrf51822",
-  "version": "0.4.5",
+  "version": "0.4.4",
   "description": "Nordic stack and drivers for the mbed BLE API.",
   "keywords": [
     "Bluetooth",
@@ -19,7 +19,7 @@
     }
   ],
   "dependencies": {
-    "ble": "~0.4.5"
+    "ble": "~0.4.4"
   },
   "extraIncludes": [
     "source/btle",
--- a/source/btle/btle_discovery.cpp	Tue Aug 11 15:14:22 2015 +0100
+++ b/source/btle/btle_discovery.cpp	Tue Aug 11 15:14:23 2015 +0100
@@ -56,10 +56,11 @@
 
         case BLE_GATTC_EVT_READ_RSP: {
                 GattReadCallbackParams response = {
-                    .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,
+                    .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,
                 };
                 nRF5xGattClient::getInstance().processReadResponse(&response);
             }
@@ -67,11 +68,12 @@
 
         case BLE_GATTC_EVT_WRITE_RSP: {
                 GattWriteCallbackParams response = {
-                    .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,
+                    .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,
                 };
                 nRF5xGattClient::getInstance().processWriteResponse(&response);
             }
@@ -79,10 +81,11 @@
 
         case BLE_GATTC_EVT_HVX: {
                 GattHVXCallbackParams params;
-                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.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;
 
                 nRF5xGattClient::getInstance().processHVXEvent(&params);
             }
--- a/source/nRF5xGap.cpp	Tue Aug 11 15:14:22 2015 +0100
+++ b/source/nRF5xGap.cpp	Tue Aug 11 15:14:23 2015 +0100
@@ -143,13 +143,13 @@
     /* Check interval range */
     if (params.getAdvertisingType() == GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED) {
         /* Min delay is slightly longer for unconnectable devices */
-        if ((params.getIntervalInADVUnits() < GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MIN_NONCON) ||
-            (params.getIntervalInADVUnits() > GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MAX)) {
+        if ((params.getInterval() < GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MIN_NONCON) ||
+            (params.getInterval() > GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MAX)) {
             return BLE_ERROR_PARAM_OUT_OF_RANGE;
         }
     } else {
-        if ((params.getIntervalInADVUnits() < GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MIN) ||
-            (params.getIntervalInADVUnits() > GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MAX)) {
+        if ((params.getInterval() < GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MIN) ||
+            (params.getInterval() > GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MAX)) {
             return BLE_ERROR_PARAM_OUT_OF_RANGE;
         }
     }
@@ -171,10 +171,10 @@
     ble_gap_adv_params_t adv_para = {0};
 
     adv_para.type        = params.getAdvertisingType();
-    adv_para.p_peer_addr = NULL;                           // Undirected advertisement
+    adv_para.p_peer_addr = NULL;                         // Undirected advertisement
     adv_para.fp          = BLE_GAP_ADV_FP_ANY;
     adv_para.p_whitelist = NULL;
-    adv_para.interval    = params.getIntervalInADVUnits(); // advertising interval (in units of 0.625 ms)
+    adv_para.interval    = params.getInterval();         // advertising interval (in units of 0.625 ms)
     adv_para.timeout     = params.getTimeout();
 
     ASSERT(ERROR_NONE == sd_ble_gap_adv_start(&adv_para), BLE_ERROR_PARAM_OUT_OF_RANGE);
@@ -434,7 +434,7 @@
 
 ble_error_t nRF5xGap::getAppearance(GapAdvertisingData::Appearance *appearanceP)
 {
-    if ((sd_ble_gap_appearance_get(reinterpret_cast<uint16_t *>(appearanceP)) == NRF_SUCCESS)) {
+    if (sd_ble_gap_appearance_get(reinterpret_cast<uint16_t *>(appearanceP))) {
         return BLE_ERROR_NONE;
     } else {
         return BLE_ERROR_PARAM_OUT_OF_RANGE;
--- a/source/nRF5xGattClient.cpp	Tue Aug 11 15:14:22 2015 +0100
+++ b/source/nRF5xGattClient.cpp	Tue Aug 11 15:14:23 2015 +0100
@@ -16,9 +16,10 @@
 
 #include "nRF5xGattClient.h"
 
+nRF5xGattClient nRFGattClientSingleton;
+
 nRF5xGattClient &
 nRF5xGattClient::getInstance(void) {
-    static nRF5xGattClient nRFGattClientSingleton;
     return nRFGattClientSingleton;
 }
 
--- a/source/nRF5xGattServer.cpp	Tue Aug 11 15:14:22 2015 +0100
+++ b/source/nRF5xGattServer.cpp	Tue Aug 11 15:14:23 2015 +0100
@@ -375,21 +375,23 @@
     switch (eventType) {
         case GattServerEvents::GATT_EVENT_DATA_WRITTEN: {
             GattWriteCallbackParams cbParams = {
-                .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
+                .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
             };
             handleDataWrittenEvent(&cbParams);
             break;
         }
         case GattServerEvents::GATT_EVENT_WRITE_AUTHORIZATION_REQ: {
             GattWriteAuthCallbackParams cbParams = {
-                .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,
+                .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,
             };
             ble_gatts_rw_authorize_reply_params_t reply = {
                 .type = BLE_GATTS_AUTHORIZE_TYPE_WRITE,
@@ -410,11 +412,12 @@
              */
             if (reply.params.write.gatt_status == BLE_GATT_STATUS_SUCCESS) {
                 GattWriteCallbackParams cbParams = {
-                    .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,
+                    .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,
                 };
                 handleDataWrittenEvent(&cbParams);
             }
@@ -422,10 +425,11 @@
         }
         case GattServerEvents::GATT_EVENT_READ_AUTHORIZATION_REQ: {
             GattReadAuthCallbackParams cbParams = {
-                .handle = handle_value,
-                .offset = gattsEventP->params.authorize_request.request.read.offset,
-                .len    = 0,
-                .data   = NULL
+                .connHandle = gattsEventP->conn_handle,
+                .handle     = handle_value,
+                .offset     = gattsEventP->params.authorize_request.request.read.offset,
+                .len        = 0,
+                .data       = NULL
             };
 
             ble_gatts_rw_authorize_reply_params_t reply = {