You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by na...@apache.org on 2021/05/27 08:20:49 UTC
[mynewt-nimble] 22/31: Revert "mesh: Add CDB handle key refresh
phase"
This is an automated email from the ASF dual-hosted git repository.
naraj pushed a commit to branch revert-958-mesh_sync_march21
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 4a0ee0bdb19f68b804dff1e8d809f40d25a2a3b3
Author: MichaĆ Narajowski <mi...@codecoup.pl>
AuthorDate: Thu May 27 10:20:19 2021 +0200
Revert "mesh: Add CDB handle key refresh phase"
This reverts commit 83cf6da68cb8c49371875cc113d176f9cfe74f89.
---
nimble/host/mesh/include/mesh/cdb.h | 1 +
nimble/host/mesh/include/mesh/cfg.h | 6 ------
nimble/host/mesh/src/cdb.c | 2 +-
nimble/host/mesh/src/provisioner.c | 2 +-
nimble/host/mesh/src/settings.c | 4 +++-
nimble/host/mesh/src/shell.c | 10 +++++-----
nimble/host/mesh/src/testing.c | 4 ++++
7 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/nimble/host/mesh/include/mesh/cdb.h b/nimble/host/mesh/include/mesh/cdb.h
index 440390c..8f9a6bc 100644
--- a/nimble/host/mesh/include/mesh/cdb.h
+++ b/nimble/host/mesh/include/mesh/cdb.h
@@ -40,6 +40,7 @@ struct bt_mesh_cdb_node {
struct bt_mesh_cdb_subnet {
uint16_t net_idx;
+ bool kr_flag;
uint8_t kr_phase;
struct {
diff --git a/nimble/host/mesh/include/mesh/cfg.h b/nimble/host/mesh/include/mesh/cfg.h
index 6fd6926..378f0a0 100644
--- a/nimble/host/mesh/include/mesh/cfg.h
+++ b/nimble/host/mesh/include/mesh/cfg.h
@@ -35,12 +35,6 @@ enum bt_mesh_feat_state {
BT_MESH_FEATURE_NOT_SUPPORTED,
};
-/* Key Refresh Phase */
-#define BT_MESH_KR_NORMAL 0x00
-#define BT_MESH_KR_PHASE_1 0x01
-#define BT_MESH_KR_PHASE_2 0x02
-#define BT_MESH_KR_PHASE_3 0x03
-
/* Legacy feature defines */
#define BT_MESH_RELAY_DISABLED BT_MESH_FEATURE_DISABLED
#define BT_MESH_RELAY_ENABLED BT_MESH_FEATURE_ENABLED
diff --git a/nimble/host/mesh/src/cdb.c b/nimble/host/mesh/src/cdb.c
index 60d47de..f0c2e5f 100644
--- a/nimble/host/mesh/src/cdb.c
+++ b/nimble/host/mesh/src/cdb.c
@@ -235,7 +235,7 @@ uint8_t bt_mesh_cdb_subnet_flags(const struct bt_mesh_cdb_subnet *sub)
{
uint8_t flags = 0x00;
- if (sub && SUBNET_KEY_TX_IDX(sub)) {
+ if (sub && sub->kr_flag) {
flags |= BT_MESH_NET_FLAG_KR;
}
diff --git a/nimble/host/mesh/src/provisioner.c b/nimble/host/mesh/src/provisioner.c
index 265dbf2..e26efe7 100644
--- a/nimble/host/mesh/src/provisioner.c
+++ b/nimble/host/mesh/src/provisioner.c
@@ -503,7 +503,7 @@ static void send_prov_data(void)
#endif
bt_mesh_prov_buf_init(pdu, PROV_DATA);
#if MYNEWT_VAL(BLE_MESH_CDB)
- net_buf_simple_add_mem(&pdu, sub->keys[SUBNET_KEY_TX_IDX(sub)].net_key, 16);
+ net_buf_simple_add_mem(pdu, sub->keys[sub->kr_flag].net_key, 16);
net_buf_simple_add_be16(pdu, prov_device.node->net_idx);
net_buf_simple_add_u8(pdu, bt_mesh_cdb_subnet_flags(sub));
net_buf_simple_add_be32(pdu, bt_mesh_cdb.iv_index);
diff --git a/nimble/host/mesh/src/settings.c b/nimble/host/mesh/src/settings.c
index 1fb2b08..193cc0b 100644
--- a/nimble/host/mesh/src/settings.c
+++ b/nimble/host/mesh/src/settings.c
@@ -829,6 +829,7 @@ static int cdb_subnet_set(int argc, char *name)
if (sub) {
BT_DBG("Updating existing NetKeyIndex 0x%03x", net_idx);
+ sub->kr_flag = key.kr_flag;
sub->kr_phase = key.kr_phase;
memcpy(sub->keys[0].net_key, &key.val[0], 16);
memcpy(sub->keys[1].net_key, &key.val[1], 16);
@@ -842,6 +843,7 @@ static int cdb_subnet_set(int argc, char *name)
return -ENOMEM;
}
+ sub->kr_flag = key.kr_flag;
sub->kr_phase = key.kr_phase;
memcpy(sub->keys[0].net_key, &key.val[0], 16);
memcpy(sub->keys[1].net_key, &key.val[1], 16);
@@ -1606,7 +1608,7 @@ static void store_cdb_subnet(const struct bt_mesh_cdb_subnet *sub)
memcpy(&key.val[0], sub->keys[0].net_key, 16);
memcpy(&key.val[1], sub->keys[1].net_key, 16);
- key.kr_flag = 0U; /* Deprecated */
+ key.kr_flag = sub->kr_flag;
key.kr_phase = sub->kr_phase;
snprintk(path, sizeof(path), "bt/mesh/cdb/Subnet/%x", sub->net_idx);
diff --git a/nimble/host/mesh/src/shell.c b/nimble/host/mesh/src/shell.c
index ade9cd6..1ac4caf 100644
--- a/nimble/host/mesh/src/shell.c
+++ b/nimble/host/mesh/src/shell.c
@@ -738,7 +738,7 @@ int cmd_mesh_init(int argc, char *argv[])
printk("Mesh initialized\n");
- if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
+ if (IS_ENABLED(CONFIG_SETTINGS)) {
settings_load();
}
@@ -2345,7 +2345,7 @@ static int cmd_provision(int argc, char *argv[])
return 0;
}
- net_key = sub->keys[SUBNET_KEY_TX_IDX(sub)].net_key;
+ net_key = sub->keys[sub->kr_flag].net_key;
}
err = bt_mesh_provision(net_key, net_idx, 0, iv_index, addr,
@@ -2905,7 +2905,7 @@ static int cmd_cdb_node_add(int argc, char *argv[])
memcpy(node->dev_key, dev_key, 16);
- if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
+ if (IS_ENABLED(CONFIG_SETTINGS)) {
bt_mesh_store_cdb_node(node);
}
@@ -2959,7 +2959,7 @@ static int cmd_cdb_subnet_add(int argc,
memcpy(sub->keys[0].net_key, net_key, 16);
- if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
+ if (IS_ENABLED(CONFIG_SETTINGS)) {
bt_mesh_store_cdb_subnet(sub);
}
@@ -3015,7 +3015,7 @@ static int cmd_cdb_app_key_add(int argc,
memcpy(key->keys[0].app_key, app_key, 16);
- if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
+ if (IS_ENABLED(CONFIG_SETTINGS)) {
bt_mesh_store_cdb_app_key(key);
}
diff --git a/nimble/host/mesh/src/testing.c b/nimble/host/mesh/src/testing.c
index 7ee11a1..dfe8d18 100644
--- a/nimble/host/mesh/src/testing.c
+++ b/nimble/host/mesh/src/testing.c
@@ -135,6 +135,8 @@ void bt_test_print_credentials(void)
console_printf("Subnet: %d\n", i);
console_printf("\tNetKeyIdx: %04x\n",
sub->net_idx);
+ console_printf("\tNetKey: %s\n",
+ bt_hex(sub->keys[sub->kr_flag].net_key, 16));
}
for (i = 0; i < ARRAY_SIZE(bt_mesh_cdb.app_keys); ++i)
@@ -152,6 +154,8 @@ void bt_test_print_credentials(void)
app_key->net_idx);
console_printf("\tAppKeyIdx: %04x\n",
app_key->app_idx);
+ console_printf("\tAppKey: %s\n",
+ bt_hex(app_key->keys[sub->kr_flag].app_key, 16));
}
for (i = 0; i < ARRAY_SIZE(bt_mesh_cdb.subnets); ++i)