This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch new-master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit e77d5460c6a9cd320b07a5cb3b74a817da68863d
Author: Andrzej Kaczmarek <andrzej.kaczma...@codecoup.pl>
AuthorDate: Fri Feb 23 21:11:20 2018 +0100

    nimble/gap: Add "Central Address Resolution" characteristic
    
    This characteristics is mandatory for LE Central role if LL Privacy is
    supported.
    
    We could be smarter in registering it by checking controller features,
    but this is quite complex to implement due to the way everything is set
    up so let's leave proper configuration for user :)
    
    X-Original-Commit: 4934ddf4afc889c0aaa932734d5bf361eb4dc042
---
 .../services/gap/include/services/gap/ble_svc_gap.h     |  1 +
 nimble/host/services/gap/src/ble_svc_gap.c              | 17 +++++++++++++++++
 nimble/host/services/gap/syscfg.yml                     |  6 ++++++
 3 files changed, 24 insertions(+)

diff --git a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h 
b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h
index b8dd196..f4bc213 100644
--- a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h
+++ b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h
@@ -28,6 +28,7 @@ extern "C" {
 #define BLE_SVC_GAP_CHR_UUID16_DEVICE_NAME                  0x2a00
 #define BLE_SVC_GAP_CHR_UUID16_APPEARANCE                   0x2a01
 #define BLE_SVC_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS      0x2a04
+#define BLE_SVC_GAP_CHR_UUID16_CENTRAL_ADDRESS_RESOLUTION   0x2aa6
 
 #define BLE_SVC_GAP_APPEARANCE_GEN_UNKNOWN                         0
 #define BLE_SVC_GAP_APPEARANCE_GEN_COMPUTER                        128
diff --git a/nimble/host/services/gap/src/ble_svc_gap.c 
b/nimble/host/services/gap/src/ble_svc_gap.c
index 995534e..cff7210 100644
--- a/nimble/host/services/gap/src/ble_svc_gap.c
+++ b/nimble/host/services/gap/src/ble_svc_gap.c
@@ -61,6 +61,13 @@ static const struct ble_gatt_svc_def ble_svc_gap_defs[] = {
             .access_cb = ble_svc_gap_access,
             .flags = BLE_GATT_CHR_F_READ,
         }, {
+#if MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION) >= 0
+            /*** Characteristic: Central Address Resolution. */
+            .uuid = 
BLE_UUID16_DECLARE(BLE_SVC_GAP_CHR_UUID16_CENTRAL_ADDRESS_RESOLUTION),
+            .access_cb = ble_svc_gap_access,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+#endif
             0, /* No more characteristics in this service. */
         } },
     },
@@ -75,6 +82,9 @@ ble_svc_gap_access(uint16_t conn_handle, uint16_t attr_handle,
                    struct ble_gatt_access_ctxt *ctxt, void *arg)
 {
     uint16_t uuid16;
+#if MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION) >= 0
+    uint8_t central_ar = MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION);
+#endif
     int rc;
 
     uuid16 = ble_uuid_u16(ctxt->chr->uuid);
@@ -99,6 +109,13 @@ ble_svc_gap_access(uint16_t conn_handle, uint16_t 
attr_handle,
                             sizeof ble_svc_gap_pref_conn_params);
         return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
 
+#if MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION) >= 0
+    case BLE_SVC_GAP_CHR_UUID16_CENTRAL_ADDRESS_RESOLUTION:
+        assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
+        rc = os_mbuf_append(ctxt->om, &central_ar, sizeof(central_ar));
+        return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
+#endif
+
     default:
         assert(0);
         return BLE_ATT_ERR_UNLIKELY;
diff --git a/nimble/host/services/gap/syscfg.yml 
b/nimble/host/services/gap/syscfg.yml
index f686e67..18bf82d 100644
--- a/nimble/host/services/gap/syscfg.yml
+++ b/nimble/host/services/gap/syscfg.yml
@@ -22,3 +22,9 @@ syscfg.defs:
     BLE_SVC_GAP_APPEARANCE:
         description: 'Device appearance'
         value: 0
+    BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION:
+        description: >
+            Value of "Central Address Resolution" characteristics, as defined
+            by Core specification 5.0, Vol 3, Part C, section 12.
+            Set to '-1' to disable.
+        value: -1

-- 
To stop receiving notification emails like this one, please contact
a...@apache.org.

Reply via email to