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.
Dependents: microbit_rubber_ducky microbit_mouse_BLE microbit_mouse_BLE_daybreak_version microbit_presenter
Fork of nRF51822 by
Diff: nRF51GattServer.h
- Revision:
- 370:295f76db798e
- Parent:
- 369:7455428e5ddb
- Child:
- 371:8f7d2137727a
--- a/nRF51GattServer.h Thu Jul 02 09:08:45 2015 +0100
+++ b/nRF51GattServer.h Mon Jul 06 10:13:26 2015 +0100
@@ -19,10 +19,10 @@
#include <stddef.h>
-#include "ble/blecommon.h"
+#include "blecommon.h"
#include "ble.h" /* nordic ble */
-#include "ble/Gap.h"
-#include "ble/GattServer.h"
+#include "Gap.h"
+#include "GattServer.h"
class nRF51GattServer : public GattServer
{
@@ -31,12 +31,11 @@
/* Functions that must be implemented from GattServer */
virtual ble_error_t addService(GattService &);
- virtual ble_error_t read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
- virtual ble_error_t read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
- virtual ble_error_t write(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
- virtual ble_error_t write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
- virtual ble_error_t areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP);
- virtual ble_error_t areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP);
+ virtual ble_error_t readValue(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
+ virtual ble_error_t readValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
+ virtual ble_error_t updateValue(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
+ virtual ble_error_t updateValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
+ virtual ble_error_t initializeGATTDatabase(void);
/* nRF51 Functions */
void eventCallback(void);
@@ -46,40 +45,6 @@
const static unsigned BLE_TOTAL_CHARACTERISTICS = 20;
const static unsigned BLE_TOTAL_DESCRIPTORS = 8;
-private:
- /**
- * resolve a value attribute to its owning characteristic.
- * @param valueHandle the value handle to be resolved.
- * @return characteristic index if a resolution is found, else -1.
- */
- int resolveValueHandleToCharIndex(GattAttribute::Handle_t valueHandle) const {
- unsigned charIndex;
- for (charIndex = 0; charIndex < characteristicCount; charIndex++) {
- if (nrfCharacteristicHandles[charIndex].value_handle == valueHandle) {
- return charIndex;
- }
- }
-
- return -1;
- }
-
- /**
- * resolve a CCCD attribute handle to its owning characteristic.
- * @param cccdHandle the CCCD handle to be resolved.
- * @return characteristic index if a resolution is found, else -1.
- */
- int resolveCCCDHandleToCharIndex(GattAttribute::Handle_t cccdHandle) const {
- unsigned charIndex;
- for (charIndex = 0; charIndex < characteristicCount; charIndex++) {
- if (nrfCharacteristicHandles[charIndex].cccd_handle == cccdHandle) {
- return charIndex;
- }
- }
-
- return -1;
- }
-
-private:
GattCharacteristic *p_characteristics[BLE_TOTAL_CHARACTERISTICS];
ble_gatts_char_handles_t nrfCharacteristicHandles[BLE_TOTAL_CHARACTERISTICS];
GattAttribute *p_descriptors[BLE_TOTAL_DESCRIPTORS];
