You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2023/11/21 07:38:33 UTC
(mynewt-nimble) 01/02: apps/bttester: update Mesh commands
This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit d2059936b58be50612de92624320ffc1180a8605
Author: Krzysztof Kopyściński <kr...@codecoup.pl>
AuthorDate: Fri Nov 17 13:51:32 2023 +0100
apps/bttester: update Mesh commands
BTP_MESH_INIT now only initialises Mesh. It expects additional field
defining which composition data to use. For now it's parsed but ignored
(we use always same composition data)
Introduced BTP_MESH_START command that enables Mesh advertising, as
before it was in BTP_MESH_INIT. Command may be longer now, because static_auth
can be 32 octets long. Additional field `static_auth_length` is ignored
for now, as we support only 16 octet long auth.
---
apps/bttester/src/btp/btp_mesh.h | 8 ++++++-
apps/bttester/src/btp_mesh.c | 49 ++++++++++++++++++++++++++++------------
2 files changed, 42 insertions(+), 15 deletions(-)
diff --git a/apps/bttester/src/btp/btp_mesh.h b/apps/bttester/src/btp/btp_mesh.h
index 0a356e40..b51706ab 100644
--- a/apps/bttester/src/btp/btp_mesh.h
+++ b/apps/bttester/src/btp/btp_mesh.h
@@ -47,7 +47,8 @@ struct btp_mesh_read_supported_commands_rp {
#define BTP_MESH_CONFIG_PROVISIONING 0x02
struct btp_mesh_config_provisioning_cmd {
uint8_t uuid[16];
- uint8_t static_auth[16];
+ uint8_t static_auth[32];
+ uint8_t static_auth_length;
uint8_t out_size;
uint16_t out_actions;
uint8_t in_size;
@@ -66,6 +67,10 @@ struct btp_mesh_provision_node_cmd {
} __packed;
#define BTP_MESH_INIT 0x04
+struct btp_mesh_init_cmd {
+ uint8_t comp;
+} __packed;
+
#define BTP_MESH_RESET 0x05
#define BTP_MESH_INPUT_NUMBER 0x06
struct btp_mesh_input_number_cmd {
@@ -132,6 +137,7 @@ struct btp_mesh_lpn_unsubscribe_cmd {
#define BTP_MESH_RPL_CLEAR 0x12
#define BTP_MESH_PROXY_IDENTITY 0x13
+#define BTP_MESH_START 0x78
/* events */
#define BTP_MESH_EV_OUT_NUMBER_ACTION 0x80
diff --git a/apps/bttester/src/btp_mesh.c b/apps/bttester/src/btp_mesh.c
index 96eaaf81..2dc3eb4d 100644
--- a/apps/bttester/src/btp_mesh.c
+++ b/apps/bttester/src/btp_mesh.c
@@ -458,26 +458,18 @@ static uint8_t
init(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
+ const struct btp_mesh_init_cmd *cp = cmd;
int err;
SYS_LOG_DBG("");
- err = bt_mesh_init(own_addr_type, &prov, &comp);
- if (err) {
+ if (cmd_len != sizeof(*cp)) {
return BTP_STATUS_FAILED;
}
- if (addr) {
- err = bt_mesh_provision(net_key, net_key_idx, flags, iv_index,
- addr, dev_key);
- if (err) {
- return BTP_STATUS_FAILED;
- }
- } else {
- err = bt_mesh_prov_enable(BT_MESH_PROV_ADV | BT_MESH_PROV_GATT);
- if (err) {
- return BTP_STATUS_FAILED;
- }
+ err = bt_mesh_init(own_addr_type, &prov, &comp);
+ if (err) {
+ return BTP_STATUS_FAILED;
}
return BTP_STATUS_SUCCESS;
@@ -828,6 +820,30 @@ proxy_identity_enable(const void *cmd, uint16_t cmd_len,
return BTP_STATUS_SUCCESS;
}
+static uint8_t
+start(const void *cmd, uint16_t cmd_len,
+ void *rsp, uint16_t *rsp_len)
+{
+ int err;
+
+ SYS_LOG_DBG("");
+
+ if (addr) {
+ err = bt_mesh_provision(net_key, net_key_idx, flags, iv_index,
+ addr, dev_key);
+ if (err) {
+ return BTP_STATUS_FAILED;
+ }
+ } else {
+ err = bt_mesh_prov_enable(BT_MESH_PROV_ADV | BT_MESH_PROV_GATT);
+ if (err) {
+ return BTP_STATUS_FAILED;
+ }
+ }
+
+ return BTP_STATUS_SUCCESS;
+}
+
static const struct btp_handler handlers[] = {
{
.opcode = BTP_MESH_READ_SUPPORTED_COMMANDS,
@@ -847,7 +863,7 @@ static const struct btp_handler handlers[] = {
},
{
.opcode = BTP_MESH_INIT,
- .expect_len = 0,
+ .expect_len = 1,
.func = init,
},
{
@@ -925,6 +941,11 @@ static const struct btp_handler handlers[] = {
.expect_len = 0,
.func = proxy_identity_enable,
},
+ {
+ .opcode = BTP_MESH_START,
+ .expect_len = 0,
+ .func = start,
+ },
};
void