Compatible with Keewi v1

Fork of BLE_API by Bluetooth Low Energy

Files at this revision

API Documentation at this revision

Comitter:
Rohit Grover
Date:
Thu Jun 05 08:48:51 2014 +0100
Parent:
66:14120914e08b
Child:
68:dcadab8a56dd
Commit message:
switch to using LongUUID_t and ShortUUID_t

Changed in this revision

GattCharacteristic.cpp Show annotated file Show diff for this revision Revisions of this file
GattCharacteristic.h Show annotated file Show diff for this revision Revisions of this file
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
UUID.cpp Show annotated file Show diff for this revision Revisions of this file
UUID.h Show annotated file Show diff for this revision Revisions of this file
--- a/GattCharacteristic.cpp	Thu Jun 05 08:22:59 2014 +0100
+++ b/GattCharacteristic.cpp	Thu Jun 05 08:48:51 2014 +0100
@@ -58,10 +58,11 @@
 {
     /* empty */
 }
-GattCharacteristic::GattCharacteristic(const uint8_t longUUID[UUID::LENGTH_OF_LONG_UUID],
-                                       uint16_t      minLen,
-                                       uint16_t      maxLen,
-                                       uint8_t       props) :
+
+GattCharacteristic::GattCharacteristic(const LongUUID_t longUUID,
+                                       uint16_t         minLen,
+                                       uint16_t         maxLen,
+                                       uint8_t          props) :
     uuid(longUUID),
     lenMin(minLen),
     lenMax(maxLen),
--- a/GattCharacteristic.h	Thu Jun 05 08:22:59 2014 +0100
+++ b/GattCharacteristic.h	Thu Jun 05 08:48:51 2014 +0100
@@ -342,11 +342,11 @@
                                      *BLE_GATT_CPF_NAMESPACES. */
     } presentation_format_t;
 
-    GattCharacteristic(uint16_t uuid = 0,
+    GattCharacteristic(ShortUUID_t uuid = 0,
                        uint16_t minLen = 1,
                        uint16_t maxLen = 1,
                        uint8_t  properties = 0);
-    GattCharacteristic(const uint8_t longUUID[UUID::LENGTH_OF_LONG_UUID],
+    GattCharacteristic(const LongUUID_t longUUID,
                        uint16_t minLen = 1,
                        uint16_t maxLen = 1,
                        uint8_t  properties = 0);
--- a/GattService.cpp	Thu Jun 05 08:22:59 2014 +0100
+++ b/GattService.cpp	Thu Jun 05 08:48:51 2014 +0100
@@ -36,7 +36,7 @@
     @endcode
 */
 /**************************************************************************/
-GattService::GattService(const uint8_t base_uuid[16]) :
+GattService::GattService(const LongUUID_t base_uuid) :
     primaryServiceID(base_uuid),
     characteristicCount(0),
     characteristics(),
--- a/GattService.h	Thu Jun 05 08:22:59 2014 +0100
+++ b/GattService.h	Thu Jun 05 08:48:51 2014 +0100
@@ -34,8 +34,8 @@
 private:
 
 public:
-    GattService(const uint8_t[UUID::LENGTH_OF_LONG_UUID]);
-    GattService(uint16_t);          /* 16-bit BLE UUID */
+    GattService(const LongUUID_t);
+    GattService(ShortUUID_t);          /* 16-bit BLE UUID */
     virtual ~GattService(void);
 
     UUID                primaryServiceID;
--- a/UUID.cpp	Thu Jun 05 08:22:59 2014 +0100
+++ b/UUID.cpp	Thu Jun 05 08:48:51 2014 +0100
@@ -64,10 +64,10 @@
     @endcode
 */
 /**************************************************************************/
-UUID::UUID(const uint8_t longUUID[LENGTH_OF_LONG_UUID]) :
-                                        type(UUID_TYPE_SHORT),
-                                        baseUUID(),
-                                        shortUUID(0)
+UUID::UUID(const LongUUID_t longUUID) :
+    type(UUID_TYPE_SHORT),
+    baseUUID(),
+    shortUUID(0)
 {
     memcpy(baseUUID, longUUID, LENGTH_OF_LONG_UUID);
     shortUUID = (uint16_t)((longUUID[2] << 8) | (longUUID[3]));
--- a/UUID.h	Thu Jun 05 08:22:59 2014 +0100
+++ b/UUID.h	Thu Jun 05 08:48:51 2014 +0100
@@ -20,6 +20,10 @@
 
 #include "blecommon.h"
 
+const unsigned LENGTH_OF_LONG_UUID = 16;
+typedef uint16_t ShortUUID_t;
+typedef uint8_t  LongUUID_t[LENGTH_OF_LONG_UUID];
+
 class UUID
 {
 public:
@@ -28,11 +32,9 @@
         UUID_TYPE_LONG  = 1     // Full 128-bit UUID
     };
 
-    static const unsigned LENGTH_OF_LONG_UUID = 16;
-
 public:
-    UUID(const uint8_t longUUID[LENGTH_OF_LONG_UUID]);
-    UUID(uint16_t      uuid);
+    UUID(const LongUUID_t);
+    UUID(ShortUUID_t);
     virtual ~UUID(void);
 
 public:
@@ -42,18 +44,18 @@
     const uint8_t* getBaseUUID(void) const {
         return baseUUID;
     }
-    uint16_t get16BitUUID(void) const {
+    ShortUUID_t getShortUUID(void) const {
         return shortUUID;
     }
 
 private:
-    uint8_t  type;         // UUID_TYPE_SHORT or UUID_TYPE_LONG
-    uint8_t  baseUUID[LENGTH_OF_LONG_UUID]; /* the base of the long UUID (if
+    uint8_t     type;      // UUID_TYPE_SHORT or UUID_TYPE_LONG
+    LongUUID_t  baseUUID;  /* the base of the long UUID (if
                             * used). Note: bytes 12 and 13 (counting from LSB)
                             * are zeroed out to allow comparison with other long
                             * UUIDs which differ only in the 16-bit relative
                             * part.*/
-    uint16_t shortUUID;     // 16 bit uuid (byte 2-3 using with base)
+    ShortUUID_t shortUUID; // 16 bit uuid (byte 2-3 using with base)
 };
 
 #endif // ifndef __UUID_H__