switch to using LongUUID_t and ShortUUID_t
This commit is contained in:
parent
d5e2df438b
commit
e98f1e8b49
6 changed files with 24 additions and 21 deletions
|
@ -58,10 +58,11 @@ GattCharacteristic::GattCharacteristic(uint16_t id,
|
|||
{
|
||||
/* 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),
|
||||
|
|
|
@ -342,11 +342,11 @@ public:
|
|||
*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);
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -34,8 +34,8 @@ class GattService
|
|||
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;
|
||||
|
|
8
UUID.cpp
8
UUID.cpp
|
@ -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]));
|
||||
|
|
18
UUID.h
18
UUID.h
|
@ -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 @@ public:
|
|||
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 @@ public:
|
|||
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__
|
||||
|
|
Loading…
Reference in a new issue