nochanges
Dependents: BLE_Acceleration_Statejudging
Fork of nRF51822 by
Diff: nRF51GattServer.cpp
- Revision:
- 86:561631ee642d
- Parent:
- 84:658e5ec772a1
- Child:
- 87:f9516241903b
diff -r 17fe69405098 -r 561631ee642d nRF51GattServer.cpp --- 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; }