You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ry...@apache.org on 2020/04/17 12:58:13 UTC

[mynewt-nimble] branch master updated (bb0fcde -> 6661a51)

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

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


    from bb0fcde  nimble/socket: Enhance error log with hci dev num
     new 7260a4e  nimble/host: Fix return code in `ble_gap_unpair_oldest_peer` when no bonded peer exist
     new 6661a51  nimble/store: Fix store behavior when CCCDs exceed maximum limit

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/host/include/host/ble_gap.h | 14 ++++++++++++++
 nimble/host/src/ble_gap.c          | 32 +++++++++++++++++++++++++++++++-
 nimble/host/src/ble_store_util.c   | 16 +++++++++-------
 3 files changed, 54 insertions(+), 8 deletions(-)


[mynewt-nimble] 02/02: nimble/store: Fix store behavior when CCCDs exceed maximum limit

Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6661a5139ae3bce4b123b7089cf6f6d61ee6764d
Author: Prasad Alatkar <pr...@espressif.com>
AuthorDate: Wed Apr 1 00:08:29 2020 +0530

    nimble/store: Fix store behavior when CCCDs exceed maximum limit
    
    - Add supporting API to skip input peer while unpairing oldest peer
---
 nimble/host/include/host/ble_gap.h | 14 ++++++++++++++
 nimble/host/src/ble_gap.c          | 30 ++++++++++++++++++++++++++++++
 nimble/host/src/ble_store_util.c   | 16 +++++++++-------
 3 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h
index 20e7dab..b58f350 100644
--- a/nimble/host/include/host/ble_gap.h
+++ b/nimble/host/include/host/ble_gap.h
@@ -1896,6 +1896,20 @@ int ble_gap_unpair(const ble_addr_t *peer_addr);
  */
 int ble_gap_unpair_oldest_peer(void);
 
+/**
+ * Similar to `ble_gap_unpair_oldest_peer()`, except it makes sure that the
+ * peer received in input parameters is not deleted.
+ *
+ * @param peer_addr             Address of the peer (not to be deleted)
+ *
+ * @return                      0 on success;
+ *                              A BLE host HCI return code if the controller
+ *                                  rejected the request;
+ *                              A BLE host core return code on unexpected
+ *                                  error.
+ */
+int ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr);
+
 #define BLE_GAP_PRIVATE_MODE_NETWORK        0
 #define BLE_GAP_PRIVATE_MODE_DEVICE         1
 
diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index b44012d..53c6bf3 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -5605,6 +5605,36 @@ ble_gap_unpair_oldest_peer(void)
     return 0;
 }
 
+int
+ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr)
+{
+    ble_addr_t peer_id_addrs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)];
+    int num_peers;
+    int rc, i;
+
+    rc = ble_store_util_bonded_peers(
+            &peer_id_addrs[0], &num_peers, MYNEWT_VAL(BLE_STORE_MAX_BONDS));
+    if (rc != 0) {
+        return rc;
+    }
+
+    if (num_peers == 0) {
+        return BLE_HS_ENOENT;
+    }
+
+    for (i = 0; i < num_peers; i++) {
+        if (ble_addr_cmp(peer_addr, &peer_id_addrs[i]) != 0) {
+            break;
+        }
+    }
+
+    if (i >= num_peers) {
+        return BLE_HS_ENOMEM;
+    }
+
+    return ble_gap_unpair(&peer_id_addrs[i]);
+}
+
 void
 ble_gap_passkey_event(uint16_t conn_handle,
                       struct ble_gap_passkey_params *passkey_params)
diff --git a/nimble/host/src/ble_store_util.c b/nimble/host/src/ble_store_util.c
index 444cc55..7de4827 100644
--- a/nimble/host/src/ble_store_util.c
+++ b/nimble/host/src/ble_store_util.c
@@ -233,13 +233,15 @@ ble_store_util_status_rr(struct ble_store_status_event *event, void *arg)
     switch (event->event_code) {
     case BLE_STORE_EVENT_OVERFLOW:
         switch (event->overflow.obj_type) {
-            case BLE_STORE_OBJ_TYPE_OUR_SEC:
-            case BLE_STORE_OBJ_TYPE_PEER_SEC:
-            case BLE_STORE_OBJ_TYPE_CCCD:
-                return ble_gap_unpair_oldest_peer();
-
-            default:
-                return BLE_HS_EUNKNOWN;
+        case BLE_STORE_OBJ_TYPE_OUR_SEC:
+        case BLE_STORE_OBJ_TYPE_PEER_SEC:
+            return ble_gap_unpair_oldest_peer();
+        case BLE_STORE_OBJ_TYPE_CCCD:
+            /* Try unpairing oldest peer except current peer */
+            return ble_gap_unpair_oldest_except(&event->overflow.value->cccd.peer_addr);
+
+        default:
+            return BLE_HS_EUNKNOWN;
         }
 
     case BLE_STORE_EVENT_FULL:


[mynewt-nimble] 01/02: nimble/host: Fix return code in `ble_gap_unpair_oldest_peer` when no bonded peer exist

Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7260a4efdb72ab8e1db1767c4f1e502876d8c378
Author: Prasad Alatkar <pr...@espressif.com>
AuthorDate: Fri Apr 3 18:42:05 2020 +0530

    nimble/host: Fix return code in `ble_gap_unpair_oldest_peer` when no bonded peer exist
---
 nimble/host/src/ble_gap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 4729dd0..b44012d 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -5594,7 +5594,7 @@ ble_gap_unpair_oldest_peer(void)
     }
 
     if (num_peers == 0) {
-        return 0;
+        return BLE_HS_ENOENT;
     }
 
     rc = ble_gap_unpair(&oldest_peer_id_addr);