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 nRF51822 by
Revision 8:2214f1df6a6a, committed 2014-05-28
- Comitter:
- Rohit Grover
- Date:
- Wed May 28 17:27:23 2014 +0100
- Parent:
- 7:dd6465921aaa
- Child:
- 9:3794dc9540f0
- Commit message:
- convert_to_transport_uuid() now works with 128bit uuids
Changed in this revision
--- a/btle/custom/custom_helper.cpp Wed May 28 16:45:23 2014 +0100
+++ b/btle/custom/custom_helper.cpp Wed May 28 17:27:23 2014 +0100
@@ -16,6 +16,35 @@
#include "custom_helper.h"
+/**
+ * The nRF transport has its own 3-byte representation of a UUID. If the user-
+ * specified UUID is 128-bits wide, then the UUID base needs to be added to the
+ * soft-device and converted to a 3-byte handle before being used further. This
+ * function is responsible for this translation of user-specified UUIDs into
+ * nRF's representation.
+ *
+ * @param[in] uuid
+ * user-specified UUID
+ * @return nRF
+ * 3-byte UUID (containing a type and 16-bit UUID) representation
+ * to be used with SVC calls.
+ */
+ble_uuid_t custom_convert_to_transport_uuid(const UUID &uuid)
+{
+ ble_uuid_t transportUUID = {
+ .uuid = uuid.value,
+ .type = BLE_UUID_TYPE_UNKNOWN /* to be set below */
+ };
+
+ if (uuid.type == UUID::UUID_TYPE_SHORT) {
+ transportUUID.type = BLE_UUID_TYPE_BLE;
+ } else {
+ transportUUID.type = custom_add_uuid_base(uuid.base);
+ }
+
+ return transportUUID;
+}
+
/**************************************************************************/
/*!
@brief Adds the base UUID to the custom service. All UUIDs used
--- a/btle/custom/custom_helper.h Wed May 28 16:45:23 2014 +0100
+++ b/btle/custom/custom_helper.h Wed May 28 17:27:23 2014 +0100
@@ -23,10 +23,12 @@
#include "common/common.h"
#include "ble.h"
+#include "UUID.h"
uint8_t custom_add_uuid_base(uint8_t const *const p_uuid_base);
error_t custom_decode_uuid(uint8_t const *const p_uuid_base,
ble_uuid_t *p_uuid);
+ble_uuid_t custom_convert_to_transport_uuid(const UUID &uuid);
error_t custom_add_in_characteristic(uint16_t service_handle,
ble_uuid_t *p_uuid,
--- a/nRF51GattServer.cpp Wed May 28 16:45:23 2014 +0100
+++ b/nRF51GattServer.cpp Wed May 28 17:27:23 2014 +0100
@@ -22,30 +22,6 @@
#include "nRF51Gap.h"
-/**
- * The nRF transport has its own 3-byte representation of a UUID. If the user-
- * specified UUID is 128-bits wide, then the UUID base needs to be added to the
- * soft-device and converted to a 3-byte handle before being used further. This
- * function is responsible for this translation of user-specified UUIDs into
- * nRF's representation.
- *
- * @param[in] uuid
- * user-specified UUID
- * @return nRF
- * 3-byte UUID (containing a type and 16-bit UUID) representation
- * to be used with SVC calls.
- */
-static ble_uuid_t
-custom_convert_to_transport_uuid(const uint16_t uuid)
-{
- ble_uuid_t transportUUID = { /* presently we only deal with 16-bit uuids. */
- .type = BLE_UUID_TYPE_BLE,
- .uuid = uuid
- };
-
- return transportUUID;
-}
-
/**************************************************************************/
/*!
@brief Adds a new service to the GATT table on the peripheral
@@ -93,7 +69,6 @@
uuid = custom_convert_to_transport_uuid(p_char->uuid);
- uuid.uuid = p_char->uuid;
ASSERT ( ERROR_NONE ==
custom_add_in_characteristic(service.handle,
&uuid,
