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
Diff: nRF51GattServer.cpp
- Revision:
- 361:d2405f5a4853
- Parent:
- 359:64918eb1ead2
- Child:
- 362:6fa0d4d555f6
--- a/nRF51GattServer.cpp Fri Jun 19 15:55:37 2015 +0100 +++ b/nRF51GattServer.cpp Thu Jul 02 09:08:44 2015 +0100 @@ -159,12 +159,12 @@ Everything executed properly */ /**************************************************************************/ -ble_error_t nRF51GattServer::read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) +ble_error_t nRF51GattServer::readValue(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) { - return read(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, lengthP); + return readValue(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, lengthP); } -ble_error_t nRF51GattServer::read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) +ble_error_t nRF51GattServer::readValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) { ble_gatts_value_t value = { .len = *lengthP, @@ -199,12 +199,12 @@ Everything executed properly */ /**************************************************************************/ -ble_error_t nRF51GattServer::write(GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly) +ble_error_t nRF51GattServer::updateValue(GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly) { - return write(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, len, localOnly); + return updateValue(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, len, localOnly); } -ble_error_t nRF51GattServer::write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly) +ble_error_t nRF51GattServer::updateValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly) { uint16_t gapConnectionHandle = nRF51Gap::getInstance().getConnectionHandle(); ble_error_t returnValue = BLE_ERROR_NONE; @@ -336,22 +336,22 @@ if (nrfCharacteristicHandles[i].value_handle == handle_value) { switch (eventType) { case GattServerEvents::GATT_EVENT_DATA_WRITTEN: { - GattWriteCallbackParams cbParams = { - .handle = i, - .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 + GattCharacteristicWriteCBParams cbParams = { + .charHandle = i, + .op = static_cast<GattCharacteristicWriteCBParams::Type>(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 = i, - .offset = gattsEventP->params.authorize_request.request.write.offset, - .len = gattsEventP->params.authorize_request.request.write.len, - .data = gattsEventP->params.authorize_request.request.write.data, + GattCharacteristicWriteAuthCBParams cbParams = { + .charHandle = i, + .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, @@ -371,23 +371,23 @@ * have done if write-authorization had not been enabled. */ if (reply.params.write.gatt_status == BLE_GATT_STATUS_SUCCESS) { - GattWriteCallbackParams cbParams = { - .handle = i, - .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, + GattCharacteristicWriteCBParams cbParams = { + .charHandle = i, + .op = static_cast<GattCharacteristicWriteCBParams::Type>(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); } break; } case GattServerEvents::GATT_EVENT_READ_AUTHORIZATION_REQ: { - GattReadAuthCallbackParams cbParams = { - .handle = i, - .offset = gattsEventP->params.authorize_request.request.read.offset, - .len = 0, - .data = NULL + GattCharacteristicReadAuthCBParams cbParams = { + .charHandle = i, + .offset = gattsEventP->params.authorize_request.request.read.offset, + .len = 0, + .data = NULL }; ble_gatts_rw_authorize_reply_params_t reply = { @@ -418,4 +418,11 @@ } } } +} + +ble_error_t +nRF51GattServer::initializeGATTDatabase(void) +{ + /* Empty. Services are populated in the GattDatabase through addService(). */ + return BLE_ERROR_NONE; } \ No newline at end of file