Shuta Nakamae / nRF51822

Fork of nRF51822 by Nordic Semiconductor

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Mon Mar 02 11:34:45 2015 +0000
Parent:
96:f98c65780f4a
Child:
98:f96993b65e90
Commit message:
Synchronized with git rev c9d036fc
Author: Rohit Grover
Release 0.2.6
=============

Enhancements
~~~~~~~~~~~~
* Disregard bytes 2 and 3 when comparing long UUIDs. This is in response to a
user request to avoid zeroing out bytes 2 and 3 when storing long UUIDs
within the class UUID.

* Added optional data and length fields to the return struct for authorized
reads so a new value can be provided for each individual authorization. Pull
request from Marcus Chang.

* Updated return value for nRF51GattServer::updateValue. Will now report when
call fails. Pull request from Marcus Chang.

* Use GattAttribute::Handle_t for GattServer::readValue() and updateValue().

* add code to support getPermittedTxValues().

Bugfixes
~~~~~~~~

* Write permission was not set for 'write without response' characteristics.
Pull request from Marcus Chang.

* When the write-authorization attribute is enabled for a characteristic,
handleDataWritten() should still be called after authorization.

Compatibility
~~~~~~~~~~~~~

This release is backward compatible with 0.2.3.

Changed in this revision

btle/custom/custom_helper.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/btle/custom/custom_helper.cpp	Mon Mar 02 11:34:45 2015 +0000
+++ b/btle/custom/custom_helper.cpp	Mon Mar 02 11:34:45 2015 +0000
@@ -42,7 +42,20 @@
 {
     unsigned i;
     for (i = 0; i < uuidTableEntries; i++) {
-        if (memcmp(convertedUUIDTable[i].uuid, uuid, LENGTH_OF_LONG_UUID) == 0) {
+        unsigned byteIndex;
+        for (byteIndex = 0; byteIndex < LENGTH_OF_LONG_UUID; byteIndex++) {
+            /* Skip bytes 2 and 3, because they contain the shortUUID (16-bit) version of the
+             * long UUID; and we're comparing against the remainder. */
+            if ((byteIndex == 2) || (byteIndex == 3)) {
+                continue;
+            }
+
+            if (convertedUUIDTable[i].uuid[byteIndex] != uuid[byteIndex]) {
+                break;
+            }
+        }
+
+        if (byteIndex == LENGTH_OF_LONG_UUID) {
             *recoveredType = convertedUUIDTable[i].type;
             return true;
         }
@@ -58,8 +71,10 @@
         return; /* recovery needed; or at least the user should be warned about this fact.*/
     }
 
-    memcpy(convertedUUIDTable[uuidTableEntries].uuid, uuid,LENGTH_OF_LONG_UUID);
-    convertedUUIDTable[uuidTableEntries].type = type;
+    memcpy(convertedUUIDTable[uuidTableEntries].uuid, uuid, LENGTH_OF_LONG_UUID);
+    convertedUUIDTable[uuidTableEntries].uuid[2] = 0;
+    convertedUUIDTable[uuidTableEntries].uuid[3] = 0;
+    convertedUUIDTable[uuidTableEntries].type    = type;
     uuidTableEntries++;
 }
 
@@ -135,8 +150,8 @@
     uint8_t       uuid_type = 0;
 
     /* Reverse the bytes since ble_uuid128_t is LSB */
-    for (uint8_t i = 0; i<16; i++) {
-        base_uuid.uuid128[i] = p_uuid_base[15 - i];
+    for (unsigned i = 0; i < LENGTH_OF_LONG_UUID; i++) {
+        base_uuid.uuid128[i] = p_uuid_base[LENGTH_OF_LONG_UUID - 1 - i];
     }
 
     ASSERT_INT( ERROR_NONE, sd_ble_uuid_vs_add( &base_uuid, &uuid_type ), 0);
@@ -155,11 +170,11 @@
     LongUUIDBytes_t uuid_base_le;
 
     /* Reverse the bytes since ble_uuid128_t is LSB */
-    for (uint8_t i = 0; i<16; i++) {
-        uuid_base_le[i] = p_uuid_base[15 - i];
+    for (uint8_t i = 0; i < LENGTH_OF_LONG_UUID; i++) {
+        uuid_base_le[i] = p_uuid_base[LENGTH_OF_LONG_UUID - 1 - i];
     }
 
-    ASSERT_STATUS( sd_ble_uuid_decode(16, uuid_base_le, p_uuid));
+    ASSERT_STATUS( sd_ble_uuid_decode(LENGTH_OF_LONG_UUID, uuid_base_le, p_uuid));
 
     return ERROR_NONE;
 }