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 86:561631ee642d, committed 2015-01-21
- Comitter:
- rgrover1
- Date:
- Wed Jan 21 10:01:16 2015 +0000
- Parent:
- 85:17fe69405098
- Child:
- 87:f9516241903b
- Commit message:
- Synchronized with git rev e6d37364
Author: Marcus Chang
Added optional data and length fields to the return struct for authorized reads so a new value can be provided for each individual authorization.
Changed in this revision
| nRF51GattServer.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/nRF51GattServer.cpp Fri Dec 12 17:12:35 2014 +0000
+++ b/nRF51GattServer.cpp Wed Jan 21 10:01:16 2015 +0000
@@ -333,16 +333,32 @@
GattCharacteristicReadAuthCBParams cbParams = {
.charHandle = i,
.offset = gattsEventP->params.authorize_request.request.read.offset,
+ .len = 0,
+ .data = NULL
};
+
+ /* Ask for authorization and, potentially, new data.
+ Use updated parameters to construct reply.
+ */
+ p_characteristics[i]->authorizeRead(&cbParams);
+
ble_gatts_rw_authorize_reply_params_t reply = {
- .type = BLE_GATTS_AUTHORIZE_TYPE_READ,
- .params = {
- .read = {
- .gatt_status = (p_characteristics[i]->authorizeRead(&cbParams) ?
- BLE_GATT_STATUS_SUCCESS : BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED)
- }
+ .type = BLE_GATTS_AUTHORIZE_TYPE_READ
+ };
+
+ if (cbParams.authorizationReply == true) {
+ reply.params.read.gatt_status = BLE_GATT_STATUS_SUCCESS;
+
+ if (cbParams.data != NULL) {
+ reply.params.read.update = 1;
+ reply.params.read.offset = cbParams.offset;
+ reply.params.read.len = cbParams.len;
+ reply.params.read.p_data = cbParams.data;
}
- };
+ } else {
+ reply.params.read.gatt_status = BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED;
+ }
+
sd_ble_gatts_rw_authorize_reply(gattsEventP->conn_handle, &reply);
break;
}
