You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/06/01 17:55:55 UTC

incubator-mynewt-core git commit: BLE Host - Add idx to store sec key.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop c18b063db -> f5a89066c


BLE Host - Add idx to store sec key.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f5a89066
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f5a89066
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f5a89066

Branch: refs/heads/develop
Commit: f5a89066c158ec56d9c722b6892fc1b41bb14621
Parents: c18b063
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Jun 1 10:55:33 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Jun 1 10:55:33 2016 -0700

----------------------------------------------------------------------
 apps/bleprph/src/store.c                 | 8 ++++++++
 apps/bletiny/src/store.c                 | 8 ++++++++
 net/nimble/host/include/host/ble_store.h | 3 +++
 net/nimble/host/src/ble_store.c          | 1 +
 4 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5a89066/apps/bleprph/src/store.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/store.c b/apps/bleprph/src/store.c
index d1b315c..d3d7262 100644
--- a/apps/bleprph/src/store.c
+++ b/apps/bleprph/src/store.c
@@ -95,8 +95,11 @@ store_find_sec(struct ble_store_key_sec *key_sec,
                struct ble_store_value_sec *value_secs, int num_value_secs)
 {
     struct ble_store_value_sec *cur;
+    int skipped;
     int i;
 
+    skipped = 0;
+
     for (i = 0; i < num_value_secs; i++) {
         cur = value_secs + i;
 
@@ -121,6 +124,11 @@ store_find_sec(struct ble_store_key_sec *key_sec,
             }
         }
 
+        if (key_sec->idx > skipped) {
+            skipped++;
+            continue;
+        }
+
         return i;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5a89066/apps/bletiny/src/store.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/store.c b/apps/bletiny/src/store.c
index c3a234b..b16655b 100644
--- a/apps/bletiny/src/store.c
+++ b/apps/bletiny/src/store.c
@@ -95,8 +95,11 @@ store_find_sec(struct ble_store_key_sec *key_sec,
                struct ble_store_value_sec *value_secs, int num_value_secs)
 {
     struct ble_store_value_sec *cur;
+    int skipped;
     int i;
 
+    skipped = 0;
+
     for (i = 0; i < num_value_secs; i++) {
         cur = value_secs + i;
 
@@ -121,6 +124,11 @@ store_find_sec(struct ble_store_key_sec *key_sec,
             }
         }
 
+        if (key_sec->idx > skipped) {
+            skipped++;
+            continue;
+        }
+
         return i;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5a89066/net/nimble/host/include/host/ble_store.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_store.h b/net/nimble/host/include/host/ble_store.h
index d287e57..7a75703 100644
--- a/net/nimble/host/include/host/ble_store.h
+++ b/net/nimble/host/include/host/ble_store.h
@@ -47,6 +47,9 @@ struct ble_store_key_sec {
     uint64_t rand_num;
 
     unsigned ediv_rand_present:1;
+
+    /** Number of results to skip; 0 means retrieve the first match. */
+    uint8_t idx;
 };
 
 struct ble_store_value_sec {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5a89066/net/nimble/host/src/ble_store.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_store.c b/net/nimble/host/src/ble_store.c
index 05f1278..a49d6b1 100644
--- a/net/nimble/host/src/ble_store.c
+++ b/net/nimble/host/src/ble_store.c
@@ -171,4 +171,5 @@ ble_store_key_from_value_sec(struct ble_store_key_sec *out_key,
     out_key->ediv = value->ediv;
     out_key->rand_num = value->rand_num;
     out_key->ediv_rand_present = 1;
+    out_key->idx = 0;
 }