Add commands to send KEY_REFRESH_PHASE_GET and KEY_REFRESH_PHASE_SET
messages. Handle KEY_REFRESH_PHASE_STATUS response.
---
tools/mesh/cfgcli.c | 69 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c
index cfa573de3..97849ff0d 100644
--- a/tools/mesh/cfgcli.c
+++ b/tools/mesh/cfgcli.c
@@ -42,6 +42,7 @@
#define MIN_COMPOSITION_LEN 16
#define NO_RESPONSE 0xFFFFFFFF
+#define MAX_OPCODE_SZ 3
/* Default timeout for getting a response to a sent config command (seconds) */
#define DEFAULT_TIMEOUT 2
@@ -538,6 +539,19 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data,
break;
+ case OP_CONFIG_KEY_REFRESH_PHASE_STATUS:
+ if (len != 4)
+ return true;
+
+ bt_shell_printf("\nNode %4.4x Key Refresh Phase status %s\n",
+ src, mesh_status_str(data[0]));
+
+ net_idx = get_le16(data + 1);
+ bt_shell_printf("\tNetKey Index %3.3x, phase %d\n",
+ net_idx, data[3]);
+
+ break;
+
case OP_CONFIG_MODEL_PUB_STATUS:
if (len != 12 && len != 14)
return true;
@@ -1537,6 +1551,57 @@ static void cmd_netkey_get(int argc, char *argv[])
cmd_default(OP_NETKEY_GET);
}
+static void cmd_kr_phase_get(int argc, char *argv[])
+{
+ uint16_t n;
+ uint8_t msg[MAX_OPCODE_SZ + 2];
+ int parm_cnt;
+
+ n = mesh_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_GET, msg);
+
+ parm_cnt = read_input_parameters(argc, argv);
+ if (parm_cnt != 1) {
+ bt_shell_printf("bad arguments\n");
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ /* NetKey index */
+ put_le16(parms[0], msg + n);
+ n += 2;
+
+ if (!config_send(msg, n, OP_CONFIG_KEY_REFRESH_PHASE_GET))
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
+static void cmd_kr_phase_set(int argc, char *argv[])
+{
+ uint16_t n;
+ uint8_t msg[MAX_OPCODE_SZ + 3];
+ int parm_cnt;
+
+ n = mesh_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_SET, msg);
+
+ parm_cnt = read_input_parameters(argc, argv);
+ if (parm_cnt != 2) {
+ bt_shell_printf("bad arguments\n");
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ /* NetKey index */
+ put_le16(parms[0], msg + n);
+ n += 2;
+
+ /* Transition */
+ msg[n++] = parms[1];
+
+ if (!config_send(msg, n, OP_CONFIG_KEY_REFRESH_PHASE_SET))
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
static bool tx_setup(model_send_msg_func_t send_func, void *user_data)
{
if (!send_func)
@@ -1566,6 +1631,10 @@ static const struct bt_shell_menu cfg_menu = {
"Delete NetKey"},
{"netkey-get", NULL, cmd_netkey_get,
"List NetKeys known to the node"},
+ {"kr-phase-get", "<net_idx>", cmd_kr_phase_get,
+ "Get Key Refresh phase of the nodes's subnet"},
+ {"kr-phase-set", "<net_idx> <phase>", cmd_kr_phase_set,
+ "Set Key Refresh phase of the nodes's subnet"},
{"appkey-add", "<app_idx>", cmd_appkey_add,
"Add AppKey"},
{"appkey-update", "<app_idx>", cmd_appkey_update,
--
2.21.1