mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-13 20:50:00 +00:00
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:
committed by
Łukasz Rymanowski
parent
bf4560e454
commit
e1a222ab56
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user