mesh: Config Client network transmit set/get API

Get/Set network transmit parameter of a node.

this is port of dc89bfcc7ffcd5372333ac8701ec944ae9de8b9f
This commit is contained in:
Krzysztof Kopyściński
2021-01-12 14:05:19 +01:00
committed by Łukasz Rymanowski
parent bf4560e454
commit e1a222ab56
3 changed files with 68 additions and 0 deletions
+6
View File
@@ -57,6 +57,12 @@ int bt_mesh_cfg_gatt_proxy_get(uint16_t net_idx, uint16_t addr, uint8_t *status)
int bt_mesh_cfg_gatt_proxy_set(uint16_t net_idx, uint16_t addr, uint8_t val,
uint8_t *status);
int bt_mesh_cfg_net_transmit_get(uint16_t net_idx, uint16_t addr,
uint8_t *transmit);
int bt_mesh_cfg_net_transmit_set(uint16_t net_idx, uint16_t addr,
uint8_t val, uint8_t *transmit);
int bt_mesh_cfg_relay_get(uint16_t net_idx, uint16_t addr, uint8_t *status,
uint8_t *transmit);
+14
View File
@@ -907,6 +907,20 @@ int bt_mesh_cfg_gatt_proxy_set(uint16_t net_idx, uint16_t addr, uint8_t val,
OP_GATT_PROXY_STATUS, val, status);
}
int bt_mesh_cfg_net_transmit_set(uint16_t net_idx, uint16_t addr,
uint8_t val, uint8_t *transmit)
{
return set_state_u8(net_idx, addr, OP_NET_TRANSMIT_SET,
OP_NET_TRANSMIT_STATUS, val, transmit);
}
int bt_mesh_cfg_net_transmit_get(uint16_t net_idx, uint16_t addr,
uint8_t *transmit)
{
return get_state_u8(net_idx, addr, OP_NET_TRANSMIT_GET,
OP_NET_TRANSMIT_STATUS, transmit);
}
int bt_mesh_cfg_relay_get(uint16_t net_idx, uint16_t addr, uint8_t *status,
uint8_t *transmit)
{
+48
View File
@@ -1219,6 +1219,49 @@ struct shell_cmd_help cmd_gatt_proxy_help = {
NULL, "[val: off, on]", NULL
};
static int cmd_net_transmit(int argc, char *argv[])
{
uint8_t transmit;
int err;
if (argc < 2) {
err = bt_mesh_cfg_net_transmit_get(net.net_idx,
net.dst, &transmit);
} else {
if (argc != 3) {
printk("Wrong number of input arguments"
"(2 arguments are required)");
return -EINVAL;
}
uint8_t count, interval, new_transmit;
count = strtoul(argv[1], NULL, 0);
interval = strtoul(argv[2], NULL, 0);
new_transmit = BT_MESH_TRANSMIT(count, interval);
err = bt_mesh_cfg_net_transmit_set(net.net_idx, net.dst,
new_transmit, &transmit);
}
if (err) {
printk("Unable to send network transmit"
" Get/Set (err %d)", err);
return 0;
}
printk("Transmit 0x%02x (count %u interval %ums)",
transmit, BT_MESH_TRANSMIT_COUNT(transmit),
BT_MESH_TRANSMIT_INT(transmit));
return 0;
}
struct shell_cmd_help cmd_net_transmit_help = {
NULL, "[<count: 0-7> <interval: 10-320>]", NULL
};
static int cmd_relay(int argc, char *argv[])
{
uint8_t relay, transmit;
@@ -3405,6 +3448,11 @@ static const struct shell_cmd mesh_commands[] = {
.sc_cmd_func = cmd_app_key_get,
.help = &cmd_app_key_get_help,
},
{
.sc_cmd = "net-transmit-param",
.sc_cmd_func = cmd_net_transmit,
.help = &cmd_net_transmit_help,
},
{
.sc_cmd = "mod-app-bind",
.sc_cmd_func = cmd_mod_app_bind,