Nordic stack and drivers for the mbed BLE API
Fork of nRF51822 by
Diff: btle/custom/custom_helper.cpp
- Revision:
- 18:465e0419c178
- Parent:
- 15:11b0c15979d1
- Child:
- 19:c5b5cb65cc6f
--- a/btle/custom/custom_helper.cpp Wed Jun 04 09:19:57 2014 +0100 +++ b/btle/custom/custom_helper.cpp Thu Jun 05 08:50:55 2014 +0100 @@ -23,7 +23,7 @@ * structures involved in maintaining a local cache of 128-bit UUIDs. */ typedef struct { - uint8_t uuid[UUID::LENGTH_OF_LONG_UUID]; + LongUUID_t uuid; uint8_t type; } converted_uuid_table_entry_t; static const unsigned UUID_TABLE_MAX_ENTRIES = 8; /* This is the maximum number @@ -40,14 +40,14 @@ * @return true if a match is found. */ static bool -lookupConvertedUUIDTable(const uint8_t uuid[UUID::LENGTH_OF_LONG_UUID], - uint8_t *recoveredType) +lookupConvertedUUIDTable(const LongUUID_t uuid, + uint8_t *recoveredType) { unsigned i; for (i = 0; i < uuidTableEntries; i++) { if (memcmp(convertedUUIDTable[i].uuid, uuid, - UUID::LENGTH_OF_LONG_UUID) == 0) { + LENGTH_OF_LONG_UUID) == 0) { *recoveredType = convertedUUIDTable[i].type; return true; } @@ -57,17 +57,14 @@ } static void -addToConvertedUUIDTable(const uint8_t uuid[UUID::LENGTH_OF_LONG_UUID], - uint8_t type) +addToConvertedUUIDTable(const LongUUID_t uuid, uint8_t type) { if (uuidTableEntries == UUID_TABLE_MAX_ENTRIES) { return; /* recovery needed; or at least the user should be * warned about this fact.*/ } - memcpy(convertedUUIDTable[uuidTableEntries].uuid, - uuid, - UUID::LENGTH_OF_LONG_UUID); + memcpy(convertedUUIDTable[uuidTableEntries].uuid, uuid,LENGTH_OF_LONG_UUID); convertedUUIDTable[uuidTableEntries].type = type; uuidTableEntries++; } @@ -88,7 +85,7 @@ ble_uuid_t custom_convert_to_nordic_uuid(const UUID &uuid) { ble_uuid_t nordicUUID = { - .uuid = uuid.get16BitUUID(), + .uuid = uuid.getShortUUID(), .type = BLE_UUID_TYPE_UNKNOWN /* to be set below */ }; @@ -161,7 +158,7 @@ error_t custom_decode_uuid_base(uint8_t const *const p_uuid_base, ble_uuid_t *p_uuid) { - uint8_t uuid_base_le[16]; + LongUUID_t uuid_base_le; /* Reverse the bytes since ble_uuid128_t is LSB */ for (uint8_t i = 0; i<16; i++) {