テスト用

Fork of nRF51822 by Nordic Semiconductor

Revision:
7:dd6465921aaa
Parent:
6:bbb4357dc135
Child:
8:2214f1df6a6a
--- a/nRF51GattServer.cpp	Wed May 28 12:55:18 2014 +0100
+++ b/nRF51GattServer.cpp	Wed May 28 16:45:23 2014 +0100
@@ -22,6 +22,30 @@
 
 #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
@@ -67,6 +91,8 @@
     for (uint8_t i = 0; i < service.characteristicCount; i++) {
         GattCharacteristic *p_char = service.characteristics[i];
 
+        uuid = custom_convert_to_transport_uuid(p_char->uuid);
+
         uuid.uuid = p_char->uuid;
         ASSERT ( ERROR_NONE ==
                  custom_add_in_characteristic(service.handle,