Skip to content

Commit bda5733

Browse files
Johan HedbergAnas Nashif
authored andcommitted
Bluetooth: Mesh: Fix setting health period divider
A previous patch which moved dispatching the health publish callback to a later moment introduced a regression where the period divider does not get updated when it should. In fact, having the divider as part of the Health Server context is redundant, since the same information is already stored generically in the model publication context. Switching to using the model publication context makes things simpler and ensures that the value is always up-to-date. With this patch it is possible to pass MESH/SR/HM/CFS/BV-02-C. Signed-off-by: Johan Hedberg <[email protected]>
1 parent 3e23053 commit bda5733

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

include/bluetooth/mesh.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,6 @@ extern const struct bt_mesh_model_op bt_mesh_cfg_op[];
292292
struct bt_mesh_health {
293293
struct bt_mesh_model *model;
294294

295-
/* Health Period (divider) */
296-
u8_t period;
297-
298295
/* Fetch current faults */
299296
int (*fault_get_cur)(struct bt_mesh_model *model, u8_t *test_id,
300297
u16_t *company_id, u8_t *faults,

subsys/bluetooth/host/mesh/health.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,10 @@ static void send_health_period_status(struct bt_mesh_model *model,
282282
{
283283
/* Needed size: opcode (2 bytes) + msg + MIC */
284284
struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 1 + 4);
285-
struct bt_mesh_health *srv = model->user_data;
286285

287286
bt_mesh_model_msg_init(msg, OP_HEALTH_PERIOD_STATUS);
288287

289-
net_buf_simple_add_u8(msg, srv->period);
288+
net_buf_simple_add_u8(msg, model->pub->period_div);
290289

291290
bt_mesh_model_send(model, ctx, msg, NULL, NULL);
292291
}
@@ -304,7 +303,6 @@ static void health_period_set_unrel(struct bt_mesh_model *model,
304303
struct bt_mesh_msg_ctx *ctx,
305304
struct net_buf_simple *buf)
306305
{
307-
struct bt_mesh_health *srv = model->user_data;
308306
u8_t period;
309307

310308
period = net_buf_simple_pull_u8(buf);
@@ -315,7 +313,7 @@ static void health_period_set_unrel(struct bt_mesh_model *model,
315313

316314
BT_DBG("period %u", period);
317315

318-
srv->period = period;
316+
model->pub->period_div = period;
319317
}
320318

321319
static void health_period_set(struct bt_mesh_model *model,
@@ -347,16 +345,13 @@ const struct bt_mesh_model_op bt_mesh_health_op[] = {
347345
static void health_pub(struct bt_mesh_model *mod)
348346
{
349347
struct net_buf_simple *msg = NET_BUF_SIMPLE(HEALTH_STATUS_SIZE);
350-
struct bt_mesh_health *srv = mod->user_data;
351348
size_t count;
352349
int err;
353350

354351
BT_DBG("");
355352

356353
count = health_get_current(mod, msg);
357-
if (count) {
358-
mod->pub->period_div = srv->period;
359-
} else {
354+
if (!count) {
360355
mod->pub->period_div = 0;
361356
}
362357

0 commit comments

Comments
 (0)