samples: mesh: boards: nrf52: upgrade to pass PTS test
Updated state Binding as per PTS test requirements. Now if gen_onoff_server & gen_onpowerup_server received Prohibited values then they will not react on it further. Plus make necessary changes wherever required for message handlers as per Mesh Model Specification which is mostly regarding to default & range values. Now right Status code would get publish in response to set lightness & temperature range. Also upgrade Message handler gen_delta_set_unack() algorithm as per PTS requirements. Signed-off-by: Vikrant More <vikrant8051@gmail.com>
This commit is contained in:
parent
d505ca7081
commit
170ca38b75
|
@ -76,9 +76,7 @@ struct generic_level_state gen_level_srv_root_user_data = {
|
|||
|
||||
struct generic_onpowerup_state gen_power_onoff_srv_user_data;
|
||||
|
||||
struct light_lightness_state light_lightness_srv_user_data = {
|
||||
.lightness_range_max = 0xFFFF,
|
||||
};
|
||||
struct light_lightness_state light_lightness_srv_user_data;
|
||||
|
||||
struct light_ctl_state light_ctl_srv_user_data;
|
||||
|
||||
|
@ -126,6 +124,8 @@ static void state_binding(u8_t lightness, u8_t temperature)
|
|||
if (gen_onoff_srv_root_user_data.onoff == 0x00) {
|
||||
light_lightness_srv_user_data.actual = 0;
|
||||
light_lightness_srv_user_data.linear = 0;
|
||||
gen_level_srv_root_user_data.level = -32768;
|
||||
light_ctl_srv_user_data.lightness = 0;
|
||||
} else if (gen_onoff_srv_root_user_data.onoff == 0x01) {
|
||||
light_lightness_srv_user_data.actual =
|
||||
light_lightness_srv_user_data.last;
|
||||
|
@ -134,12 +134,20 @@ static void state_binding(u8_t lightness, u8_t temperature)
|
|||
light_lightness_srv_user_data.actual / 65535);
|
||||
light_lightness_srv_user_data.linear =
|
||||
(u16_t) (65535 * tmp * tmp);
|
||||
|
||||
gen_level_srv_root_user_data.level =
|
||||
light_lightness_srv_user_data.actual - 32768;
|
||||
|
||||
light_ctl_srv_user_data.lightness =
|
||||
light_lightness_srv_user_data.actual;
|
||||
}
|
||||
break;
|
||||
case ONOFF: /* Lightness update as per Generic OnOff (root) state */
|
||||
if (gen_onoff_srv_root_user_data.onoff == 0x00) {
|
||||
light_lightness_srv_user_data.actual = 0;
|
||||
light_lightness_srv_user_data.linear = 0;
|
||||
gen_level_srv_root_user_data.level = -32768;
|
||||
light_ctl_srv_user_data.lightness = 0;
|
||||
} else if (gen_onoff_srv_root_user_data.onoff == 0x01) {
|
||||
if (light_lightness_srv_user_data.def == 0) {
|
||||
light_lightness_srv_user_data.actual =
|
||||
|
@ -156,7 +164,16 @@ static void state_binding(u8_t lightness, u8_t temperature)
|
|||
|
||||
light_lightness_srv_user_data.last =
|
||||
light_lightness_srv_user_data.actual;
|
||||
|
||||
gen_level_srv_root_user_data.level =
|
||||
light_lightness_srv_user_data.actual - 32768;
|
||||
|
||||
light_ctl_srv_user_data.lightness =
|
||||
light_lightness_srv_user_data.actual;
|
||||
}
|
||||
|
||||
goto update_temp;
|
||||
|
||||
break;
|
||||
case LEVEL: /* Lightness update as per Generic Level (root) state */
|
||||
light_lightness_srv_user_data.actual =
|
||||
|
@ -168,6 +185,9 @@ static void state_binding(u8_t lightness, u8_t temperature)
|
|||
|
||||
light_lightness_srv_user_data.last =
|
||||
light_lightness_srv_user_data.actual;
|
||||
|
||||
light_ctl_srv_user_data.lightness =
|
||||
light_lightness_srv_user_data.actual;
|
||||
break;
|
||||
case ACTUAL: /* Lightness update as per Light Lightness Actual state */
|
||||
tmp = ((float) light_lightness_srv_user_data.actual / 65535);
|
||||
|
@ -176,6 +196,12 @@ static void state_binding(u8_t lightness, u8_t temperature)
|
|||
|
||||
light_lightness_srv_user_data.last =
|
||||
light_lightness_srv_user_data.actual;
|
||||
|
||||
gen_level_srv_root_user_data.level =
|
||||
light_lightness_srv_user_data.actual - 32768;
|
||||
|
||||
light_ctl_srv_user_data.lightness =
|
||||
light_lightness_srv_user_data.actual;
|
||||
break;
|
||||
case LINEAR: /* Lightness update as per Light Lightness Linear state */
|
||||
light_lightness_srv_user_data.actual =
|
||||
|
@ -185,6 +211,12 @@ static void state_binding(u8_t lightness, u8_t temperature)
|
|||
|
||||
light_lightness_srv_user_data.last =
|
||||
light_lightness_srv_user_data.actual;
|
||||
|
||||
gen_level_srv_root_user_data.level =
|
||||
light_lightness_srv_user_data.actual - 32768;
|
||||
|
||||
light_ctl_srv_user_data.lightness =
|
||||
light_lightness_srv_user_data.actual;
|
||||
break;
|
||||
case CTL: /* Lightness update as per Light CTL Lightness state */
|
||||
light_lightness_srv_user_data.actual =
|
||||
|
@ -196,18 +228,15 @@ static void state_binding(u8_t lightness, u8_t temperature)
|
|||
|
||||
light_lightness_srv_user_data.last =
|
||||
light_lightness_srv_user_data.actual;
|
||||
|
||||
gen_level_srv_root_user_data.level =
|
||||
light_lightness_srv_user_data.actual - 32768;
|
||||
break;
|
||||
default:
|
||||
goto update_temp;
|
||||
break;
|
||||
}
|
||||
|
||||
gen_level_srv_root_user_data.level =
|
||||
light_lightness_srv_user_data.actual - 32768;
|
||||
|
||||
light_ctl_srv_user_data.lightness =
|
||||
light_lightness_srv_user_data.actual;
|
||||
|
||||
if (light_lightness_srv_user_data.actual == 0) {
|
||||
gen_onoff_srv_root_user_data.onoff = 0;
|
||||
} else {
|
||||
|
@ -247,11 +276,14 @@ void light_default_status_init(void)
|
|||
*/
|
||||
gen_power_onoff_srv_user_data.onpowerup = 0x01;
|
||||
|
||||
light_lightness_srv_user_data.lightness_range_min = 0x0001;
|
||||
light_lightness_srv_user_data.lightness_range_max = 0xFFFF;
|
||||
light_lightness_srv_user_data.def = 0xFFFF;
|
||||
|
||||
/* Following 2 values are as per specification */
|
||||
light_ctl_srv_user_data.temp_range_min = 0x0320;
|
||||
light_ctl_srv_user_data.temp_range_max = 0x4E20;
|
||||
|
||||
light_lightness_srv_user_data.def = 0xFFFF;
|
||||
light_ctl_srv_user_data.temp_def = 0x0320;
|
||||
/* (End) */
|
||||
|
||||
|
@ -305,9 +337,9 @@ static void gen_onoff_get(struct bt_mesh_model *model,
|
|||
}
|
||||
}
|
||||
|
||||
static void gen_onoff_set_unack(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
static bool onoff_set_unack(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t tid, tmp8;
|
||||
struct net_buf_simple *msg = model->pub->msg;
|
||||
|
@ -317,15 +349,19 @@ static void gen_onoff_set_unack(struct bt_mesh_model *model,
|
|||
tid = net_buf_simple_pull_u8(buf);
|
||||
|
||||
if (state->last_tid == tid && state->last_tx_addr == ctx->addr) {
|
||||
return;
|
||||
if (tmp8 > 0x01) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (tmp8 > 0x01) {
|
||||
return false;
|
||||
}
|
||||
|
||||
state->last_tid = tid;
|
||||
state->last_tx_addr = ctx->addr;
|
||||
|
||||
if (tmp8 > 0x01) {
|
||||
return;
|
||||
}
|
||||
state->onoff = tmp8;
|
||||
|
||||
if (state->model_instance == 0x01) {
|
||||
|
@ -348,14 +384,24 @@ static void gen_onoff_set_unack(struct bt_mesh_model *model,
|
|||
printk("bt_mesh_model_publish err %d\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void gen_onoff_set_unack(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
onoff_set_unack(model, ctx, buf);
|
||||
}
|
||||
|
||||
static void gen_onoff_set(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
gen_onoff_set_unack(model, ctx, buf);
|
||||
gen_onoff_get(model, ctx, buf);
|
||||
if (onoff_set_unack(model, ctx, buf) == true) {
|
||||
gen_onoff_get(model, ctx, buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* Generic OnOff Client message handlers */
|
||||
|
@ -389,11 +435,11 @@ static void gen_level_set_unack(struct bt_mesh_model *model,
|
|||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t tid;
|
||||
s16_t tmp16;
|
||||
s16_t level;
|
||||
struct net_buf_simple *msg = model->pub->msg;
|
||||
struct generic_level_state *state = model->user_data;
|
||||
|
||||
tmp16 = (int16_t) net_buf_simple_pull_le16(buf);
|
||||
level = (int16_t) net_buf_simple_pull_le16(buf);
|
||||
tid = net_buf_simple_pull_u8(buf);
|
||||
|
||||
if (state->last_tid == tid && state->last_tx_addr == ctx->addr) {
|
||||
|
@ -403,7 +449,7 @@ static void gen_level_set_unack(struct bt_mesh_model *model,
|
|||
state->last_tid = tid;
|
||||
state->last_tx_addr = ctx->addr;
|
||||
|
||||
state->level = tmp16;
|
||||
state->level = level;
|
||||
|
||||
if (state->model_instance == 0x01) {
|
||||
/* Root element */
|
||||
|
@ -443,17 +489,24 @@ static void gen_delta_set_unack(struct bt_mesh_model *model,
|
|||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t tid;
|
||||
s32_t tmp32;
|
||||
s32_t tmp32, delta;
|
||||
struct net_buf_simple *msg = model->pub->msg;
|
||||
struct generic_level_state *state = model->user_data;
|
||||
|
||||
tmp32 = state->level + net_buf_simple_pull_le32(buf);
|
||||
delta = net_buf_simple_pull_le32(buf);
|
||||
tid = net_buf_simple_pull_u8(buf);
|
||||
|
||||
if (state->last_tid == tid && state->last_tx_addr == ctx->addr) {
|
||||
return;
|
||||
if (state->last_delta == delta) {
|
||||
return;
|
||||
}
|
||||
tmp32 = state->last_level + delta;
|
||||
} else {
|
||||
state->last_level = state->level;
|
||||
tmp32 = state->level + delta;
|
||||
}
|
||||
|
||||
state->last_delta = delta;
|
||||
state->last_tid = tid;
|
||||
state->last_tx_addr = ctx->addr;
|
||||
|
||||
|
@ -550,9 +603,9 @@ static void gen_onpowerup_status(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
/* Generic Power OnOff Setup Server message handlers */
|
||||
static void gen_onpowerup_set_unack(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
static bool onpowerup_set_unack(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t tmp8;
|
||||
struct net_buf_simple *msg = model->pub->msg;
|
||||
|
@ -563,7 +616,7 @@ static void gen_onpowerup_set_unack(struct bt_mesh_model *model,
|
|||
/* Here, Model specification is silent about tid implementation */
|
||||
|
||||
if (tmp8 > 0x02) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
state->onpowerup = tmp8;
|
||||
|
||||
|
@ -581,14 +634,24 @@ static void gen_onpowerup_set_unack(struct bt_mesh_model *model,
|
|||
printk("bt_mesh_model_publish err %d\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void gen_onpowerup_set_unack(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
onpowerup_set_unack(model, ctx, buf);
|
||||
}
|
||||
|
||||
static void gen_onpowerup_set(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
gen_onpowerup_set_unack(model, ctx, buf);
|
||||
gen_onpowerup_get(model, ctx, buf);
|
||||
if (onpowerup_set_unack(model, ctx, buf) == true) {
|
||||
gen_onpowerup_get(model, ctx, buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* Vendor Model message handlers*/
|
||||
|
@ -684,10 +747,11 @@ static void light_lightness_set_unack(struct bt_mesh_model *model,
|
|||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t tid;
|
||||
u16_t actual;
|
||||
struct net_buf_simple *msg = model->pub->msg;
|
||||
struct light_lightness_state *state = model->user_data;
|
||||
|
||||
state->actual = net_buf_simple_pull_le16(buf);
|
||||
actual = net_buf_simple_pull_le16(buf);
|
||||
tid = net_buf_simple_pull_u8(buf);
|
||||
|
||||
if (state->last_tid == tid && state->last_tx_addr == ctx->addr) {
|
||||
|
@ -697,6 +761,16 @@ static void light_lightness_set_unack(struct bt_mesh_model *model,
|
|||
state->last_tid = tid;
|
||||
state->last_tx_addr = ctx->addr;
|
||||
|
||||
if (actual < state->lightness_range_min && actual > 0) {
|
||||
actual = state->lightness_range_min;
|
||||
}
|
||||
|
||||
if (actual > state->lightness_range_max) {
|
||||
actual = state->lightness_range_max;
|
||||
}
|
||||
|
||||
state->actual = actual;
|
||||
|
||||
state_binding(ACTUAL, IGNORE_TEMP);
|
||||
update_light_state();
|
||||
|
||||
|
@ -744,10 +818,11 @@ static void light_lightness_linear_set_unack(struct bt_mesh_model *model,
|
|||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t tid;
|
||||
u16_t linear;
|
||||
struct net_buf_simple *msg = model->pub->msg;
|
||||
struct light_lightness_state *state = model->user_data;
|
||||
|
||||
state->linear = net_buf_simple_pull_le16(buf);
|
||||
linear = net_buf_simple_pull_le16(buf);
|
||||
tid = net_buf_simple_pull_u8(buf);
|
||||
|
||||
if (state->last_tid == tid && state->last_tx_addr == ctx->addr) {
|
||||
|
@ -756,6 +831,7 @@ static void light_lightness_linear_set_unack(struct bt_mesh_model *model,
|
|||
|
||||
state->last_tid = tid;
|
||||
state->last_tx_addr = ctx->addr;
|
||||
state->linear = linear;
|
||||
|
||||
state_binding(LINEAR, IGNORE_TEMP);
|
||||
update_light_state();
|
||||
|
@ -874,14 +950,30 @@ static void light_lightness_range_set_unack(struct bt_mesh_model *model,
|
|||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t min, max;
|
||||
struct net_buf_simple *msg = model->pub->msg;
|
||||
struct light_lightness_state *state = model->user_data;
|
||||
|
||||
state->lightness_range_min = net_buf_simple_pull_le16(buf);
|
||||
state->lightness_range_max = net_buf_simple_pull_le16(buf);
|
||||
min = net_buf_simple_pull_le16(buf);
|
||||
max = net_buf_simple_pull_le16(buf);
|
||||
|
||||
/* Here, Model specification is silent about tid implementation */
|
||||
|
||||
if (min == 0) {
|
||||
/* The provided value for Range Min cannot be set */
|
||||
state->status_code = CANNOT_SET_RANGE_MIN;
|
||||
} else {
|
||||
if (min <= max && max != 0) {
|
||||
state->status_code = RANGE_SUCCESSFULLY_UPDATED;
|
||||
|
||||
state->lightness_range_min = min;
|
||||
state->lightness_range_max = max;
|
||||
} else {
|
||||
/* The provided value for Range Max cannot be set */
|
||||
state->status_code = CANNOT_SET_RANGE_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do some work here to save values of
|
||||
* state->lightness_range_min & state->lightness_range_max
|
||||
* on SoC flash
|
||||
|
@ -982,13 +1074,13 @@ static void light_ctl_set_unack(struct bt_mesh_model *model,
|
|||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t tid;
|
||||
u16_t tmp16;
|
||||
u16_t lightness, temp, delta_uv;
|
||||
struct net_buf_simple *msg = model->pub->msg;
|
||||
struct light_ctl_state *state = model->user_data;
|
||||
|
||||
state->lightness = net_buf_simple_pull_le16(buf);
|
||||
tmp16 = net_buf_simple_pull_le16(buf);
|
||||
state->delta_uv = (int16_t) net_buf_simple_pull_le16(buf);
|
||||
lightness = net_buf_simple_pull_le16(buf);
|
||||
temp = net_buf_simple_pull_le16(buf);
|
||||
delta_uv = (int16_t) net_buf_simple_pull_le16(buf);
|
||||
tid = net_buf_simple_pull_u8(buf);
|
||||
|
||||
if (state->last_tid == tid && state->last_tx_addr == ctx->addr) {
|
||||
|
@ -998,13 +1090,15 @@ static void light_ctl_set_unack(struct bt_mesh_model *model,
|
|||
state->last_tid = tid;
|
||||
state->last_tx_addr = ctx->addr;
|
||||
|
||||
if (tmp16 < state->temp_range_min) {
|
||||
tmp16 = state->temp_range_min;
|
||||
} else if (tmp16 > state->temp_range_max) {
|
||||
tmp16 = state->temp_range_max;
|
||||
if (temp < state->temp_range_min) {
|
||||
temp = state->temp_range_min;
|
||||
} else if (temp > state->temp_range_max) {
|
||||
temp = state->temp_range_max;
|
||||
}
|
||||
|
||||
state->temp = tmp16;
|
||||
state->lightness = lightness;
|
||||
state->temp = temp;
|
||||
state->delta_uv = delta_uv;
|
||||
|
||||
state_binding(CTL, CTL_TEMP);
|
||||
update_light_state();
|
||||
|
@ -1077,23 +1171,23 @@ static void light_ctl_default_set_unack(struct bt_mesh_model *model,
|
|||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t tmp16;
|
||||
u16_t temp;
|
||||
struct net_buf_simple *msg = model->pub->msg;
|
||||
struct light_ctl_state *state = model->user_data;
|
||||
|
||||
state->lightness_def = net_buf_simple_pull_le16(buf);
|
||||
tmp16 = net_buf_simple_pull_le16(buf);
|
||||
temp = net_buf_simple_pull_le16(buf);
|
||||
state->delta_uv_def = (int16_t) net_buf_simple_pull_le16(buf);
|
||||
|
||||
/* Here, Model specification is silent about tid implementation */
|
||||
|
||||
if (tmp16 < state->temp_range_min) {
|
||||
tmp16 = state->temp_range_min;
|
||||
} else if (tmp16 > state->temp_range_max) {
|
||||
tmp16 = state->temp_range_max;
|
||||
if (temp < state->temp_range_min) {
|
||||
temp = state->temp_range_min;
|
||||
} else if (temp > state->temp_range_max) {
|
||||
temp = state->temp_range_max;
|
||||
}
|
||||
|
||||
state->temp = tmp16;
|
||||
state->temp_def = temp;
|
||||
|
||||
/* Do some work here to save values of
|
||||
* state->lightness_def, state->temp_Def & state->delta_uv_def
|
||||
|
@ -1129,26 +1223,37 @@ static void light_ctl_temp_range_set_unack(struct bt_mesh_model *model,
|
|||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t tmp[2];
|
||||
u16_t min, max;
|
||||
struct net_buf_simple *msg = model->pub->msg;
|
||||
struct light_ctl_state *state = model->user_data;
|
||||
|
||||
tmp[0] = net_buf_simple_pull_le16(buf);
|
||||
tmp[1] = net_buf_simple_pull_le16(buf);
|
||||
min = net_buf_simple_pull_le16(buf);
|
||||
max = net_buf_simple_pull_le16(buf);
|
||||
|
||||
/* Here, Model specification is silent about tid implementation */
|
||||
|
||||
state->status_code = RANGE_SUCCESSFULLY_UPDATED;
|
||||
|
||||
/* This is as per 6.1.3.1 in Mesh Model Specification */
|
||||
if (tmp[0] < 0x0320) {
|
||||
tmp[0] = 0x0320;
|
||||
if (min < 0x0320 && min > 0x4E20) {
|
||||
/* The provided value for Range Min cannot be set */
|
||||
state->status_code = CANNOT_SET_RANGE_MIN;
|
||||
}
|
||||
|
||||
if (tmp[1] > 0x4E20) {
|
||||
tmp[1] = 0x4E20;
|
||||
if (max > 0x4E20 && max < 0x0320) {
|
||||
/* The provided value for Range Max cannot be set */
|
||||
state->status_code = CANNOT_SET_RANGE_MAX;
|
||||
}
|
||||
|
||||
state->temp_range_min = tmp[0];
|
||||
state->temp_range_max = tmp[1];
|
||||
if (state->status_code == RANGE_SUCCESSFULLY_UPDATED) {
|
||||
if (min <= max) {
|
||||
state->temp_range_min = min;
|
||||
state->temp_range_max = max;
|
||||
} else if (max < min) {
|
||||
/* The provided value for Range Max cannot be set */
|
||||
state->status_code = CANNOT_SET_RANGE_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do some work here to save values of
|
||||
* state->temp_range_min & state->temp_range_min
|
||||
|
@ -1254,12 +1359,12 @@ static void light_ctl_temp_set_unack(struct bt_mesh_model *model,
|
|||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t tid;
|
||||
u16_t tmp16;
|
||||
u16_t temp, delta_uv;
|
||||
struct net_buf_simple *msg = model->pub->msg;
|
||||
struct light_ctl_state *state = model->user_data;
|
||||
|
||||
tmp16 = net_buf_simple_pull_le16(buf);
|
||||
state->delta_uv = (int16_t) net_buf_simple_pull_le16(buf);
|
||||
temp = net_buf_simple_pull_le16(buf);
|
||||
delta_uv = (int16_t) net_buf_simple_pull_le16(buf);
|
||||
tid = net_buf_simple_pull_u8(buf);
|
||||
|
||||
if (state->last_tid == tid && state->last_tx_addr == ctx->addr) {
|
||||
|
@ -1269,13 +1374,14 @@ static void light_ctl_temp_set_unack(struct bt_mesh_model *model,
|
|||
state->last_tid = tid;
|
||||
state->last_tx_addr = ctx->addr;
|
||||
|
||||
if (tmp16 < state->temp_range_min) {
|
||||
tmp16 = state->temp_range_min;
|
||||
} else if (tmp16 > state->temp_range_max) {
|
||||
tmp16 = state->temp_range_max;
|
||||
if (temp < state->temp_range_min) {
|
||||
temp = state->temp_range_min;
|
||||
} else if (temp > state->temp_range_max) {
|
||||
temp = state->temp_range_max;
|
||||
}
|
||||
|
||||
state->temp = tmp16;
|
||||
state->temp = temp;
|
||||
state->delta_uv = delta_uv;
|
||||
|
||||
state_binding(IGNORE, CTL_TEMP);
|
||||
update_light_state();
|
||||
|
|
|
@ -10,12 +10,16 @@
|
|||
|
||||
#define CID_ZEPHYR 0x0002
|
||||
|
||||
enum lightness { ONPOWERUP = 0x01, ONOFF, LEVEL, ACTUAL, LINEAR, CTL, IGNORE};
|
||||
enum temperature { ONOFF_TEMP = 0x01, LEVEL_TEMP, CTL_TEMP, IGNORE_TEMP};
|
||||
/* Refer 7.2 of Mesh Model Specification */
|
||||
#define RANGE_SUCCESSFULLY_UPDATED 0x00
|
||||
#define CANNOT_SET_RANGE_MIN 0x01
|
||||
#define CANNOT_SET_RANGE_MAX 0x02
|
||||
|
||||
enum lightness { ONPOWERUP = 0x01, ONOFF, LEVEL, ACTUAL, LINEAR, CTL, IGNORE };
|
||||
enum temperature { ONOFF_TEMP = 0x01, LEVEL_TEMP, CTL_TEMP, IGNORE_TEMP };
|
||||
|
||||
struct generic_onoff_state {
|
||||
u8_t onoff;
|
||||
u8_t previous;
|
||||
u8_t model_instance;
|
||||
u8_t last_tid;
|
||||
u16_t last_tx_addr;
|
||||
|
@ -23,6 +27,8 @@ struct generic_onoff_state {
|
|||
|
||||
struct generic_level_state {
|
||||
int level;
|
||||
int last_level;
|
||||
s32_t last_delta;
|
||||
u8_t model_instance;
|
||||
u8_t last_tid;
|
||||
u16_t last_tx_addr;
|
||||
|
|
Loading…
Reference in a new issue