Bluetooth: Mesh: Config Client network transmit set/get API

Get/Set network transmit parameter of a node.

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
This commit is contained in:
YanBiao Hao 2020-09-23 10:50:23 +08:00 committed by Carles Cufí
parent b8b42c6d18
commit dc89bfcc7f
4 changed files with 93 additions and 0 deletions

View file

@ -372,6 +372,15 @@ The Configuration Client uses the general messages parameters set by ``mesh dst`
* ``interval``: Sets the new relay retransmit interval in milliseconds if ``val`` is ``on``. Ignored if ``val`` is ``off``. Defaults to ``20`` if omitted.
``mesh net-transmit-param [<count: 0-7> <interval: 10-320>]``
-------------------------------------------------------------
Get or set the network transmit parameters.
* ``count``: Sets the number of additional network transmits for every sent message.
* ``interval``: Sets the new network retransmit interval in milliseconds.
``mesh net-key-add <NetKeyIndex> [val]``
----------------------------------------

View file

@ -160,6 +160,33 @@ 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);
/** @brief Get the target node's network_transmit state.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param transmit Network transmit response parameter. Returns the encoded
* network transmission parameters on success. Decoded with
* @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_net_transmit_get(uint16_t net_idx, uint16_t addr,
uint8_t *transmit);
/** @brief Set the target node's network transmit parameters.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val New encoded network transmit parameters.
* @see BT_MESH_TRANSMIT.
* @param transmit Network transmit response parameter. Returns the encoded
* network transmission parameters on success. Decoded with
* @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT.
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_net_transmit_set(uint16_t net_idx, uint16_t addr,
uint8_t val, uint8_t *transmit);
/** @brief Get the target node's Relay feature state.
*
* @param net_idx Network index to encrypt with.

View file

@ -903,6 +903,21 @@ 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)
{

View file

@ -899,6 +899,46 @@ static int cmd_gatt_proxy(const struct shell *shell, size_t argc, char *argv[])
return 0;
}
static int cmd_net_transmit(const struct shell *shell,
size_t 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) {
shell_error(shell, "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) {
shell_error(shell, "Unable to send network transmit"
" Get/Set (err %d)", err);
return 0;
}
shell_print(shell, "Transmit 0x%02x (count %u interval %ums)",
transmit, BT_MESH_TRANSMIT_COUNT(transmit),
BT_MESH_TRANSMIT_INT(transmit));
return 0;
}
static int cmd_relay(const struct shell *shell, size_t argc, char *argv[])
{
uint8_t relay, transmit;
@ -2681,6 +2721,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(mesh_cmds,
cmd_app_key_del, 3, 0),
SHELL_CMD_ARG(app-key-get, NULL, "<NetKeyIndex>", cmd_app_key_get, 2,
0),
SHELL_CMD_ARG(net-transmit-param, NULL, "[<count: 0-7>"
" <interval: 10-320>]", cmd_net_transmit, 1, 2),
SHELL_CMD_ARG(mod-app-bind, NULL,
"<addr> <AppIndex> <Model ID> [Company ID]",
cmd_mod_app_bind, 4, 1),