Re: BT Mesh Health Server Fault Periodic Publication#bluetoothmesh #zephyrbluetoothmesh

Johan Hedberg
 

Hi Billy,

(added zephyr-users back to CC - please don’t drop it since others may benefit from this information as well)

On 9 Apr 2019, at 14.28, William Fish <@WilliamFish> wrote:
/* Health SVR: publish periodicaly to a remote address */
struct bt_mesh_cfg_mod_pub health_svr_pub = {
.addr = GROUP_ADDR, /*GROUP_ADDR or Node addr */
.app_idx = app_idx,
.ttl = 0x07,
.period = HEALTH_SVR_UPDATE_PERIOD,
.transmit=BT_MESH_TRANSMIT(1, 20),
};
There are a many problems with the above:

1. The model publication is expected to be configured by a configuration client - not statically like this. If everything else is initialised correctly (it’s not - see my other points) it *might* work if you’re also using BT_SETTINGS and calling settings_load() from your application, but I’ve never tested it.

2. You’re missing an update callback. This is mandatory for periodic publication.

3. You’re missing a pub->msg where the publication message is expected to be encoded by your app.

The two last issues will likely cause unexpected behaviour and faults. If you had asserts enabled than issue 2 should trigger an assert (see access.c line 216).

In general, it’s recommended to use the BT_MESH_MODEL_PUB_DEFINE() macro for defining the publication context.

Johan

Join users@lists.zephyrproject.org to automatically receive all group messages.