|
@@ -11,30 +11,23 @@
|
|
|
#include <errno.h>
|
|
#include <errno.h>
|
|
|
#include <stdbool.h>
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
-#include "sdkconfig.h"
|
|
|
|
|
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL)
|
|
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL)
|
|
|
|
|
|
|
|
-#include "mesh_types.h"
|
|
|
|
|
-#include "mesh_util.h"
|
|
|
|
|
-#include "mesh_main.h"
|
|
|
|
|
-#include "mesh_trace.h"
|
|
|
|
|
-#include "cfg_srv.h"
|
|
|
|
|
-#include "settings.h"
|
|
|
|
|
-
|
|
|
|
|
#include "mesh.h"
|
|
#include "mesh.h"
|
|
|
#include "adv.h"
|
|
#include "adv.h"
|
|
|
-#include "net.h"
|
|
|
|
|
#include "lpn.h"
|
|
#include "lpn.h"
|
|
|
#include "transport.h"
|
|
#include "transport.h"
|
|
|
#include "crypto.h"
|
|
#include "crypto.h"
|
|
|
#include "access.h"
|
|
#include "access.h"
|
|
|
#include "beacon.h"
|
|
#include "beacon.h"
|
|
|
-#include "proxy_server.h"
|
|
|
|
|
#include "foundation.h"
|
|
#include "foundation.h"
|
|
|
#include "friend.h"
|
|
#include "friend.h"
|
|
|
#include "settings.h"
|
|
#include "settings.h"
|
|
|
-
|
|
|
|
|
|
|
+#include "cfg_srv.h"
|
|
|
|
|
+#include "proxy_server.h"
|
|
|
|
|
+#include "mesh_main.h"
|
|
|
#include "mesh_common.h"
|
|
#include "mesh_common.h"
|
|
|
|
|
+
|
|
|
#include "btc_ble_mesh_config_model.h"
|
|
#include "btc_ble_mesh_config_model.h"
|
|
|
|
|
|
|
|
#define DEFAULT_TTL 7
|
|
#define DEFAULT_TTL 7
|
|
@@ -52,7 +45,7 @@ static struct label labels[CONFIG_BLE_MESH_LABEL_COUNT];
|
|
|
static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem,
|
|
static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem,
|
|
|
bool primary)
|
|
bool primary)
|
|
|
{
|
|
{
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
if (net_buf_simple_tailroom(buf) <
|
|
if (net_buf_simple_tailroom(buf) <
|
|
@@ -83,7 +76,7 @@ static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem,
|
|
|
static int comp_get_page_0(struct net_buf_simple *buf)
|
|
static int comp_get_page_0(struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
u16_t feat = 0U;
|
|
u16_t feat = 0U;
|
|
|
- const struct bt_mesh_comp *comp;
|
|
|
|
|
|
|
+ const struct bt_mesh_comp *comp = NULL;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
comp = bt_mesh_comp_get();
|
|
comp = bt_mesh_comp_get();
|
|
@@ -127,7 +120,7 @@ static void dev_comp_data_get(struct bt_mesh_model *model,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
struct net_buf_simple *sdu = NULL;
|
|
struct net_buf_simple *sdu = NULL;
|
|
|
- u8_t page;
|
|
|
|
|
|
|
+ u8_t page = 0U;
|
|
|
|
|
|
|
|
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
|
|
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->len,
|
|
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
|
@@ -166,7 +159,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
|
|
|
struct net_buf_simple *buf, bool *vnd)
|
|
struct net_buf_simple *buf, bool *vnd)
|
|
|
{
|
|
{
|
|
|
if (buf->len < 4) {
|
|
if (buf->len < 4) {
|
|
|
- u16_t id;
|
|
|
|
|
|
|
+ u16_t id = 0U;
|
|
|
|
|
|
|
|
id = net_buf_simple_pull_le16(buf);
|
|
id = net_buf_simple_pull_le16(buf);
|
|
|
|
|
|
|
@@ -176,7 +169,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
|
|
|
|
|
|
|
|
return bt_mesh_model_find(elem, id);
|
|
return bt_mesh_model_find(elem, id);
|
|
|
} else {
|
|
} else {
|
|
|
- u16_t company, id;
|
|
|
|
|
|
|
+ u16_t company = 0U, id = 0U;
|
|
|
|
|
|
|
|
company = net_buf_simple_pull_le16(buf);
|
|
company = net_buf_simple_pull_le16(buf);
|
|
|
id = net_buf_simple_pull_le16(buf);
|
|
id = net_buf_simple_pull_le16(buf);
|
|
@@ -357,9 +350,9 @@ struct bt_mesh_app_key *bt_mesh_app_key_alloc(u16_t app_idx)
|
|
|
static u8_t app_key_set(u16_t net_idx, u16_t app_idx, const u8_t val[16],
|
|
static u8_t app_key_set(u16_t net_idx, u16_t app_idx, const u8_t val[16],
|
|
|
bool update)
|
|
bool update)
|
|
|
{
|
|
{
|
|
|
- struct bt_mesh_app_keys *keys;
|
|
|
|
|
- struct bt_mesh_app_key *key;
|
|
|
|
|
- struct bt_mesh_subnet *sub;
|
|
|
|
|
|
|
+ struct bt_mesh_app_keys *keys = NULL;
|
|
|
|
|
+ struct bt_mesh_app_key *key = NULL;
|
|
|
|
|
+ struct bt_mesh_subnet *sub = NULL;
|
|
|
|
|
|
|
|
BT_DBG("net_idx 0x%04x app_idx %04x update %u val %s",
|
|
BT_DBG("net_idx 0x%04x app_idx %04x update %u val %s",
|
|
|
net_idx, app_idx, update, bt_hex(val, 16));
|
|
net_idx, app_idx, update, bt_hex(val, 16));
|
|
@@ -448,8 +441,8 @@ static void app_key_add(struct bt_mesh_model *model,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
|
|
|
- u16_t key_net_idx, key_app_idx;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
|
|
+ u16_t key_net_idx = 0U, key_app_idx = 0U;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
|
|
|
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
|
|
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
|
|
|
|
|
|
|
@@ -483,8 +476,8 @@ static void app_key_update(struct bt_mesh_model *model,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
|
|
|
- u16_t key_net_idx, key_app_idx;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
|
|
+ u16_t key_net_idx = 0U, key_app_idx = 0U;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
|
|
|
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
|
|
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
|
|
|
|
|
|
|
@@ -546,9 +539,9 @@ static void app_key_del(struct bt_mesh_model *model,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
|
|
|
- u16_t key_net_idx, key_app_idx;
|
|
|
|
|
- struct bt_mesh_app_key *key;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
|
|
+ u16_t key_net_idx = 0U, key_app_idx = 0U;
|
|
|
|
|
+ struct bt_mesh_app_key *key = NULL;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
|
|
|
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
|
|
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
|
|
|
|
|
|
|
@@ -605,8 +598,8 @@ static void app_key_get(struct bt_mesh_model *model,
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_LIST,
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_LIST,
|
|
|
3 + IDX_LEN(CONFIG_BLE_MESH_APP_KEY_COUNT));
|
|
3 + IDX_LEN(CONFIG_BLE_MESH_APP_KEY_COUNT));
|
|
|
- u16_t get_idx, i, prev;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
|
|
+ u16_t get_idx = 0U, i = 0U, prev = 0U;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
|
|
|
get_idx = net_buf_simple_pull_le16(buf);
|
|
get_idx = net_buf_simple_pull_le16(buf);
|
|
|
if (get_idx > 0xfff) {
|
|
if (get_idx > 0xfff) {
|
|
@@ -697,13 +690,11 @@ static void beacon_set(struct bt_mesh_model *model,
|
|
|
bt_mesh_store_cfg();
|
|
bt_mesh_store_cfg();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#if CONFIG_BLE_MESH_NODE
|
|
|
|
|
if (cfg->beacon) {
|
|
if (cfg->beacon) {
|
|
|
bt_mesh_beacon_enable();
|
|
bt_mesh_beacon_enable();
|
|
|
} else {
|
|
} else {
|
|
|
bt_mesh_beacon_disable();
|
|
bt_mesh_beacon_disable();
|
|
|
}
|
|
}
|
|
|
-#endif
|
|
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
BT_WARN("Invalid Config Beacon value 0x%02x", buf->data[0]);
|
|
BT_WARN("Invalid Config Beacon value 0x%02x", buf->data[0]);
|
|
@@ -831,7 +822,6 @@ static void gatt_proxy_set(struct bt_mesh_model *model,
|
|
|
bt_mesh_store_cfg();
|
|
bt_mesh_store_cfg();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#if CONFIG_BLE_MESH_NODE
|
|
|
|
|
if (cfg->gatt_proxy == BLE_MESH_GATT_PROXY_DISABLED) {
|
|
if (cfg->gatt_proxy == BLE_MESH_GATT_PROXY_DISABLED) {
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
@@ -855,7 +845,6 @@ static void gatt_proxy_set(struct bt_mesh_model *model,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bt_mesh_adv_update();
|
|
bt_mesh_adv_update();
|
|
|
-#endif
|
|
|
|
|
|
|
|
|
|
if (cfg->hb_pub.feat & BLE_MESH_FEAT_PROXY) {
|
|
if (cfg->hb_pub.feat & BLE_MESH_FEAT_PROXY) {
|
|
|
bt_mesh_heartbeat_send();
|
|
bt_mesh_heartbeat_send();
|
|
@@ -1028,11 +1017,11 @@ static void mod_pub_get(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- u16_t elem_addr, pub_addr = 0U;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *mod_id, status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u16_t elem_addr = 0U, pub_addr = 0U;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL, status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -1075,12 +1064,12 @@ static void mod_pub_set(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- u8_t retransmit, status, pub_ttl, pub_period, cred_flag;
|
|
|
|
|
- u16_t elem_addr, pub_addr, pub_app_idx;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U;
|
|
|
|
|
+ u16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -1194,7 +1183,7 @@ static struct label *va_find(const u8_t *label_uuid,
|
|
|
|
|
|
|
|
static u8_t va_add(u8_t *label_uuid, u16_t *addr)
|
|
static u8_t va_add(u8_t *label_uuid, u16_t *addr)
|
|
|
{
|
|
{
|
|
|
- struct label *update, *free_slot = NULL;
|
|
|
|
|
|
|
+ struct label *update = NULL, *free_slot = NULL;
|
|
|
|
|
|
|
|
update = va_find(label_uuid, &free_slot);
|
|
update = va_find(label_uuid, &free_slot);
|
|
|
if (update) {
|
|
if (update) {
|
|
@@ -1221,7 +1210,7 @@ static u8_t va_add(u8_t *label_uuid, u16_t *addr)
|
|
|
|
|
|
|
|
static u8_t va_del(u8_t *label_uuid, u16_t *addr)
|
|
static u8_t va_del(u8_t *label_uuid, u16_t *addr)
|
|
|
{
|
|
{
|
|
|
- struct label *update;
|
|
|
|
|
|
|
+ struct label *update = NULL;
|
|
|
|
|
|
|
|
update = va_find(label_uuid, NULL);
|
|
update = va_find(label_uuid, NULL);
|
|
|
if (update) {
|
|
if (update) {
|
|
@@ -1244,8 +1233,8 @@ static u8_t va_del(u8_t *label_uuid, u16_t *addr)
|
|
|
|
|
|
|
|
static size_t mod_sub_list_clear(struct bt_mesh_model *mod)
|
|
static size_t mod_sub_list_clear(struct bt_mesh_model *mod)
|
|
|
{
|
|
{
|
|
|
- u8_t *label_uuid;
|
|
|
|
|
- size_t clear_count;
|
|
|
|
|
|
|
+ u8_t *label_uuid = NULL;
|
|
|
|
|
+ size_t clear_count = 0U;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
/* Unref stored labels related to this model */
|
|
/* Unref stored labels related to this model */
|
|
@@ -1278,13 +1267,13 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- u8_t retransmit, status, pub_ttl, pub_period, cred_flag;
|
|
|
|
|
- u16_t elem_addr, pub_addr, pub_app_idx;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *label_uuid;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U;
|
|
|
|
|
+ u16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *label_uuid = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -1342,7 +1331,7 @@ send_status:
|
|
|
#else
|
|
#else
|
|
|
static size_t mod_sub_list_clear(struct bt_mesh_model *mod)
|
|
static size_t mod_sub_list_clear(struct bt_mesh_model *mod)
|
|
|
{
|
|
{
|
|
|
- size_t clear_count;
|
|
|
|
|
|
|
+ size_t clear_count = 0U;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
/* Unref stored labels related to this model */
|
|
/* Unref stored labels related to this model */
|
|
@@ -1360,11 +1349,11 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- u8_t *mod_id, status;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u16_t elem_addr, pub_addr = 0U;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u8_t *mod_id = NULL, status = 0U;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u16_t elem_addr = 0U, pub_addr = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -1436,12 +1425,12 @@ static void mod_sub_add(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- u16_t elem_addr, sub_addr;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u16_t elem_addr = 0U, sub_addr = 0U;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
@@ -1522,13 +1511,13 @@ static void mod_sub_del(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- u16_t elem_addr, sub_addr;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- u16_t *match;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u16_t elem_addr = 0U, sub_addr = 0U;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ u16_t *match = NULL;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -1598,12 +1587,12 @@ static void mod_sub_overwrite(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- u16_t elem_addr, sub_addr;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u16_t elem_addr = 0U, sub_addr = 0U;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -1667,12 +1656,12 @@ static void mod_sub_del_all(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u16_t elem_addr;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u16_t elem_addr = 0U;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -1721,9 +1710,9 @@ static void mod_sub_get(struct bt_mesh_model *model,
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_LIST,
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_LIST,
|
|
|
5 + CONFIG_BLE_MESH_MODEL_GROUP_COUNT * 2);
|
|
5 + CONFIG_BLE_MESH_MODEL_GROUP_COUNT * 2);
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u16_t addr, id;
|
|
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u16_t addr = 0U, id = 0U;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
addr = net_buf_simple_pull_le16(buf);
|
|
addr = net_buf_simple_pull_le16(buf);
|
|
@@ -1777,9 +1766,9 @@ static void mod_sub_get_vnd(struct bt_mesh_model *model,
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_LIST_VND,
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_LIST_VND,
|
|
|
7 + CONFIG_BLE_MESH_MODEL_GROUP_COUNT * 2);
|
|
7 + CONFIG_BLE_MESH_MODEL_GROUP_COUNT * 2);
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u16_t company, addr, id;
|
|
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u16_t company = 0U, addr = 0U, id = 0U;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
addr = net_buf_simple_pull_le16(buf);
|
|
addr = net_buf_simple_pull_le16(buf);
|
|
@@ -1836,13 +1825,13 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- u16_t elem_addr, sub_addr;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *label_uuid;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u16_t elem_addr = 0U, sub_addr = 0U;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *label_uuid = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
@@ -1913,14 +1902,14 @@ static void mod_sub_va_del(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- u16_t elem_addr, sub_addr;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *label_uuid;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- u16_t *match;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u16_t elem_addr = 0U, sub_addr = 0U;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *label_uuid = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ u16_t *match = NULL;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -1981,13 +1970,13 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- u16_t elem_addr, sub_addr = BLE_MESH_ADDR_UNASSIGNED;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *label_uuid;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u16_t elem_addr = 0U, sub_addr = BLE_MESH_ADDR_UNASSIGNED;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *label_uuid = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -2047,12 +2036,12 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u16_t elem_addr;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u16_t elem_addr = 0U;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -2089,11 +2078,11 @@ static void mod_sub_va_del(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u16_t elem_addr;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u16_t elem_addr = 0U;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -2128,11 +2117,11 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u16_t elem_addr;
|
|
|
|
|
- u8_t *mod_id;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u16_t elem_addr = 0U;
|
|
|
|
|
+ u8_t *mod_id = NULL;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -2184,9 +2173,9 @@ static void net_key_add(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- struct bt_mesh_subnet *sub;
|
|
|
|
|
- u16_t idx;
|
|
|
|
|
- int err;
|
|
|
|
|
|
|
+ struct bt_mesh_subnet *sub = NULL;
|
|
|
|
|
+ u16_t idx = 0U;
|
|
|
|
|
+ int err = 0;
|
|
|
|
|
|
|
|
idx = net_buf_simple_pull_le16(buf);
|
|
idx = net_buf_simple_pull_le16(buf);
|
|
|
if (idx > 0xfff) {
|
|
if (idx > 0xfff) {
|
|
@@ -2216,7 +2205,7 @@ static void net_key_add(struct bt_mesh_model *model,
|
|
|
|
|
|
|
|
/* Check for already existing subnet */
|
|
/* Check for already existing subnet */
|
|
|
if (sub->net_idx == idx) {
|
|
if (sub->net_idx == idx) {
|
|
|
- u8_t status;
|
|
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
|
|
|
if (memcmp(buf->data, sub->keys[0].net, 16)) {
|
|
if (memcmp(buf->data, sub->keys[0].net, 16)) {
|
|
|
status = STATUS_IDX_ALREADY_STORED;
|
|
status = STATUS_IDX_ALREADY_STORED;
|
|
@@ -2246,10 +2235,8 @@ static void net_key_add(struct bt_mesh_model *model,
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
|
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
|
|
sub->node_id = BLE_MESH_NODE_IDENTITY_STOPPED;
|
|
sub->node_id = BLE_MESH_NODE_IDENTITY_STOPPED;
|
|
|
-#if CONFIG_BLE_MESH_NODE
|
|
|
|
|
bt_mesh_proxy_beacon_send(sub);
|
|
bt_mesh_proxy_beacon_send(sub);
|
|
|
bt_mesh_adv_update();
|
|
bt_mesh_adv_update();
|
|
|
-#endif
|
|
|
|
|
} else {
|
|
} else {
|
|
|
sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED;
|
|
sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED;
|
|
|
}
|
|
}
|
|
@@ -2267,9 +2254,9 @@ static void net_key_update(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- struct bt_mesh_subnet *sub;
|
|
|
|
|
- u16_t idx;
|
|
|
|
|
- int err;
|
|
|
|
|
|
|
+ struct bt_mesh_subnet *sub = NULL;
|
|
|
|
|
+ u16_t idx = 0U;
|
|
|
|
|
+ int err = 0;
|
|
|
|
|
|
|
|
idx = net_buf_simple_pull_le16(buf);
|
|
idx = net_buf_simple_pull_le16(buf);
|
|
|
if (idx > 0xfff) {
|
|
if (idx > 0xfff) {
|
|
@@ -2354,9 +2341,9 @@ static void net_key_del(struct bt_mesh_model *model,
|
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- struct bt_mesh_subnet *sub;
|
|
|
|
|
- u16_t del_idx;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
|
|
+ struct bt_mesh_subnet *sub = NULL;
|
|
|
|
|
+ u16_t del_idx = 0U;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
|
|
|
del_idx = net_buf_simple_pull_le16(buf);
|
|
del_idx = net_buf_simple_pull_le16(buf);
|
|
|
if (del_idx > 0xfff) {
|
|
if (del_idx > 0xfff) {
|
|
@@ -2403,7 +2390,7 @@ static void net_key_get(struct bt_mesh_model *model,
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_LIST,
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_LIST,
|
|
|
IDX_LEN(CONFIG_BLE_MESH_SUBNET_COUNT));
|
|
IDX_LEN(CONFIG_BLE_MESH_SUBNET_COUNT));
|
|
|
- u16_t prev, i;
|
|
|
|
|
|
|
+ u16_t prev = 0U, i = 0U;
|
|
|
|
|
|
|
|
bt_mesh_model_msg_init(&msg, OP_NET_KEY_LIST);
|
|
bt_mesh_model_msg_init(&msg, OP_NET_KEY_LIST);
|
|
|
|
|
|
|
@@ -2438,9 +2425,9 @@ static void node_identity_get(struct bt_mesh_model *model,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_STATUS, 4);
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_STATUS, 4);
|
|
|
- struct bt_mesh_subnet *sub;
|
|
|
|
|
- u8_t node_id;
|
|
|
|
|
- u16_t idx;
|
|
|
|
|
|
|
+ struct bt_mesh_subnet *sub = NULL;
|
|
|
|
|
+ u8_t node_id = 0U;
|
|
|
|
|
+ u16_t idx = 0U;
|
|
|
|
|
|
|
|
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
|
|
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->len,
|
|
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
|
@@ -2476,9 +2463,9 @@ static void node_identity_set(struct bt_mesh_model *model,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_STATUS, 4);
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_STATUS, 4);
|
|
|
- struct bt_mesh_subnet *sub;
|
|
|
|
|
- u8_t node_id;
|
|
|
|
|
- u16_t idx;
|
|
|
|
|
|
|
+ struct bt_mesh_subnet *sub = NULL;
|
|
|
|
|
+ u8_t node_id = 0U;
|
|
|
|
|
+ u16_t idx = 0U;
|
|
|
|
|
|
|
|
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
|
|
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->len,
|
|
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
|
@@ -2506,7 +2493,6 @@ static void node_identity_set(struct bt_mesh_model *model,
|
|
|
} else {
|
|
} else {
|
|
|
net_buf_simple_add_u8(&msg, STATUS_SUCCESS);
|
|
net_buf_simple_add_u8(&msg, STATUS_SUCCESS);
|
|
|
net_buf_simple_add_le16(&msg, idx);
|
|
net_buf_simple_add_le16(&msg, idx);
|
|
|
-#if CONFIG_BLE_MESH_NODE
|
|
|
|
|
/* Section 4.2.11.1: "When the GATT Proxy state is set to
|
|
/* Section 4.2.11.1: "When the GATT Proxy state is set to
|
|
|
* 0x00, the Node Identity state for all subnets shall be set
|
|
* 0x00, the Node Identity state for all subnets shall be set
|
|
|
* to 0x00 and shall not be changed."
|
|
* to 0x00 and shall not be changed."
|
|
@@ -2520,7 +2506,6 @@ static void node_identity_set(struct bt_mesh_model *model,
|
|
|
}
|
|
}
|
|
|
bt_mesh_adv_update();
|
|
bt_mesh_adv_update();
|
|
|
}
|
|
}
|
|
|
-#endif
|
|
|
|
|
net_buf_simple_add_u8(&msg, sub->node_id);
|
|
net_buf_simple_add_u8(&msg, sub->node_id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2552,11 +2537,11 @@ static void mod_app_bind(struct bt_mesh_model *model,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9);
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9);
|
|
|
- u16_t elem_addr, key_app_idx;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *mod_id, status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u16_t elem_addr = 0U, key_app_idx = 0U;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL, status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -2615,11 +2600,11 @@ static void mod_app_unbind(struct bt_mesh_model *model,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9);
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9);
|
|
|
- u16_t elem_addr, key_app_idx;
|
|
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *mod_id, status;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ u16_t elem_addr = 0U, key_app_idx = 0U;
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL, status = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -2677,11 +2662,11 @@ static void mod_app_get(struct bt_mesh_model *model,
|
|
|
9 + KEY_LIST_LEN),
|
|
9 + KEY_LIST_LEN),
|
|
|
BLE_MESH_MODEL_BUF_LEN(OP_SIG_MOD_APP_LIST,
|
|
BLE_MESH_MODEL_BUF_LEN(OP_SIG_MOD_APP_LIST,
|
|
|
9 + KEY_LIST_LEN)));
|
|
9 + KEY_LIST_LEN)));
|
|
|
- struct bt_mesh_model *mod;
|
|
|
|
|
- struct bt_mesh_elem *elem;
|
|
|
|
|
- u8_t *mod_id, status;
|
|
|
|
|
- u16_t elem_addr;
|
|
|
|
|
- bool vnd;
|
|
|
|
|
|
|
+ struct bt_mesh_model *mod = NULL;
|
|
|
|
|
+ struct bt_mesh_elem *elem = NULL;
|
|
|
|
|
+ u8_t *mod_id = NULL, status = 0U;
|
|
|
|
|
+ u16_t elem_addr = 0U;
|
|
|
|
|
+ bool vnd = false;
|
|
|
|
|
|
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
elem_addr = net_buf_simple_pull_le16(buf);
|
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
|
@@ -2760,9 +2745,9 @@ static void node_reset(struct bt_mesh_model *model,
|
|
|
BT_ERR("%s, Unable to send Config Node Reset Status", __func__);
|
|
BT_ERR("%s, Unable to send Config Node Reset Status", __func__);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#if CONFIG_BLE_MESH_NODE
|
|
|
|
|
- bt_mesh_reset();
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
+ if (IS_ENABLED(CONFIG_BLE_MESH_NODE)) {
|
|
|
|
|
+ bt_mesh_reset();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void send_friend_status(struct bt_mesh_model *model,
|
|
static void send_friend_status(struct bt_mesh_model *model,
|
|
@@ -2841,9 +2826,9 @@ static void lpn_timeout_get(struct bt_mesh_model *model,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_LPN_TIMEOUT_STATUS, 5);
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_LPN_TIMEOUT_STATUS, 5);
|
|
|
- struct bt_mesh_friend *frnd;
|
|
|
|
|
- u16_t lpn_addr;
|
|
|
|
|
- s32_t timeout;
|
|
|
|
|
|
|
+ struct bt_mesh_friend *frnd = NULL;
|
|
|
|
|
+ u16_t lpn_addr = 0U;
|
|
|
|
|
+ s32_t timeout = 0;
|
|
|
|
|
|
|
|
lpn_addr = net_buf_simple_pull_le16(buf);
|
|
lpn_addr = net_buf_simple_pull_le16(buf);
|
|
|
|
|
|
|
@@ -2901,8 +2886,8 @@ static void send_krp_status(struct bt_mesh_model *model,
|
|
|
static void krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|
static void krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- struct bt_mesh_subnet *sub;
|
|
|
|
|
- u16_t idx;
|
|
|
|
|
|
|
+ struct bt_mesh_subnet *sub = NULL;
|
|
|
|
|
+ u16_t idx = 0U;
|
|
|
|
|
|
|
|
idx = net_buf_simple_pull_le16(buf);
|
|
idx = net_buf_simple_pull_le16(buf);
|
|
|
if (idx > 0xfff) {
|
|
if (idx > 0xfff) {
|
|
@@ -2924,9 +2909,9 @@ static void krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|
|
static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|
static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
- struct bt_mesh_subnet *sub;
|
|
|
|
|
- u8_t phase;
|
|
|
|
|
- u16_t idx;
|
|
|
|
|
|
|
+ struct bt_mesh_subnet *sub = NULL;
|
|
|
|
|
+ u8_t phase = 0U;
|
|
|
|
|
+ u16_t idx = 0U;
|
|
|
|
|
|
|
|
idx = net_buf_simple_pull_le16(buf);
|
|
idx = net_buf_simple_pull_le16(buf);
|
|
|
phase = net_buf_simple_pull_u8(buf);
|
|
phase = net_buf_simple_pull_u8(buf);
|
|
@@ -3071,8 +3056,8 @@ static void heartbeat_pub_set(struct bt_mesh_model *model,
|
|
|
{
|
|
{
|
|
|
struct hb_pub_param *param = (void *)buf->data;
|
|
struct hb_pub_param *param = (void *)buf->data;
|
|
|
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
|
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
|
|
- u16_t dst, feat, idx;
|
|
|
|
|
- u8_t status;
|
|
|
|
|
|
|
+ u16_t dst = 0U, feat = 0U, idx = 0U;
|
|
|
|
|
+ u8_t status = 0U;
|
|
|
|
|
|
|
|
BT_DBG("src 0x%04x", ctx->addr);
|
|
BT_DBG("src 0x%04x", ctx->addr);
|
|
|
|
|
|
|
@@ -3168,8 +3153,8 @@ static void hb_sub_send_status(struct bt_mesh_model *model,
|
|
|
{
|
|
{
|
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_SUB_STATUS, 9);
|
|
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_SUB_STATUS, 9);
|
|
|
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
|
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
|
|
- u16_t period;
|
|
|
|
|
- s64_t uptime;
|
|
|
|
|
|
|
+ u16_t period = 0U;
|
|
|
|
|
+ s64_t uptime = 0;
|
|
|
|
|
|
|
|
BT_DBG("src 0x%04x status 0x%02x", ctx->addr, status);
|
|
BT_DBG("src 0x%04x status 0x%02x", ctx->addr, status);
|
|
|
|
|
|
|
@@ -3209,9 +3194,9 @@ static void heartbeat_sub_set(struct bt_mesh_model *model,
|
|
|
struct net_buf_simple *buf)
|
|
struct net_buf_simple *buf)
|
|
|
{
|
|
{
|
|
|
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
|
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
|
|
- u16_t sub_src, sub_dst;
|
|
|
|
|
- u8_t sub_period;
|
|
|
|
|
- s32_t period_ms;
|
|
|
|
|
|
|
+ u16_t sub_src = 0U, sub_dst = 0U;
|
|
|
|
|
+ u8_t sub_period = 0U;
|
|
|
|
|
+ s32_t period_ms = 0;
|
|
|
|
|
|
|
|
BT_DBG("src 0x%04x", ctx->addr);
|
|
BT_DBG("src 0x%04x", ctx->addr);
|
|
|
|
|
|
|
@@ -3343,8 +3328,8 @@ static void hb_publish(struct k_work *work)
|
|
|
struct bt_mesh_cfg_srv *cfg = CONTAINER_OF(work,
|
|
struct bt_mesh_cfg_srv *cfg = CONTAINER_OF(work,
|
|
|
struct bt_mesh_cfg_srv,
|
|
struct bt_mesh_cfg_srv,
|
|
|
hb_pub.timer.work);
|
|
hb_pub.timer.work);
|
|
|
- struct bt_mesh_subnet *sub;
|
|
|
|
|
- u16_t period_ms;
|
|
|
|
|
|
|
+ struct bt_mesh_subnet *sub = NULL;
|
|
|
|
|
+ u16_t period_ms = 0U;
|
|
|
|
|
|
|
|
BT_DBG("hb_pub.count: %u", cfg->hb_pub.count);
|
|
BT_DBG("hb_pub.count: %u", cfg->hb_pub.count);
|
|
|
|
|
|
|
@@ -3429,10 +3414,29 @@ int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary)
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+int bt_mesh_cfg_srv_deinit(struct bt_mesh_model *model, bool primary)
|
|
|
|
|
+{
|
|
|
|
|
+ struct bt_mesh_cfg_srv *cfg = model->user_data;
|
|
|
|
|
+
|
|
|
|
|
+ if (!cfg) {
|
|
|
|
|
+ BT_ERR("%s, No Configuration Server context provided", __func__);
|
|
|
|
|
+ return -EINVAL;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ bt_mesh_cfg_reset();
|
|
|
|
|
+
|
|
|
|
|
+ k_delayed_work_free(&cfg->hb_pub.timer);
|
|
|
|
|
+ cfg->hb_pub.dst = BLE_MESH_ADDR_UNASSIGNED;
|
|
|
|
|
+
|
|
|
|
|
+ conf = NULL;
|
|
|
|
|
+
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void mod_reset(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
|
static void mod_reset(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
|
|
bool vnd, bool primary, void *user_data)
|
|
bool vnd, bool primary, void *user_data)
|
|
|
{
|
|
{
|
|
|
- size_t clear_count;
|
|
|
|
|
|
|
+ size_t clear_count = 0U;
|
|
|
|
|
|
|
|
/* Clear model state that isn't otherwise cleared. E.g. AppKey
|
|
/* Clear model state that isn't otherwise cleared. E.g. AppKey
|
|
|
* binding and model publication is cleared as a consequence
|
|
* binding and model publication is cleared as a consequence
|