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:
- 371:8f7d2137727a
- Parent:
- 370:295f76db798e
--- a/nRF51GattServer.cpp Mon Jul 06 10:13:26 2015 +0100 +++ b/nRF51GattServer.cpp Mon Jul 06 10:13:27 2015 +0100 @@ -159,12 +159,12 @@ Everything executed properly */ /**************************************************************************/ -ble_error_t nRF51GattServer::readValue(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) +ble_error_t nRF51GattServer::read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) { - return readValue(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, lengthP); + return read(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, lengthP); } -ble_error_t nRF51GattServer::readValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) +ble_error_t nRF51GattServer::read(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::updateValue(GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly) +ble_error_t nRF51GattServer::write(GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly) { - return updateValue(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, len, localOnly); + return write(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, len, localOnly); } -ble_error_t nRF51GattServer::updateValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly) +ble_error_t nRF51GattServer::write(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: { - 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 + 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 }; handleDataWrittenEvent(&cbParams); break; } case GattServerEvents::GATT_EVENT_WRITE_AUTHORIZATION_REQ: { - 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, + 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, }; 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) { - 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, + 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, }; handleDataWrittenEvent(&cbParams); } break; } case GattServerEvents::GATT_EVENT_READ_AUTHORIZATION_REQ: { - GattCharacteristicReadAuthCBParams cbParams = { - .charHandle = i, - .offset = gattsEventP->params.authorize_request.request.read.offset, - .len = 0, - .data = NULL + GattReadAuthCallbackParams cbParams = { + .handle = i, + .offset = gattsEventP->params.authorize_request.request.read.offset, + .len = 0, + .data = NULL }; ble_gatts_rw_authorize_reply_params_t reply = { @@ -418,11 +418,4 @@ } } } -} - -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