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/07 14:41:18 UTC
[11/12] incubator-mynewt-core git commit: bletiny - Read correct
mst/slv ltk for sec restart
bletiny - Read correct mst/slv ltk for sec restart
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/12c296ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/12c296ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/12c296ad
Branch: refs/heads/upf54
Commit: 12c296ad76f9b6a4549e58ccb9ee6ea32dad544e
Parents: 5ee73b1
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Jun 7 18:42:48 2016 +0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Jun 7 22:40:34 2016 +0800
----------------------------------------------------------------------
apps/bletiny/src/main.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/12c296ad/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index f10d00a..e9c5b9b 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -52,6 +52,7 @@
*/
#include "../src/ble_hs_conn_priv.h"
#include "../src/ble_hci_util_priv.h"
+#include "../src/ble_hs_atomic_priv.h"
#define BSWAP16(x) ((uint16_t)(((x) << 8) | (((x) & 0xff00) >> 8)))
@@ -1417,6 +1418,7 @@ bletiny_sec_restart(uint16_t conn_handle,
struct ble_store_value_sec value_sec;
struct ble_store_key_sec key_sec;
struct ble_gap_conn_desc desc;
+ ble_hs_conn_flags_t conn_flags;
int rc;
if (ltk == NULL) {
@@ -1430,7 +1432,15 @@ bletiny_sec_restart(uint16_t conn_handle,
key_sec.peer_addr_type = desc.peer_addr_type;
memcpy(key_sec.peer_addr, desc.peer_addr, 6);
- rc = ble_store_read_mst_sec(&key_sec, &value_sec);
+ rc = ble_hs_atomic_conn_flags(conn_handle, &conn_flags);
+ if (rc != 0) {
+ return rc;
+ }
+ if (conn_flags & BLE_HS_CONN_F_MASTER) {
+ rc = ble_store_read_mst_sec(&key_sec, &value_sec);
+ } else {
+ rc = ble_store_read_slv_sec(&key_sec, &value_sec);
+ }
if (rc != 0) {
return rc;
}