remove need for UUID::update()

master
Rohit Grover 2014-05-29 08:16:31 +01:00
parent e1ae67ab8c
commit 76ac2a5291
3 changed files with 11 additions and 78 deletions

View File

@ -36,11 +36,13 @@
@endcode
*/
/**************************************************************************/
GattService::GattService(uint8_t base_uuid[16])
GattService::GattService(uint8_t base_uuid[16]) :
primaryServiceID(base_uuid),
characteristicCount(0),
characteristics(),
handle(0)
{
primaryServiceID.update(base_uuid);
characteristicCount = 0;
handle = 0;
/* empty */
}
/**************************************************************************/
@ -58,11 +60,12 @@ GattService::GattService(uint8_t base_uuid[16])
@endcode
*/
/**************************************************************************/
GattService::GattService(uint16_t ble_uuid)
GattService::GattService(uint16_t ble_uuid) :
primaryServiceID(ble_uuid),
characteristicCount(0),
characteristics(),
handle(0)
{
primaryServiceID.update( ble_uuid );
characteristicCount = 0;
handle = 0;
}
/**************************************************************************/

View File

@ -121,70 +121,3 @@ UUID::UUID(const uint16_t ble_uuid) : type(UUID_TYPE_SHORT),
UUID::~UUID(void)
{
}
/**************************************************************************/
/*!
@brief Updates the value of the UUID
@args[in] uuid_base
The 128-bit value to use when updating the UUID. For
16-bit IDs, insert the ID in bytes 2/3 in LSB format.
@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 UUID::update(uint8_t const uuid_base[LENGTH_OF_LONG_UUID])
{
memcpy(base, uuid_base, LENGTH_OF_LONG_UUID);
value = (uint16_t)((uuid_base[3] << 8) | (uuid_base[2]));
/* Check if this is a short of a long UUID */
if (uuid_base[0] + uuid_base[1] +
uuid_base[4] + uuid_base[5] + uuid_base[6] + uuid_base[7] +
uuid_base[8] + uuid_base[9] + uuid_base[10] + uuid_base[11] +
uuid_base[12] + uuid_base[13] + uuid_base[14] + uuid_base[15] == 0) {
type = UUID_TYPE_SHORT;
} else {
type = UUID_TYPE_LONG;
}
return BLE_ERROR_NONE;
}
/**************************************************************************/
/*!
@brief Updates the value of the UUID
@args[in] ble_uuid
The 16-bit value to use when updating the UUID.
@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 UUID::update(uint16_t const ble_uuid)
{
memset(base, 0, LENGTH_OF_LONG_UUID);
memcpy(base + 2, (uint8_t *)&ble_uuid, 2);
value = ble_uuid;
type = UUID_TYPE_SHORT;
return BLE_ERROR_NONE;
}

3
UUID.h
View File

@ -36,9 +36,6 @@ public:
UUID(uint16_t const);
virtual ~UUID(void);
ble_error_t update(uint8_t const[LENGTH_OF_LONG_UUID]);
ble_error_t update(uint16_t const);
public:
uint8_t type; // UUID_TYPE_SHORT or UUID_TYPE_LONG
uint8_t base[LENGTH_OF_LONG_UUID]; // in case of custom