samples: mesh: removed redundant code, blank lines & comments
Removed redundant code, unnecessary blank lines & comments. Signed-off-by: Vikrant More <vikrant8051@gmail.com>
This commit is contained in:
parent
a1d73acfcd
commit
b5ebc66889
|
@ -855,7 +855,6 @@ static bool gen_def_trans_time_setunack(struct bt_mesh_model *model,
|
|||
u8_t tt;
|
||||
struct light_ctl_state *state = model->user_data;
|
||||
tt = net_buf_simple_pull_u8(buf);
|
||||
/* Here, Model specification is silent about tid implementation */
|
||||
|
||||
if ((tt & 0x3F) == 0x3F) {
|
||||
return false;
|
||||
|
@ -952,7 +951,6 @@ static bool gen_onpowerup_setunack(struct bt_mesh_model *model,
|
|||
u8_t onpowerup;
|
||||
struct light_ctl_state *state = model->user_data;
|
||||
onpowerup = net_buf_simple_pull_u8(buf);
|
||||
/* Here, Model specification is silent about tid implementation */
|
||||
|
||||
if (onpowerup > STATE_RESTORE) {
|
||||
return false;
|
||||
|
@ -1524,8 +1522,6 @@ static void light_lightness_default_set_unack(struct bt_mesh_model *model,
|
|||
|
||||
lightness = net_buf_simple_pull_le16(buf);
|
||||
|
||||
/* Here, Model specification is silent about tid implementation */
|
||||
|
||||
if (state->light->def != lightness) {
|
||||
state->light->def = constrain_lightness(lightness);
|
||||
|
||||
|
@ -1573,8 +1569,6 @@ static bool light_lightness_range_setunack(struct bt_mesh_model *model,
|
|||
min = net_buf_simple_pull_le16(buf);
|
||||
max = net_buf_simple_pull_le16(buf);
|
||||
|
||||
/* Here, Model specification is silent about tid implementation */
|
||||
|
||||
if (min == 0U || max == 0U) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -1976,8 +1970,6 @@ static bool light_ctl_default_setunack(struct bt_mesh_model *model,
|
|||
temp = net_buf_simple_pull_le16(buf);
|
||||
delta_uv = (s16_t) net_buf_simple_pull_le16(buf);
|
||||
|
||||
/* Here, Model specification is silent about tid implementation */
|
||||
|
||||
if (temp < TEMP_MIN || temp > TEMP_MAX) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2048,8 +2040,6 @@ static bool light_ctl_temp_range_setunack(struct bt_mesh_model *model,
|
|||
min = net_buf_simple_pull_le16(buf);
|
||||
max = net_buf_simple_pull_le16(buf);
|
||||
|
||||
/* Here, Model specification is silent about tid implementation */
|
||||
|
||||
/* This is as per 6.1.3.1 in Mesh Model Specification */
|
||||
if (min < TEMP_MIN || min > TEMP_MAX ||
|
||||
max < TEMP_MIN || max > TEMP_MAX) {
|
||||
|
|
|
@ -56,7 +56,6 @@ struct temperature {
|
|||
u16_t target;
|
||||
|
||||
u16_t def;
|
||||
u16_t last;
|
||||
|
||||
u8_t status_code;
|
||||
u16_t range_min;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <drivers/gpio.h>
|
||||
|
||||
#include "app_gpio.h"
|
||||
|
||||
#include "ble_mesh.h"
|
||||
#include "device_composition.h"
|
||||
#include "publisher.h"
|
||||
|
@ -16,13 +15,7 @@
|
|||
#define ONOFF
|
||||
#define GENERIC_LEVEL
|
||||
|
||||
#if (defined(ONOFF) || defined(ONOFF_TT))
|
||||
static u8_t tid_onoff;
|
||||
#elif defined(VND_MODEL_TEST)
|
||||
static u8_t tid_vnd;
|
||||
#endif
|
||||
|
||||
static u8_t tid_level;
|
||||
static u8_t tid;
|
||||
|
||||
static u32_t button_read(struct device *port, u32_t pin)
|
||||
{
|
||||
|
@ -41,13 +34,13 @@ void publish(struct k_work *work)
|
|||
bt_mesh_model_msg_init(root_models[3].pub->msg,
|
||||
BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, 0x01);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, tid_onoff++);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&root_models[3]);
|
||||
#elif defined(ONOFF_TT)
|
||||
bt_mesh_model_msg_init(root_models[3].pub->msg,
|
||||
BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, 0x01);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, tid_onoff++);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, tid++);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, 0x45);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, 0x28);
|
||||
err = bt_mesh_model_publish(&root_models[3]);
|
||||
|
@ -55,7 +48,7 @@ void publish(struct k_work *work)
|
|||
bt_mesh_model_msg_init(vnd_models[0].pub->msg,
|
||||
BT_MESH_MODEL_OP_3(0x03, CID_ZEPHYR));
|
||||
net_buf_simple_add_le16(vnd_models[0].pub->msg, 0x0001);
|
||||
net_buf_simple_add_u8(vnd_models[0].pub->msg, tid_vnd++);
|
||||
net_buf_simple_add_u8(vnd_models[0].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&vnd_models[0]);
|
||||
#endif
|
||||
} else if (button_read(button_device[1], DT_ALIAS_SW1_GPIOS_PIN) ==
|
||||
|
@ -64,13 +57,13 @@ void publish(struct k_work *work)
|
|||
bt_mesh_model_msg_init(root_models[3].pub->msg,
|
||||
BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, 0x00);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, tid_onoff++);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&root_models[3]);
|
||||
#elif defined(ONOFF_TT)
|
||||
bt_mesh_model_msg_init(root_models[3].pub->msg,
|
||||
BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, 0x00);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, tid_onoff++);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, tid++);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, 0x45);
|
||||
net_buf_simple_add_u8(root_models[3].pub->msg, 0x28);
|
||||
err = bt_mesh_model_publish(&root_models[3]);
|
||||
|
@ -78,7 +71,7 @@ void publish(struct k_work *work)
|
|||
bt_mesh_model_msg_init(vnd_models[0].pub->msg,
|
||||
BT_MESH_MODEL_OP_3(0x03, CID_ZEPHYR));
|
||||
net_buf_simple_add_le16(vnd_models[0].pub->msg, 0x0000);
|
||||
net_buf_simple_add_u8(vnd_models[0].pub->msg, tid_vnd++);
|
||||
net_buf_simple_add_u8(vnd_models[0].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&vnd_models[0]);
|
||||
#endif
|
||||
} else if (button_read(button_device[2], DT_ALIAS_SW2_GPIOS_PIN) ==
|
||||
|
@ -87,7 +80,7 @@ void publish(struct k_work *work)
|
|||
bt_mesh_model_msg_init(root_models[5].pub->msg,
|
||||
BT_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK);
|
||||
net_buf_simple_add_le16(root_models[5].pub->msg, LEVEL_S25);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&root_models[5]);
|
||||
#elif defined(ONOFF_GET)
|
||||
bt_mesh_model_msg_init(root_models[3].pub->msg,
|
||||
|
@ -97,13 +90,13 @@ void publish(struct k_work *work)
|
|||
bt_mesh_model_msg_init(root_models[5].pub->msg,
|
||||
BT_MESH_MODEL_OP_GEN_DELTA_SET_UNACK);
|
||||
net_buf_simple_add_le32(root_models[5].pub->msg, 100);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&root_models[5]);
|
||||
#elif defined(GENERIC_MOVE_LEVEL_TT)
|
||||
bt_mesh_model_msg_init(root_models[5].pub->msg,
|
||||
BT_MESH_MODEL_OP_GEN_MOVE_SET_UNACK);
|
||||
net_buf_simple_add_le16(root_models[5].pub->msg, 655);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid++);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, 0x41);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, 0x00);
|
||||
err = bt_mesh_model_publish(&root_models[5]);
|
||||
|
@ -111,7 +104,7 @@ void publish(struct k_work *work)
|
|||
bt_mesh_model_msg_init(root_models[13].pub->msg,
|
||||
BT_MESH_MODEL_OP_2(0x82, 0x4D));
|
||||
net_buf_simple_add_le16(root_models[13].pub->msg, LEVEL_U25);
|
||||
net_buf_simple_add_u8(root_models[13].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[13].pub->msg, tid++);
|
||||
net_buf_simple_add_u8(root_models[13].pub->msg, 0x45);
|
||||
net_buf_simple_add_u8(root_models[13].pub->msg, 0x28);
|
||||
err = bt_mesh_model_publish(&root_models[13]);
|
||||
|
@ -125,7 +118,7 @@ void publish(struct k_work *work)
|
|||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x0320);
|
||||
/* Delta UV */
|
||||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x0000);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&root_models[16]);
|
||||
#elif defined(LIGHT_CTL_TT)
|
||||
bt_mesh_model_msg_init(root_models[16].pub->msg,
|
||||
|
@ -137,7 +130,7 @@ void publish(struct k_work *work)
|
|||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x0320);
|
||||
/* Delta UV */
|
||||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x0000);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid++);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, 0x45);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, 0x00);
|
||||
err = bt_mesh_model_publish(&root_models[16]);
|
||||
|
@ -149,7 +142,7 @@ void publish(struct k_work *work)
|
|||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x0320);
|
||||
/* Delta UV */
|
||||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x0000);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&root_models[16]);
|
||||
#endif
|
||||
} else if (button_read(button_device[3], DT_ALIAS_SW3_GPIOS_PIN) ==
|
||||
|
@ -158,19 +151,19 @@ void publish(struct k_work *work)
|
|||
bt_mesh_model_msg_init(root_models[5].pub->msg,
|
||||
BT_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK);
|
||||
net_buf_simple_add_le16(root_models[5].pub->msg, LEVEL_S100);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&root_models[5]);
|
||||
#elif defined(GENERIC_DELTA_LEVEL)
|
||||
bt_mesh_model_msg_init(root_models[5].pub->msg,
|
||||
BT_MESH_MODEL_OP_GEN_DELTA_SET_UNACK);
|
||||
net_buf_simple_add_le32(root_models[5].pub->msg, -100);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&root_models[5]);
|
||||
#elif defined(GENERIC_MOVE_LEVEL_TT)
|
||||
bt_mesh_model_msg_init(root_models[5].pub->msg,
|
||||
BT_MESH_MODEL_OP_GEN_MOVE_SET_UNACK);
|
||||
net_buf_simple_add_le16(root_models[5].pub->msg, -655);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, tid++);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, 0x41);
|
||||
net_buf_simple_add_u8(root_models[5].pub->msg, 0x00);
|
||||
err = bt_mesh_model_publish(&root_models[5]);
|
||||
|
@ -178,7 +171,7 @@ void publish(struct k_work *work)
|
|||
bt_mesh_model_msg_init(root_models[13].pub->msg,
|
||||
BT_MESH_MODEL_OP_2(0x82, 0x4D));
|
||||
net_buf_simple_add_le16(root_models[13].pub->msg, LEVEL_U100);
|
||||
net_buf_simple_add_u8(root_models[13].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[13].pub->msg, tid++);
|
||||
net_buf_simple_add_u8(root_models[13].pub->msg, 0x45);
|
||||
net_buf_simple_add_u8(root_models[13].pub->msg, 0x28);
|
||||
err = bt_mesh_model_publish(&root_models[13]);
|
||||
|
@ -192,7 +185,7 @@ void publish(struct k_work *work)
|
|||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x4E20);
|
||||
/* Delta UV */
|
||||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x0000);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&root_models[16]);
|
||||
#elif defined(LIGHT_CTL_TT)
|
||||
bt_mesh_model_msg_init(root_models[16].pub->msg,
|
||||
|
@ -204,7 +197,7 @@ void publish(struct k_work *work)
|
|||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x4E20);
|
||||
/* Delta UV */
|
||||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x0000);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid++);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, 0x45);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, 0x00);
|
||||
err = bt_mesh_model_publish(&root_models[16]);
|
||||
|
@ -216,7 +209,7 @@ void publish(struct k_work *work)
|
|||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x4E20);
|
||||
/* Delta UV */
|
||||
net_buf_simple_add_le16(root_models[16].pub->msg, 0x0000);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid_level++);
|
||||
net_buf_simple_add_u8(root_models[16].pub->msg, tid++);
|
||||
err = bt_mesh_model_publish(&root_models[16]);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#define LEVEL_U75 49152
|
||||
#define LEVEL_U100 65535
|
||||
|
||||
void randomize_publishers_TID(void);
|
||||
void publish(struct k_work *work);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -125,10 +125,6 @@ u16_t level_to_light_ctl_temp(s16_t level)
|
|||
|
||||
void set_target(u8_t type, void *dptr)
|
||||
{
|
||||
bool set_light_ctl_delta_uv_target_value;
|
||||
|
||||
set_light_ctl_delta_uv_target_value = true;
|
||||
|
||||
switch (type) {
|
||||
case ONOFF: {
|
||||
u8_t onoff;
|
||||
|
@ -160,8 +156,7 @@ void set_target(u8_t type, void *dptr)
|
|||
ctl->light->target = linear_to_actual(*((u16_t *) dptr));
|
||||
constrain_target_lightness();
|
||||
break;
|
||||
case CTL:
|
||||
set_light_ctl_delta_uv_target_value = false;
|
||||
case CTL_LIGHT:
|
||||
ctl->light->target = *((u16_t *) dptr);
|
||||
constrain_target_lightness();
|
||||
break;
|
||||
|
@ -169,7 +164,6 @@ void set_target(u8_t type, void *dptr)
|
|||
ctl->temp->target = level_to_light_ctl_temp(*((s16_t *) dptr));
|
||||
break;
|
||||
case CTL_TEMP:
|
||||
set_light_ctl_delta_uv_target_value = false;
|
||||
ctl->temp->target = *((u16_t *) dptr);
|
||||
break;
|
||||
case CTL_DELTA_UV:
|
||||
|
@ -179,10 +173,6 @@ void set_target(u8_t type, void *dptr)
|
|||
return;
|
||||
}
|
||||
|
||||
if (set_light_ctl_delta_uv_target_value) {
|
||||
ctl->duv->target = ctl->duv->current;
|
||||
}
|
||||
|
||||
if (ctl->onpowerup == STATE_RESTORE) {
|
||||
save_on_flash(LIGHTNESS_TEMP_LAST_TARGET_STATE);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#define _STATE_BINDING_H
|
||||
|
||||
enum state_binding {
|
||||
ONPOWERUP = 0x01,
|
||||
ONOFF,
|
||||
LEVEL,
|
||||
DELTA_LEVEL,
|
||||
|
|
|
@ -219,7 +219,6 @@ static void level_lightness_work_handler(struct k_work *work)
|
|||
update_light_state();
|
||||
k_timer_stop(&ctl->transition->timer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void level_move_temp_work_handler(void)
|
||||
|
@ -287,7 +286,6 @@ static void light_lightness_actual_work_handler(struct k_work *work)
|
|||
update_light_state();
|
||||
k_timer_stop(&ctl->transition->timer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void light_lightness_linear_work_handler(struct k_work *work)
|
||||
|
|
Loading…
Reference in a new issue