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 0fa1d0e1a81856d23c339ec37e65e90bf694c808
Author: Andrzej Kaczmarek <andrzej.kaczma...@codecoup.pl>
AuthorDate: Fri Feb 23 21:40:44 2018 +0100

    nimble/gap: Make PPCP configurable
    
    Allow to configure value of "Peripherap Preferred Connection Parameters"
    characteristic. Since this characteristic is optional and right now we
    do not set any meaningful value there, we simply disable it by default.
    
    X-Original-Commit: ce7276d7ea9e46e2912980d010b98ef5beadc6ee
---
 nimble/host/services/gap/src/ble_svc_gap.c | 23 ++++++++++++++++++-----
 nimble/host/services/gap/syscfg.yml        | 24 ++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/nimble/host/services/gap/src/ble_svc_gap.c 
b/nimble/host/services/gap/src/ble_svc_gap.c
index a52b3be..2445b9a 100644
--- a/nimble/host/services/gap/src/ble_svc_gap.c
+++ b/nimble/host/services/gap/src/ble_svc_gap.c
@@ -25,6 +25,13 @@
 #include "services/gap/ble_svc_gap.h"
 #include "os/endian.h"
 
+#define PPCP_ENABLED \
+    MYNEWT_VAL(BLE_ROLE_PERIPHERAL) && \
+    (MYNEWT_VAL(BLE_SVC_GAP_PPCP_MIN_CONN_INTERVAL) || \
+     MYNEWT_VAL(BLE_SVC_GAP_PPCP_MAX_CONN_INTERVAL) || \
+     MYNEWT_VAL(BLE_SVC_GAP_PPCP_SLAVE_LATENCY) || \
+     MYNEWT_VAL(BLE_SVC_GAP_PPCP_SUPERVISION_TMO))
+
 /* XXX: This should be configurable. */
 #define BLE_SVC_GAP_NAME_MAX_LEN    31
 
@@ -32,7 +39,6 @@ static char ble_svc_gap_name[BLE_SVC_GAP_NAME_MAX_LEN + 1] =
         MYNEWT_VAL(BLE_SVC_GAP_DEVICE_NAME);
 static const uint16_t ble_svc_gap_appearance =
         MYNEWT_VAL(BLE_SVC_GAP_APPEARANCE);
-static uint8_t ble_svc_gap_pref_conn_params[8];
 
 static int
 ble_svc_gap_access(uint16_t conn_handle, uint16_t attr_handle,
@@ -54,7 +60,7 @@ 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_ROLE_PERIPHERAL)
+#if PPCP_ENABLED
             /*** Characteristic: Peripheral Preferred Connection Parameters. */
             .uuid =
                 
BLE_UUID16_DECLARE(BLE_SVC_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS),
@@ -87,6 +93,14 @@ ble_svc_gap_access(uint16_t conn_handle, uint16_t 
attr_handle,
 #if MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION) >= 0
     uint8_t central_ar = MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION);
 #endif
+#if PPCP_ENABLED
+    uint16_t ppcp[4] = {
+        htole16(MYNEWT_VAL(BLE_SVC_GAP_PPCP_MIN_CONN_INTERVAL)),
+        htole16(MYNEWT_VAL(BLE_SVC_GAP_PPCP_MAX_CONN_INTERVAL)),
+        htole16(MYNEWT_VAL(BLE_SVC_GAP_PPCP_SLAVE_LATENCY)),
+        htole16(MYNEWT_VAL(BLE_SVC_GAP_PPCP_SUPERVISION_TMO))
+    };
+#endif
     int rc;
 
     uuid16 = ble_uuid_u16(ctxt->chr->uuid);
@@ -104,11 +118,10 @@ ble_svc_gap_access(uint16_t conn_handle, uint16_t 
attr_handle,
         rc = os_mbuf_append(ctxt->om, &appearance, sizeof(appearance));
         return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
 
-#if MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
+#if PPCP_ENABLED
     case BLE_SVC_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS:
         assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
-        rc = os_mbuf_append(ctxt->om, &ble_svc_gap_pref_conn_params,
-                            sizeof ble_svc_gap_pref_conn_params);
+        rc = os_mbuf_append(ctxt->om, &ppcp, sizeof(ppcp));
         return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
 #endif
 
diff --git a/nimble/host/services/gap/syscfg.yml 
b/nimble/host/services/gap/syscfg.yml
index 0e327fd..25597e9 100644
--- a/nimble/host/services/gap/syscfg.yml
+++ b/nimble/host/services/gap/syscfg.yml
@@ -27,6 +27,30 @@ syscfg.defs:
     BLE_SVC_GAP_APPEARANCE:
         description: 'Device appearance'
         value: 0
+
+    # Setting all values for PPCP to '0' will disable characteristic!
+    BLE_SVC_GAP_PPCP_MIN_CONN_INTERVAL:
+        description: >
+            Value of "minimum connection interval" of PPCP characteristic as
+            defined by Core specification 5.0, Vol 3, Part C, section 12.3.
+        value: 0
+    BLE_SVC_GAP_PPCP_MAX_CONN_INTERVAL:
+        description: >
+            Value of "maximum connection interval" of PPCP characteristic as
+            defined by Core specification 5.0, Vol 3, Part C, section 12.3.
+        value: 0
+    BLE_SVC_GAP_PPCP_SLAVE_LATENCY:
+        description: >
+            Value of "slave latency" of PPCP characteristic as  defined by Core
+            specification 5.0, Vol 3, Part C, section 12.3.
+        value: 0
+    BLE_SVC_GAP_PPCP_SUPERVISION_TMO:
+        description: >
+            Value of "connection supervision timeout multiplier" of PPCP
+            characteristic as defined by Core specification 5.0, Vol 3, Part C,
+            section 12.3.
+        value: 0
+
     BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION:
         description: >
             Value of "Central Address Resolution" characteristics, as defined

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

Reply via email to