Bluetooth: Mesh: shell: Fix sending health publication

We need to send out a Health Fault Current Status (the Health Model's
publication message) when all faults are cleared. The logic for
calculating number of faults was also wrong after the updated model
publication API.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-11-26 16:48:59 +02:00 committed by Johan Hedberg
commit c2fd67699d
2 changed files with 3 additions and 4 deletions

View file

@ -81,9 +81,8 @@ static size_t health_get_current(struct bt_mesh_model *mod,
company_ptr = net_buf_simple_add(msg, sizeof(company_id)); company_ptr = net_buf_simple_add(msg, sizeof(company_id));
comp = bt_mesh_comp_get(); comp = bt_mesh_comp_get();
fault_count = net_buf_simple_tailroom(msg) - 4;
if (srv->cb && srv->cb->fault_get_cur) { if (srv->cb && srv->cb->fault_get_cur) {
fault_count = net_buf_simple_tailroom(msg);
err = srv->cb->fault_get_cur(mod, test_id, &company_id, err = srv->cb->fault_get_cur(mod, test_id, &company_id,
net_buf_simple_tail(msg), net_buf_simple_tail(msg),
&fault_count); &fault_count);
@ -358,8 +357,7 @@ int bt_mesh_fault_update(struct bt_mesh_elem *elem)
return -EINVAL; return -EINVAL;
} }
k_delayed_work_submit(&mod->pub->timer, K_NO_WAIT); return bt_mesh_model_publish(mod);
return 0;
} }
static void attention_off(struct k_work *work) static void attention_off(struct k_work *work)

View file

@ -1750,6 +1750,7 @@ static int cmd_del_fault(int argc, char *argv[])
if (argc < 2) { if (argc < 2) {
memset(cur_faults, 0, sizeof(cur_faults)); memset(cur_faults, 0, sizeof(cur_faults));
printk("All current faults cleared\n"); printk("All current faults cleared\n");
bt_mesh_fault_update(&elements[0]);
return 0; return 0;
} }