Bluetooth: Mesh: Use invalid CID instead of bool for non-vendor models
The value 0xffff is reserved, so we can use that to indicate whether there's a vendor model in question or not. Simplifies things over the previously used separate boolean value. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
49e7ca957e
commit
2e50ba9847
1 changed files with 29 additions and 28 deletions
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "foundation.h"
|
||||
|
||||
#define CID_NVAL 0xffff
|
||||
|
||||
struct comp_data {
|
||||
u8_t *status;
|
||||
struct net_buf_simple *comp;
|
||||
|
@ -177,7 +179,6 @@ struct mod_app_param {
|
|||
u16_t elem_addr;
|
||||
u16_t mod_app_idx;
|
||||
u16_t mod_id;
|
||||
bool vnd;
|
||||
u16_t cid;
|
||||
};
|
||||
|
||||
|
@ -188,7 +189,6 @@ static void mod_app_status(struct bt_mesh_model *model,
|
|||
u16_t elem_addr, mod_app_idx, mod_id, cid;
|
||||
struct mod_app_param *param;
|
||||
u8_t status;
|
||||
bool vnd;
|
||||
|
||||
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,
|
||||
|
@ -204,19 +204,17 @@ static void mod_app_status(struct bt_mesh_model *model,
|
|||
mod_app_idx = net_buf_simple_pull_le16(buf);
|
||||
|
||||
if (buf->len >= 4) {
|
||||
vnd = true;
|
||||
cid = net_buf_simple_pull_le16(buf);
|
||||
} else {
|
||||
vnd = false;
|
||||
cid = 0;
|
||||
cid = CID_NVAL;
|
||||
}
|
||||
|
||||
mod_id = net_buf_simple_pull_le16(buf);
|
||||
|
||||
param = cli->op_param;
|
||||
if (param->elem_addr != elem_addr ||
|
||||
param->mod_app_idx != mod_app_idx || param->vnd != vnd ||
|
||||
param->mod_id != mod_id || param->cid != cid) {
|
||||
param->mod_app_idx != mod_app_idx || param->mod_id != mod_id ||
|
||||
param->cid != cid) {
|
||||
BT_WARN("Model App Status parameters did not match");
|
||||
return;
|
||||
}
|
||||
|
@ -231,7 +229,6 @@ struct mod_sub_param {
|
|||
u16_t elem_addr;
|
||||
u16_t sub_addr;
|
||||
u16_t mod_id;
|
||||
bool vnd;
|
||||
u16_t cid;
|
||||
};
|
||||
|
||||
|
@ -242,7 +239,6 @@ static void mod_sub_status(struct bt_mesh_model *model,
|
|||
u16_t elem_addr, sub_addr, mod_id, cid;
|
||||
struct mod_sub_param *param;
|
||||
u8_t status;
|
||||
bool vnd;
|
||||
|
||||
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,
|
||||
|
@ -258,19 +254,17 @@ static void mod_sub_status(struct bt_mesh_model *model,
|
|||
sub_addr = net_buf_simple_pull_le16(buf);
|
||||
|
||||
if (buf->len >= 4) {
|
||||
vnd = true;
|
||||
cid = net_buf_simple_pull_le16(buf);
|
||||
} else {
|
||||
vnd = false;
|
||||
cid = 0;
|
||||
cid = CID_NVAL;
|
||||
}
|
||||
|
||||
mod_id = net_buf_simple_pull_le16(buf);
|
||||
|
||||
param = cli->op_param;
|
||||
if (param->elem_addr != elem_addr ||
|
||||
param->sub_addr != sub_addr || param->vnd != vnd ||
|
||||
param->mod_id != mod_id || param->cid != cid) {
|
||||
param->sub_addr != sub_addr || param->mod_id != mod_id ||
|
||||
param->cid != cid) {
|
||||
BT_WARN("Model Subscription Status parameters did not match");
|
||||
return;
|
||||
}
|
||||
|
@ -680,8 +674,9 @@ int bt_mesh_cfg_app_key_add(u16_t net_idx, u16_t addr, u16_t key_net_idx,
|
|||
return err;
|
||||
}
|
||||
|
||||
int mod_app_bind(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t mod_app_idx,
|
||||
u16_t mod_id, bool vnd, u16_t cid, u8_t *status)
|
||||
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)
|
||||
{
|
||||
struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 8 + 4);
|
||||
struct bt_mesh_msg_ctx ctx = {
|
||||
|
@ -695,7 +690,6 @@ int mod_app_bind(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t mod_app_idx,
|
|||
.elem_addr = elem_addr,
|
||||
.mod_app_idx = mod_app_idx,
|
||||
.mod_id = mod_id,
|
||||
.vnd = vnd,
|
||||
.cid = cid,
|
||||
};
|
||||
int err;
|
||||
|
@ -709,7 +703,7 @@ int mod_app_bind(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t mod_app_idx,
|
|||
net_buf_simple_add_le16(msg, elem_addr);
|
||||
net_buf_simple_add_le16(msg, mod_app_idx);
|
||||
|
||||
if (vnd) {
|
||||
if (cid != CID_NVAL) {
|
||||
net_buf_simple_add_le16(msg, cid);
|
||||
}
|
||||
|
||||
|
@ -740,19 +734,23 @@ 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)
|
||||
{
|
||||
return mod_app_bind(net_idx, addr, elem_addr, mod_app_idx, mod_id,
|
||||
false, 0, status);
|
||||
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)
|
||||
{
|
||||
return mod_app_bind(net_idx, addr, elem_addr, mod_app_idx, mod_id,
|
||||
true, cid, status);
|
||||
if (cid == CID_NVAL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return mod_app_bind(net_idx, addr, elem_addr, mod_app_idx, mod_id, cid,
|
||||
status);
|
||||
}
|
||||
|
||||
int mod_sub_add(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, bool vnd, u16_t cid, u8_t *status)
|
||||
static int mod_sub_add(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)
|
||||
{
|
||||
struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 8 + 4);
|
||||
struct bt_mesh_msg_ctx ctx = {
|
||||
|
@ -766,7 +764,6 @@ int mod_sub_add(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t sub_addr,
|
|||
.elem_addr = elem_addr,
|
||||
.sub_addr = sub_addr,
|
||||
.mod_id = mod_id,
|
||||
.vnd = vnd,
|
||||
.cid = cid,
|
||||
};
|
||||
int err;
|
||||
|
@ -780,7 +777,7 @@ int mod_sub_add(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t sub_addr,
|
|||
net_buf_simple_add_le16(msg, elem_addr);
|
||||
net_buf_simple_add_le16(msg, sub_addr);
|
||||
|
||||
if (vnd) {
|
||||
if (cid != CID_NVAL) {
|
||||
net_buf_simple_add_le16(msg, cid);
|
||||
}
|
||||
|
||||
|
@ -811,15 +808,19 @@ 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)
|
||||
{
|
||||
return mod_sub_add(net_idx, addr, elem_addr, sub_addr, mod_id,
|
||||
false, 0, status);
|
||||
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)
|
||||
{
|
||||
return mod_sub_add(net_idx, addr, elem_addr, sub_addr, mod_id,
|
||||
true, cid, status);
|
||||
if (cid == CID_NVAL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return mod_sub_add(net_idx, addr, elem_addr, sub_addr, mod_id, cid,
|
||||
status);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_hb_sub_set(u16_t net_idx, u16_t addr, u16_t src, u16_t dst,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue