Bluetooth: Mesh: Fix publication period timestamp initialization
The period_start timestamp wasn't getting properly initialized in the case that retransmission was not being used. In the case of retransmission the timestamp was getting updated in the mod_publish() delayed work callback. Add a send_start callback and do the initialization there, since this covers both the retransmission as well as the no-retransmission cases. Fixes #17820 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
aed767a98c
commit
71d00c1bf8
1 changed files with 17 additions and 2 deletions
|
@ -147,7 +147,24 @@ static void publish_sent(int err, void *user_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void publish_start(u16_t duration, int err, void *user_data)
|
||||||
|
{
|
||||||
|
struct bt_mesh_model *mod = user_data;
|
||||||
|
struct bt_mesh_model_pub *pub = mod->pub;
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
BT_ERR("Failed to publish: err %d", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize the timestamp for the beginning of a new period */
|
||||||
|
if (pub->count == BT_MESH_PUB_TRANSMIT_COUNT(pub->retransmit)) {
|
||||||
|
pub->period_start = k_uptime_get_32();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const struct bt_mesh_send_cb pub_sent_cb = {
|
static const struct bt_mesh_send_cb pub_sent_cb = {
|
||||||
|
.start = publish_start,
|
||||||
.end = publish_sent,
|
.end = publish_sent,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -219,8 +236,6 @@ static void mod_publish(struct k_work *work)
|
||||||
|
|
||||||
__ASSERT_NO_MSG(pub->update != NULL);
|
__ASSERT_NO_MSG(pub->update != NULL);
|
||||||
|
|
||||||
pub->period_start = k_uptime_get_32();
|
|
||||||
|
|
||||||
err = pub->update(pub->mod);
|
err = pub->update(pub->mod);
|
||||||
if (err) {
|
if (err) {
|
||||||
BT_ERR("Failed to update publication message");
|
BT_ERR("Failed to update publication message");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue