diff options
Diffstat (limited to 'src/libs/mynewt-nimble/nimble/host/mesh/src/cfg_cli.c')
| -rw-r--r-- | src/libs/mynewt-nimble/nimble/host/mesh/src/cfg_cli.c | 901 |
1 files changed, 760 insertions, 141 deletions
diff --git a/src/libs/mynewt-nimble/nimble/host/mesh/src/cfg_cli.c b/src/libs/mynewt-nimble/nimble/host/mesh/src/cfg_cli.c index 2c2f6c3..a87cd7b 100644 --- a/src/libs/mynewt-nimble/nimble/host/mesh/src/cfg_cli.c +++ b/src/libs/mynewt-nimble/nimble/host/mesh/src/cfg_cli.c @@ -25,11 +25,11 @@ #define DUMMY_2_BYTE_OP BT_MESH_MODEL_OP_2(0xff, 0xff) struct comp_data { - u8_t *status; + uint8_t *status; struct os_mbuf *comp; }; -static s32_t msg_timeout = K_SECONDS(5); +static int32_t msg_timeout = K_SECONDS(5); static struct bt_mesh_cfg_cli *cli; @@ -61,9 +61,9 @@ static void comp_data_status(struct bt_mesh_model *model, static void state_status_u8(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf*buf, - u32_t expect_status) + uint32_t expect_status) { - u8_t *status; + uint8_t *status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -110,8 +110,8 @@ static void gatt_proxy_status(struct bt_mesh_model *model, } struct relay_param { - u8_t *status; - u8_t *transmit; + uint8_t *status; + uint8_t *transmit; }; static void relay_status(struct bt_mesh_model *model, @@ -137,8 +137,8 @@ static void relay_status(struct bt_mesh_model *model, } struct net_key_param { - u8_t *status; - u16_t net_idx; + uint8_t *status; + uint16_t net_idx; }; static void net_key_status(struct bt_mesh_model *model, @@ -146,8 +146,8 @@ static void net_key_status(struct bt_mesh_model *model, struct os_mbuf *buf) { struct net_key_param *param; - u16_t net_idx, app_idx; - u8_t status; + uint16_t net_idx; + uint8_t status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -159,7 +159,7 @@ static void net_key_status(struct bt_mesh_model *model, } status = net_buf_simple_pull_u8(buf); - key_idx_unpack(buf, &net_idx, &app_idx); + net_idx = net_buf_simple_pull_le16(buf) & 0xfff; param = cli->op_param; if (param->net_idx != net_idx) { @@ -174,10 +174,66 @@ static void net_key_status(struct bt_mesh_model *model, k_sem_give(&cli->op_sync); } +struct net_key_list_param { + uint16_t *keys; + size_t *key_cnt; +}; + +static void net_key_list(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct os_mbuf *buf) +{ + struct net_key_list_param *param; + int i; + + BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", + ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, + bt_hex(buf->om_data, buf->om_len)); + + if (cli->op_pending != OP_NET_KEY_LIST) { + BT_WARN("Unexpected Net Key List message"); + return; + } + + param = cli->op_param; + + for (i = 0; i < *param->key_cnt && buf->om_len >= 3; i += 2) { + key_idx_unpack(buf, ¶m->keys[i], ¶m->keys[i + 1]); + } + + if (i < *param->key_cnt && buf->om_len >= 2) { + param->keys[i++] = net_buf_simple_pull_le16(buf) & 0xfff; + } + + *param->key_cnt = i; + + k_sem_give(&cli->op_sync); +} + +static void node_reset_status(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) +{ + bool *param = NULL; + BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x", + ctx->net_idx, ctx->app_idx, ctx->addr); + + if (cli->op_pending != OP_NODE_RESET_STATUS) { + BT_WARN("Unexpected Node Reset Status message"); + return; + } + + param = cli->op_param; + + if (param) { + *param = true; + } + k_sem_give(&cli->op_sync); +} + struct app_key_param { - u8_t *status; - u16_t net_idx; - u16_t app_idx; + uint8_t *status; + uint16_t net_idx; + uint16_t app_idx; }; static void app_key_status(struct bt_mesh_model *model, @@ -185,8 +241,8 @@ static void app_key_status(struct bt_mesh_model *model, struct os_mbuf*buf) { struct app_key_param *param; - u16_t net_idx, app_idx; - u8_t status; + uint16_t net_idx, app_idx; + uint8_t status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -213,21 +269,71 @@ static void app_key_status(struct bt_mesh_model *model, k_sem_give(&cli->op_sync); } +struct app_key_list_param { + uint16_t net_idx; + uint8_t *status; + uint16_t *keys; + size_t *key_cnt; +}; + +static void app_key_list(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct os_mbuf *buf) +{ + struct app_key_list_param *param; + uint16_t net_idx; + uint8_t status; + int i; + + BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", + ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, + bt_hex(buf->om_data, buf->om_len)); + + if (cli->op_pending != OP_APP_KEY_LIST) { + BT_WARN("Unexpected App Key List message"); + return; + } + + status = net_buf_simple_pull_u8(buf); + net_idx = net_buf_simple_pull_le16(buf) & 0xfff; + + param = cli->op_param; + if (param->net_idx != net_idx) { + BT_WARN("App Key List Net Key index did not match"); + return; + } + + for (i = 0; i < *param->key_cnt && buf->om_len >= 3; i += 2) { + key_idx_unpack(buf, ¶m->keys[i], ¶m->keys[i + 1]); + } + + if (i < *param->key_cnt && buf->om_len >= 2) { + param->keys[i++] = net_buf_simple_pull_le16(buf) & 0xfff; + } + + *param->key_cnt = i; + if (param->status) { + *param->status = status; + } + + k_sem_give(&cli->op_sync); +} + struct mod_app_param { - u8_t *status; - u16_t elem_addr; - u16_t mod_app_idx; - u16_t mod_id; - u16_t cid; + uint8_t *status; + uint16_t elem_addr; + uint16_t mod_app_idx; + uint16_t mod_id; + uint16_t cid; }; static void mod_app_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf*buf) { - u16_t elem_addr, mod_app_idx, mod_id, cid; + uint16_t elem_addr, mod_app_idx, mod_id, cid; struct mod_app_param *param; - u8_t status; + uint8_t status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -265,11 +371,92 @@ static void mod_app_status(struct bt_mesh_model *model, k_sem_give(&cli->op_sync); } +struct mod_member_list_param { + uint8_t *status; + uint16_t elem_addr; + uint16_t mod_id; + uint16_t cid; + uint16_t *members; + size_t *member_cnt; +}; + +static void mod_member_list_handle(struct bt_mesh_msg_ctx *ctx, + struct os_mbuf *buf, bool vnd) +{ + struct mod_member_list_param *param; + uint16_t elem_addr, mod_id, cid; + uint8_t status; + int i; + + status = net_buf_simple_pull_u8(buf); + elem_addr = net_buf_simple_pull_le16(buf); + if (vnd) { + cid = net_buf_simple_pull_le16(buf); + } + + mod_id = net_buf_simple_pull_le16(buf); + + param = cli->op_param; + if (param->elem_addr != elem_addr || param->mod_id != mod_id || + (vnd && param->cid != cid)) { + BT_WARN("Model Member List parameters did not match"); + return; + } + + if (buf->om_len % 2) { + BT_WARN("Model Member List invalid length"); + return; + } + + for (i = 0; i < *param->member_cnt && buf->om_len; i++) { + param->members[i] = net_buf_simple_pull_le16(buf); + } + + *param->member_cnt = i; + if (param->status) { + *param->status = status; + } + + k_sem_give(&cli->op_sync); +} + +static void mod_app_list(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct os_mbuf *buf) +{ + BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", + ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, + bt_hex(buf->om_data, buf->om_len)); + + if (cli->op_pending != OP_SIG_MOD_APP_LIST) { + BT_WARN("Unexpected Model App List message"); + return; + } + + mod_member_list_handle(ctx, buf, false); +} + +static void mod_app_list_vnd(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct os_mbuf *buf) +{ + BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", + ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, + bt_hex(buf->om_data, buf->om_len)); + + if (cli->op_pending != OP_VND_MOD_APP_LIST) { + BT_WARN("Unexpected Model App List Vendor message"); + return; + } + + mod_member_list_handle(ctx, buf, true); +} + struct mod_pub_param { - u16_t mod_id; - u16_t cid; - u16_t elem_addr; - u8_t *status; + uint16_t mod_id; + uint16_t cid; + uint16_t elem_addr; + uint8_t *status; struct bt_mesh_cfg_mod_pub *pub; }; @@ -277,9 +464,9 @@ static void mod_pub_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf*buf) { - u16_t mod_id, cid, elem_addr; + uint16_t mod_id, cid, elem_addr; struct mod_pub_param *param; - u8_t status; + uint8_t status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -341,21 +528,21 @@ static void mod_pub_status(struct bt_mesh_model *model, } struct mod_sub_param { - u8_t *status; - u16_t elem_addr; - u16_t *sub_addr; - u16_t *expect_sub; - u16_t mod_id; - u16_t cid; + uint8_t *status; + uint16_t elem_addr; + uint16_t *sub_addr; + uint16_t *expect_sub; + uint16_t mod_id; + uint16_t cid; }; static void mod_sub_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf*buf) { - u16_t elem_addr, sub_addr, mod_id, cid; + uint16_t elem_addr, sub_addr, mod_id, cid; struct mod_sub_param *param; - u8_t status; + uint8_t status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -397,8 +584,40 @@ static void mod_sub_status(struct bt_mesh_model *model, k_sem_give(&cli->op_sync); } +static void mod_sub_list(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct os_mbuf *buf) +{ + BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", + ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, + bt_hex(buf->om_data, buf->om_len)); + + if (cli->op_pending != OP_MOD_SUB_LIST) { + BT_WARN("Unexpected Model Subscription List message"); + return; + } + + mod_member_list_handle(ctx, buf, false); +} + +static void mod_sub_list_vnd(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct os_mbuf *buf) +{ + BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", + ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, + bt_hex(buf->om_data, buf->om_len)); + + if (cli->op_pending != OP_MOD_SUB_LIST_VND) { + BT_WARN("Unexpected Model Subscription List Vendor message"); + return; + } + + mod_member_list_handle(ctx, buf, true); +} + struct hb_sub_param { - u8_t *status; + uint8_t *status; struct bt_mesh_cfg_hb_sub *sub; }; @@ -432,7 +651,7 @@ static void hb_sub_status(struct bt_mesh_model *model, } struct hb_pub_param { - u8_t *status; + uint8_t *status; struct bt_mesh_cfg_hb_pub *pub; }; @@ -475,12 +694,19 @@ const struct bt_mesh_model_op bt_mesh_cfg_cli_op[] = { { OP_GATT_PROXY_STATUS, 1, gatt_proxy_status }, { OP_RELAY_STATUS, 2, relay_status }, { OP_NET_KEY_STATUS, 3, net_key_status }, + { OP_NET_KEY_LIST, 0, net_key_list }, { OP_APP_KEY_STATUS, 4, app_key_status }, + { OP_APP_KEY_LIST, 3, app_key_list }, { OP_MOD_APP_STATUS, 7, mod_app_status }, + { OP_SIG_MOD_APP_LIST, 5, mod_app_list}, + { OP_VND_MOD_APP_LIST, 7, mod_app_list_vnd}, { OP_MOD_PUB_STATUS, 12, mod_pub_status }, { OP_MOD_SUB_STATUS, 7, mod_sub_status }, + { OP_MOD_SUB_LIST, 5, mod_sub_list}, + { OP_MOD_SUB_LIST_VND, 7, mod_sub_list_vnd}, { OP_HEARTBEAT_SUB_STATUS, 9, hb_sub_status }, { OP_HEARTBEAT_PUB_STATUS, 10, hb_pub_status }, + { OP_NODE_RESET_STATUS, 0, node_reset_status}, BT_MESH_MODEL_OP_END, }; @@ -516,7 +742,7 @@ const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb = { .init = cfg_cli_init, }; -static int cli_prepare(void *param, u32_t op) +static int cli_prepare(void *param, uint32_t op) { if (!cli) { BT_ERR("No available Configuration Client context!"); @@ -551,8 +777,8 @@ static int cli_wait(void) return err; } -int bt_mesh_cfg_comp_data_get(u16_t net_idx, u16_t addr, u8_t page, - u8_t *status, struct os_mbuf *comp) +int bt_mesh_cfg_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page, + uint8_t *status, struct os_mbuf *comp) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_DEV_COMP_DATA_GET, 1); struct bt_mesh_msg_ctx ctx = { @@ -588,8 +814,8 @@ done: return err; } -static int get_state_u8(u16_t net_idx, u16_t addr, u32_t op, u32_t rsp, - u8_t *val) +static int get_state_u8(uint16_t net_idx, uint16_t addr, uint32_t op, uint32_t rsp, + uint8_t *val) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(DUMMY_2_BYTE_OP, 0); struct bt_mesh_msg_ctx ctx = { @@ -620,8 +846,8 @@ done: return err; } -static int set_state_u8(u16_t net_idx, u16_t addr, u32_t op, u32_t rsp, - u8_t new_val, u8_t *val) +static int set_state_u8(uint16_t net_idx, uint16_t addr, uint32_t op, uint32_t rsp, + uint8_t new_val, uint8_t *val) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(DUMMY_2_BYTE_OP, 1); struct bt_mesh_msg_ctx ctx = { @@ -653,57 +879,71 @@ done: return err; } -int bt_mesh_cfg_beacon_get(u16_t net_idx, u16_t addr, u8_t *status) +int bt_mesh_cfg_beacon_get(uint16_t net_idx, uint16_t addr, uint8_t *status) { return get_state_u8(net_idx, addr, OP_BEACON_GET, OP_BEACON_STATUS, status); } -int bt_mesh_cfg_beacon_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *status) +int bt_mesh_cfg_beacon_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status) { return set_state_u8(net_idx, addr, OP_BEACON_SET, OP_BEACON_STATUS, val, status); } -int bt_mesh_cfg_ttl_get(u16_t net_idx, u16_t addr, u8_t *ttl) +int bt_mesh_cfg_ttl_get(uint16_t net_idx, uint16_t addr, uint8_t *ttl) { return get_state_u8(net_idx, addr, OP_DEFAULT_TTL_GET, OP_DEFAULT_TTL_STATUS, ttl); } -int bt_mesh_cfg_ttl_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *ttl) +int bt_mesh_cfg_ttl_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *ttl) { return set_state_u8(net_idx, addr, OP_DEFAULT_TTL_SET, OP_DEFAULT_TTL_STATUS, val, ttl); } -int bt_mesh_cfg_friend_get(u16_t net_idx, u16_t addr, u8_t *status) +int bt_mesh_cfg_friend_get(uint16_t net_idx, uint16_t addr, uint8_t *status) { return get_state_u8(net_idx, addr, OP_FRIEND_GET, OP_FRIEND_STATUS, status); } -int bt_mesh_cfg_friend_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *status) +int bt_mesh_cfg_friend_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status) { return set_state_u8(net_idx, addr, OP_FRIEND_SET, OP_FRIEND_STATUS, val, status); } -int bt_mesh_cfg_gatt_proxy_get(u16_t net_idx, u16_t addr, u8_t *status) +int bt_mesh_cfg_gatt_proxy_get(uint16_t net_idx, uint16_t addr, uint8_t *status) { return get_state_u8(net_idx, addr, OP_GATT_PROXY_GET, OP_GATT_PROXY_STATUS, status); } -int bt_mesh_cfg_gatt_proxy_set(u16_t net_idx, u16_t addr, u8_t val, - u8_t *status) +int bt_mesh_cfg_gatt_proxy_set(uint16_t net_idx, uint16_t addr, uint8_t val, + uint8_t *status) { return set_state_u8(net_idx, addr, OP_GATT_PROXY_SET, OP_GATT_PROXY_STATUS, val, status); } -int bt_mesh_cfg_relay_get(u16_t net_idx, u16_t addr, u8_t *status, - u8_t *transmit) +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) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_RELAY_GET, 0); struct bt_mesh_msg_ctx ctx = { @@ -738,8 +978,8 @@ done: return err; } -int bt_mesh_cfg_relay_set(u16_t net_idx, u16_t addr, u8_t new_relay, - u8_t new_transmit, u8_t *status, u8_t *transmit) +int bt_mesh_cfg_relay_set(uint16_t net_idx, uint16_t addr, uint8_t new_relay, + uint8_t new_transmit, uint8_t *status, uint8_t *transmit) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_RELAY_SET, 2); struct bt_mesh_msg_ctx ctx = { @@ -776,8 +1016,8 @@ done: return err; } -int bt_mesh_cfg_net_key_add(u16_t net_idx, u16_t addr, u16_t key_net_idx, - const u8_t net_key[16], u8_t *status) +int bt_mesh_cfg_net_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, + const uint8_t net_key[16], uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_NET_KEY_ADD, 18); struct bt_mesh_msg_ctx ctx = { @@ -819,9 +1059,85 @@ done: return err; } -int bt_mesh_cfg_app_key_add(u16_t net_idx, u16_t addr, u16_t key_net_idx, - u16_t key_app_idx, const u8_t app_key[16], - u8_t *status) +int bt_mesh_cfg_net_key_get(uint16_t net_idx, uint16_t addr, uint16_t *keys, + size_t *key_cnt) +{ + struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_NET_KEY_GET, 0); + struct bt_mesh_msg_ctx ctx = { + .net_idx = net_idx, + .app_idx = BT_MESH_KEY_DEV_REMOTE, + .addr = addr, + .send_ttl = BT_MESH_TTL_DEFAULT, + }; + struct net_key_list_param param = { + .keys = keys, + .key_cnt = key_cnt, + }; + int err; + + err = cli_prepare(¶m, OP_NET_KEY_LIST); + if (err) { + return err; + } + + bt_mesh_model_msg_init(msg, OP_NET_KEY_GET); + + err = bt_mesh_model_send(cli->model, &ctx, msg, NULL, NULL); + if (err) { + BT_ERR("model_send() failed (err %d)", err); + cli_reset(); + return err; + } + + os_mbuf_free_chain(msg); + return cli_wait(); +} + +int bt_mesh_cfg_net_key_del(uint16_t net_idx, uint16_t addr, + uint16_t key_net_idx, uint8_t *status) +{ + struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_NET_KEY_DEL, 2); + struct bt_mesh_msg_ctx ctx = { + .net_idx = net_idx, + .app_idx = BT_MESH_KEY_DEV_REMOTE, + .addr = addr, + .send_ttl = BT_MESH_TTL_DEFAULT, + }; + struct net_key_param param = { + .status = status, + .net_idx = key_net_idx, + }; + int err; + + err = cli_prepare(¶m, OP_NET_KEY_STATUS); + if (err) { + goto done; + } + + bt_mesh_model_msg_init(msg, OP_NET_KEY_DEL); + net_buf_simple_add_le16(msg, key_net_idx); + + err = bt_mesh_model_send(cli->model, &ctx, msg, NULL, NULL); + if (err) { + BT_ERR("model_send() failed (err %d)", err); + cli_reset(); + goto done; + } + + if (!status) { + cli_reset(); + goto done; + } + + err = cli_wait(); +done: + os_mbuf_free_chain(msg); + return err; +} + +int bt_mesh_cfg_app_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, + uint16_t key_app_idx, const uint8_t app_key[16], + uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_APP_KEY_ADD, 19); struct bt_mesh_msg_ctx ctx = { @@ -864,9 +1180,137 @@ done: return err; } -static int mod_app_bind(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_app_idx, u16_t mod_id, u16_t cid, - u8_t *status) +int bt_mesh_cfg_node_reset(uint16_t net_idx, uint16_t addr, bool *status) +{ + struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_NODE_RESET, 0); + struct bt_mesh_msg_ctx ctx = { + .net_idx = net_idx, + .app_idx = BT_MESH_KEY_DEV_REMOTE, + .addr = addr, + .send_ttl = BT_MESH_TTL_DEFAULT, + }; + + int err; + + if (status) { + *status = false; + } + + err = cli_prepare(status, OP_NODE_RESET_STATUS); + if (err) { + goto done; + } + + bt_mesh_model_msg_init(msg, OP_NODE_RESET); + + err = bt_mesh_model_send(cli->model, &ctx, msg, NULL, NULL); + if (err) { + BT_ERR("model_send() failed (err %d)", err); + cli_reset(); + goto done; + } + + if (!status) { + cli_reset(); + goto done; + } + + err = cli_wait(); +done: + os_mbuf_free_chain(msg); + if (err) { + return err; + } else { + return 0; + } +} + +int bt_mesh_cfg_app_key_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, + uint8_t *status, uint16_t *keys, size_t *key_cnt) +{ + struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_APP_KEY_GET, 2); + struct bt_mesh_msg_ctx ctx = { + .net_idx = net_idx, + .app_idx = BT_MESH_KEY_DEV_REMOTE, + .addr = addr, + .send_ttl = BT_MESH_TTL_DEFAULT, + }; + struct app_key_list_param param = { + .net_idx = key_net_idx, + .status = status, + .keys = keys, + .key_cnt = key_cnt, + }; + int err; + + err = cli_prepare(¶m, OP_APP_KEY_LIST); + if (err) { + os_mbuf_free_chain(msg); + return err; + } + + bt_mesh_model_msg_init(msg, OP_APP_KEY_GET); + net_buf_simple_add_le16(msg, key_net_idx); + + err = bt_mesh_model_send(cli->model, &ctx, msg, NULL, NULL); + if (err) { + BT_ERR("model_send() failed (err %d)", err); + os_mbuf_free_chain(msg); + cli_reset(); + return err; + } + + os_mbuf_free_chain(msg); + return cli_wait(); +} + +int bt_mesh_cfg_app_key_del(uint16_t net_idx, uint16_t addr, + uint16_t key_net_idx, uint16_t key_app_idx, uint8_t *status) +{ + struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_APP_KEY_DEL, 3); + struct bt_mesh_msg_ctx ctx = { + .net_idx = net_idx, + .app_idx = BT_MESH_KEY_DEV_REMOTE, + .addr = addr, + .send_ttl = BT_MESH_TTL_DEFAULT, + }; + struct app_key_param param = { + .status = status, + .net_idx = key_net_idx, + .app_idx = key_app_idx, + }; + int err; + + err = cli_prepare(¶m, OP_APP_KEY_STATUS); + if (err) { + os_mbuf_free_chain(msg); + return err; + } + + bt_mesh_model_msg_init(msg, OP_APP_KEY_DEL); + key_idx_pack(msg, key_net_idx, key_app_idx); + + err = bt_mesh_model_send(cli->model, &ctx, msg, NULL, NULL); + if (err) { + BT_ERR("model_send() failed (err %d)", err); + os_mbuf_free_chain(msg); + cli_reset(); + return err; + } + + if (!status) { + cli_reset(); + os_mbuf_free_chain(msg); + return 0; + } + + os_mbuf_free_chain(msg); + return cli_wait(); +} + +static int mod_app_bind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid, + uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_MOD_APP_BIND, 8); struct bt_mesh_msg_ctx ctx = { @@ -917,16 +1361,16 @@ done: return err; } -int bt_mesh_cfg_mod_app_bind(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_app_idx, u16_t mod_id, u8_t *status) +int bt_mesh_cfg_mod_app_bind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_app_idx, uint16_t mod_id, uint8_t *status) { return mod_app_bind(net_idx, addr, elem_addr, mod_app_idx, mod_id, CID_NVAL, status); } -int bt_mesh_cfg_mod_app_bind_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_app_idx, u16_t mod_id, u16_t cid, - u8_t *status) +int bt_mesh_cfg_mod_app_bind_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid, + uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -936,8 +1380,160 @@ int bt_mesh_cfg_mod_app_bind_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, status); } -static int mod_sub(u32_t op, u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u16_t cid, u8_t *status) +static int mod_app_unbind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid, + uint8_t *status) +{ + struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_MOD_APP_UNBIND, 8); + struct bt_mesh_msg_ctx ctx = { + .net_idx = net_idx, + .app_idx = BT_MESH_KEY_DEV_REMOTE, + .addr = addr, + .send_ttl = BT_MESH_TTL_DEFAULT, + }; + struct mod_app_param param = { + .status = status, + .elem_addr = elem_addr, + .mod_app_idx = mod_app_idx, + .mod_id = mod_id, + .cid = cid, + }; + int err; + + err = cli_prepare(¶m, OP_MOD_APP_STATUS); + if (err) { + goto done; + } + + bt_mesh_model_msg_init(msg, OP_MOD_APP_UNBIND); + net_buf_simple_add_le16(msg, elem_addr); + net_buf_simple_add_le16(msg, mod_app_idx); + + if (cid != CID_NVAL) { + net_buf_simple_add_le16(msg, cid); + } + + net_buf_simple_add_le16(msg, mod_id); + + err = bt_mesh_model_send(cli->model, &ctx, msg, NULL, NULL); + if (err) { + BT_ERR("model_send() failed (err %d)", err); + cli_reset(); + goto done; + } + + if (!status) { + cli_reset(); + err = 0; + goto done; + } + +done: + os_mbuf_free_chain(msg); + if (err) { + return err; + } else { + return cli_wait(); + } +} + +int bt_mesh_cfg_mod_app_unbind(uint16_t net_idx, uint16_t addr, + uint16_t elem_addr, uint16_t mod_app_idx, + uint16_t mod_id, uint8_t *status) +{ + return mod_app_unbind(net_idx, addr, elem_addr, mod_app_idx, mod_id, + CID_NVAL, status); +} + +int bt_mesh_cfg_mod_app_unbind_vnd(uint16_t net_idx, uint16_t addr, + uint16_t elem_addr, uint16_t mod_app_idx, + uint16_t mod_id, uint16_t cid, uint8_t *status) +{ + if (cid == CID_NVAL) { + return -EINVAL; + } + + return mod_app_unbind(net_idx, addr, elem_addr, mod_app_idx, + mod_id, cid, status); +} + +static int mod_member_list_get(uint32_t op, uint32_t expect_op, uint16_t net_idx, + uint16_t addr, uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint8_t *status, uint16_t *apps, + size_t *app_cnt) +{ + struct os_mbuf *msg = BT_MESH_MODEL_BUF(DUMMY_2_BYTE_OP, 6); + struct bt_mesh_msg_ctx ctx = { + .net_idx = net_idx, + .app_idx = BT_MESH_KEY_DEV_REMOTE, + .addr = addr, + .send_ttl = BT_MESH_TTL_DEFAULT, + }; + struct mod_member_list_param param = { + .status = status, + .elem_addr = elem_addr, + .mod_id = mod_id, + .cid = cid, + .members = apps, + .member_cnt = app_cnt, + }; + int err; + + err = cli_prepare(¶m, expect_op); + if (err) { + goto done; + } + + BT_DBG("net_idx 0x%04x addr 0x%04x elem_addr 0x%04x", + net_idx, addr, elem_addr); + BT_DBG("mod_id 0x%04x cid 0x%04x op: %x", mod_id, cid, op); + + bt_mesh_model_msg_init(msg, op); + net_buf_simple_add_le16(msg, elem_addr); + + if (cid != CID_NVAL) { + net_buf_simple_add_le16(msg, cid); + } + + net_buf_simple_add_le16(msg, mod_id); + + err = bt_mesh_model_send(cli->model, &ctx, msg, NULL, NULL); + if (err) { + BT_ERR("model_send() failed (err %d)", err); + cli_reset(); + goto done; + } + + err = cli_wait(); +done: + os_mbuf_free_chain(msg); + return err; +} + +int bt_mesh_cfg_mod_app_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint8_t *status, uint16_t *apps, + size_t *app_cnt) +{ + return mod_member_list_get(OP_SIG_MOD_APP_GET, OP_SIG_MOD_APP_LIST, + net_idx, addr, elem_addr, mod_id, CID_NVAL, + status, apps, app_cnt); +} + +int bt_mesh_cfg_mod_app_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, uint8_t *status, + uint16_t *apps, size_t *app_cnt) +{ + if (cid == CID_NVAL) { + return -EINVAL; + } + + return mod_member_list_get(OP_VND_MOD_APP_GET, OP_VND_MOD_APP_LIST, + net_idx, addr, elem_addr, mod_id, CID_NVAL, + status, apps, app_cnt); +} + +static int mod_sub(uint32_t op, uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint16_t cid, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(DUMMY_2_BYTE_OP, 8); struct bt_mesh_msg_ctx ctx = { @@ -979,6 +1575,7 @@ static int mod_sub(u32_t op, u16_t net_idx, u16_t addr, u16_t elem_addr, if (!status) { cli_reset(); + err = 0; goto done; } @@ -988,16 +1585,16 @@ done: return err; } -int bt_mesh_cfg_mod_sub_add(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u8_t *status) +int bt_mesh_cfg_mod_sub_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint8_t *status) { return mod_sub(OP_MOD_SUB_ADD, net_idx, addr, elem_addr, sub_addr, mod_id, CID_NVAL, status); } -int bt_mesh_cfg_mod_sub_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u16_t cid, - u8_t *status) +int bt_mesh_cfg_mod_sub_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint16_t cid, + uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1007,16 +1604,16 @@ int bt_mesh_cfg_mod_sub_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, mod_id, cid, status); } -int bt_mesh_cfg_mod_sub_del(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u8_t *status) +int bt_mesh_cfg_mod_sub_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint8_t *status) { return mod_sub(OP_MOD_SUB_DEL, net_idx, addr, elem_addr, sub_addr, mod_id, CID_NVAL, status); } -int bt_mesh_cfg_mod_sub_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u16_t cid, - u8_t *status) +int bt_mesh_cfg_mod_sub_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint16_t cid, + uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1026,16 +1623,16 @@ int bt_mesh_cfg_mod_sub_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, mod_id, cid, status); } -int bt_mesh_cfg_mod_sub_overwrite(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u8_t *status) +int bt_mesh_cfg_mod_sub_overwrite(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint8_t *status) { return mod_sub(OP_MOD_SUB_OVERWRITE, net_idx, addr, elem_addr, sub_addr, mod_id, CID_NVAL, status); } -int bt_mesh_cfg_mod_sub_overwrite_vnd(u16_t net_idx, u16_t addr, - u16_t elem_addr, u16_t sub_addr, - u16_t mod_id, u16_t cid, u8_t *status) +int bt_mesh_cfg_mod_sub_overwrite_vnd(uint16_t net_idx, uint16_t addr, + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1045,9 +1642,9 @@ int bt_mesh_cfg_mod_sub_overwrite_vnd(u16_t net_idx, u16_t addr, sub_addr, mod_id, cid, status); } -static int mod_sub_va(u32_t op, u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, u16_t cid, - u16_t *virt_addr, u8_t *status) +static int mod_sub_va(uint32_t op, uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, uint16_t cid, + uint16_t *virt_addr, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(DUMMY_2_BYTE_OP, 22); struct bt_mesh_msg_ctx ctx = { @@ -1102,17 +1699,17 @@ done: return err; } -int bt_mesh_cfg_mod_sub_va_add(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t *virt_addr, u8_t *status) +int bt_mesh_cfg_mod_sub_va_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t *virt_addr, uint8_t *status) { return mod_sub_va(OP_MOD_SUB_VA_ADD, net_idx, addr, elem_addr, label, mod_id, CID_NVAL, virt_addr, status); } -int bt_mesh_cfg_mod_sub_va_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t cid, u16_t *virt_addr, u8_t *status) +int bt_mesh_cfg_mod_sub_va_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t cid, uint16_t *virt_addr, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1122,17 +1719,17 @@ int bt_mesh_cfg_mod_sub_va_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, mod_id, cid, virt_addr, status); } -int bt_mesh_cfg_mod_sub_va_del(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t *virt_addr, u8_t *status) +int bt_mesh_cfg_mod_sub_va_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t *virt_addr, uint8_t *status) { return mod_sub_va(OP_MOD_SUB_VA_DEL, net_idx, addr, elem_addr, label, mod_id, CID_NVAL, virt_addr, status); } -int bt_mesh_cfg_mod_sub_va_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t cid, u16_t *virt_addr, u8_t *status) +int bt_mesh_cfg_mod_sub_va_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t cid, uint16_t *virt_addr, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1142,19 +1739,19 @@ int bt_mesh_cfg_mod_sub_va_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, mod_id, cid, virt_addr, status); } -int bt_mesh_cfg_mod_sub_va_overwrite(u16_t net_idx, u16_t addr, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t *virt_addr, - u8_t *status) +int bt_mesh_cfg_mod_sub_va_overwrite(uint16_t net_idx, uint16_t addr, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t *virt_addr, + uint8_t *status) { return mod_sub_va(OP_MOD_SUB_VA_OVERWRITE, net_idx, addr, elem_addr, label, mod_id, CID_NVAL, virt_addr, status); } -int bt_mesh_cfg_mod_sub_va_overwrite_vnd(u16_t net_idx, u16_t addr, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t cid, - u16_t *virt_addr, u8_t *status) +int bt_mesh_cfg_mod_sub_va_overwrite_vnd(uint16_t net_idx, uint16_t addr, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid, + uint16_t *virt_addr, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1164,9 +1761,31 @@ int bt_mesh_cfg_mod_sub_va_overwrite_vnd(u16_t net_idx, u16_t addr, label, mod_id, cid, virt_addr, status); } -static int mod_pub_get(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, - struct bt_mesh_cfg_mod_pub *pub, u8_t *status) +int bt_mesh_cfg_mod_sub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint8_t *status, uint16_t *subs, + size_t *sub_cnt) +{ + return mod_member_list_get(OP_MOD_SUB_GET, OP_MOD_SUB_LIST, net_idx, + addr, elem_addr, mod_id, CID_NVAL, status, + subs, sub_cnt); +} + +int bt_mesh_cfg_mod_sub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, uint8_t *status, + uint16_t *subs, size_t *sub_cnt) +{ + if (cid == CID_NVAL) { + return -EINVAL; + } + + return mod_member_list_get(OP_MOD_SUB_GET_VND, OP_MOD_SUB_LIST_VND, + net_idx, addr, elem_addr, mod_id, CID_NVAL, + status, subs, sub_cnt); +} + +static int mod_pub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_MOD_PUB_GET, 6); struct bt_mesh_msg_ctx ctx = { @@ -1217,17 +1836,17 @@ done: return err; } -int bt_mesh_cfg_mod_pub_get(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, - u8_t *status) +int bt_mesh_cfg_mod_pub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, + uint8_t *status) { return mod_pub_get(net_idx, addr, elem_addr, mod_id, CID_NVAL, pub, status); } -int bt_mesh_cfg_mod_pub_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, - struct bt_mesh_cfg_mod_pub *pub, u8_t *status) +int bt_mesh_cfg_mod_pub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1236,9 +1855,9 @@ int bt_mesh_cfg_mod_pub_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, return mod_pub_get(net_idx, addr, elem_addr, mod_id, cid, pub, status); } -static int mod_pub_set(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, - struct bt_mesh_cfg_mod_pub *pub, u8_t *status) +static int mod_pub_set(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_MOD_PUB_SET, 13); struct bt_mesh_msg_ctx ctx = { @@ -1265,7 +1884,7 @@ static int mod_pub_set(u16_t net_idx, u16_t addr, u16_t elem_addr, net_buf_simple_add_le16(msg, elem_addr); net_buf_simple_add_le16(msg, pub->addr); - net_buf_simple_add_le16(msg, (pub->app_idx | (pub->cred_flag << 12))); + net_buf_simple_add_le16(msg, (pub->app_idx & (pub->cred_flag << 12))); net_buf_simple_add_u8(msg, pub->ttl); net_buf_simple_add_u8(msg, pub->period); net_buf_simple_add_u8(msg, pub->transmit); @@ -1294,17 +1913,17 @@ done: return err; } -int bt_mesh_cfg_mod_pub_set(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, - u8_t *status) +int bt_mesh_cfg_mod_pub_set(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, + uint8_t *status) { return mod_pub_set(net_idx, addr, elem_addr, mod_id, CID_NVAL, pub, status); } -int bt_mesh_cfg_mod_pub_set_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, - struct bt_mesh_cfg_mod_pub *pub, u8_t *status) +int bt_mesh_cfg_mod_pub_set_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1313,8 +1932,8 @@ int bt_mesh_cfg_mod_pub_set_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, return mod_pub_set(net_idx, addr, elem_addr, mod_id, cid, pub, status); } -int bt_mesh_cfg_hb_sub_set(u16_t net_idx, u16_t addr, - struct bt_mesh_cfg_hb_sub *sub, u8_t *status) +int bt_mesh_cfg_hb_sub_set(uint16_t net_idx, uint16_t addr, + struct bt_mesh_cfg_hb_sub *sub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEARTBEAT_SUB_SET, 5); struct bt_mesh_msg_ctx ctx = { @@ -1357,8 +1976,8 @@ done: return err; } -int bt_mesh_cfg_hb_sub_get(u16_t net_idx, u16_t addr, - struct bt_mesh_cfg_hb_sub *sub, u8_t *status) +int bt_mesh_cfg_hb_sub_get(uint16_t net_idx, uint16_t addr, + struct bt_mesh_cfg_hb_sub *sub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEARTBEAT_SUB_GET, 0); struct bt_mesh_msg_ctx ctx = { @@ -1398,8 +2017,8 @@ done: return err; } -int bt_mesh_cfg_hb_pub_set(u16_t net_idx, u16_t addr, - const struct bt_mesh_cfg_hb_pub *pub, u8_t *status) +int bt_mesh_cfg_hb_pub_set(uint16_t net_idx, uint16_t addr, + const struct bt_mesh_cfg_hb_pub *pub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEARTBEAT_PUB_SET, 9); struct bt_mesh_msg_ctx ctx = { @@ -1444,8 +2063,8 @@ done: return err; } -int bt_mesh_cfg_hb_pub_get(u16_t net_idx, u16_t addr, - struct bt_mesh_cfg_hb_pub *pub, u8_t *status) +int bt_mesh_cfg_hb_pub_get(uint16_t net_idx, uint16_t addr, + struct bt_mesh_cfg_hb_pub *pub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEARTBEAT_PUB_GET, 0); struct bt_mesh_msg_ctx ctx = { @@ -1485,12 +2104,12 @@ done: return err; } -s32_t bt_mesh_cfg_cli_timeout_get(void) +int32_t bt_mesh_cfg_cli_timeout_get(void) { return msg_timeout; } -void bt_mesh_cfg_cli_timeout_set(s32_t timeout) +void bt_mesh_cfg_cli_timeout_set(int32_t timeout) { msg_timeout = timeout; } |
