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 BLE_API by
Revision 92:3781dc6f8c18, committed 2014-06-11
- Comitter:
- Rohit Grover
- Date:
- Wed Jun 11 14:42:08 2014 +0100
- Parent:
- 91:311bde45b251
- Child:
- 93:f97a35cc40f8
- Commit message:
- GattService constructor now takes a statically initialized array of pointers to Characteristics
Changed in this revision
| GattService.cpp | Show annotated file Show diff for this revision Revisions of this file |
| GattService.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/GattService.cpp Wed Jun 11 14:14:04 2014 +0100
+++ b/GattService.cpp Wed Jun 11 14:42:08 2014 +0100
@@ -36,52 +36,8 @@
@endcode
*/
/**************************************************************************/
-GattService::GattService(const UUID &uuid) : primaryServiceID(uuid), characteristicCount(0), characteristics(), handle(0)
+GattService::GattService(const UUID &uuid, GattCharacteristic *characteristics[], unsigned numCharacteristics) :
+ _primaryServiceID(uuid), _characteristicCount(numCharacteristics), _characteristics(characteristics), _handle(0)
{
/* empty */
}
-
-/**************************************************************************/
-/*!
- @brief Destructor
-*/
-/**************************************************************************/
-GattService::~GattService(void)
-{
-}
-
-/**************************************************************************/
-/*!
- @brief Adds a GattCharacterisic to the service.
-
- @note This function will not update the .handle field in the
- GattCharacteristic. This value is updated when the parent
- service is added via the radio driver.
-
- @param[in] characteristic
- The GattCharacteristic object describing the characteristic
- to add to this service
-
- @returns BLE_ERROR_NONE (0) if everything executed correctly, or an
- error code if there was a problem
- @retval BLE_ERROR_NONE
- Everything executed correctly
-
- @section EXAMPLE
-
- @code
-
- @endcode
-*/
-/**************************************************************************/
-ble_error_t GattService::addCharacteristic(GattCharacteristic & characteristic)
-{
- /* ToDo: Make sure we don't overflow the array, etc. */
- /* ToDo: Make sure this characteristic UUID doesn't already exist */
- /* ToDo: Basic validation */
-
- characteristics[characteristicCount] = &characteristic;
- characteristicCount++;
-
- return BLE_ERROR_NONE;
-}
--- a/GattService.h Wed Jun 11 14:14:04 2014 +0100
+++ b/GattService.h Wed Jun 11 14:42:08 2014 +0100
@@ -22,7 +22,6 @@
#include "UUID.h"
#include "GattCharacteristic.h"
-#define BLE_SERVICE_MAX_CHARACTERISTICS (5)
/**************************************************************************/
/*!
@@ -31,13 +30,8 @@
/**************************************************************************/
class GattService
{
-private:
-
public:
- GattService(const UUID &uuid);
- virtual ~GattService(void);
-
- ble_error_t addCharacteristic(GattCharacteristic &);
+ GattService(const UUID &uuid, GattCharacteristic *characteristics[], unsigned numCharacteristics);
enum {
UUID_ALERT_NOTIFICATION_SERVICE = 0x1811,
@@ -61,30 +55,30 @@
};
const UUID &getUUID(void) const {
- return primaryServiceID;
- }
- uint16_t *getHandlePtr(void) {
- return &handle;
+ return _primaryServiceID;
}
uint16_t getHandle(void) const {
- return handle;
+ return _handle;
+ }
+ void setHandle(uint16_t handle) {
+ _handle = handle;
}
uint8_t getCharacteristicCount(void) const {
- return characteristicCount;
+ return _characteristicCount;
}
GattCharacteristic *getCharacteristic(uint8_t index) {
- if (index >= characteristicCount) {
+ if (index >= _characteristicCount) {
return NULL;
}
- return characteristics[index];
+ return _characteristics[index];
}
private:
- UUID primaryServiceID;
- uint8_t characteristicCount;
- GattCharacteristic *characteristics[BLE_SERVICE_MAX_CHARACTERISTICS];
- uint16_t handle;
+ UUID _primaryServiceID;
+ uint8_t _characteristicCount;
+ GattCharacteristic **_characteristics;
+ uint16_t _handle;
};
#endif // ifndef __GATT_SERVICE_H__
