Bluetooth: Mesh: Fix RPL storage timeout handling
The default values for the timeouts, as well as non-defaults in most Mesh samples, use a higher value for the RPL than then generic mesh storage timeout. This hasn't had any effect in practice since the code only uses the RPL timeout if it is *smaller* than the generic one. The original intention of the code was to use the RPL timeout, regardless of what the generic one is, whenever the RPL is the only thing that needs updating. Add some helper macros to track the various groups of pending flags, and perform the appropriate checks to apply the RPL timeout whenever it's smaller than the generic timeout, or if there are no other items to store besides the RPL. Fixes #15904 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
9d3435692d
commit
c0a7e4d778
2 changed files with 16 additions and 6 deletions
|
@ -200,7 +200,7 @@ enum {
|
||||||
BT_MESH_IVU_TEST, /* IV Update test mode */
|
BT_MESH_IVU_TEST, /* IV Update test mode */
|
||||||
BT_MESH_IVU_PENDING, /* Update blocked by SDU in progress */
|
BT_MESH_IVU_PENDING, /* Update blocked by SDU in progress */
|
||||||
|
|
||||||
/* pending storage actions */
|
/* pending storage actions, must reside within first 32 flags */
|
||||||
BT_MESH_RPL_PENDING,
|
BT_MESH_RPL_PENDING,
|
||||||
BT_MESH_KEYS_PENDING,
|
BT_MESH_KEYS_PENDING,
|
||||||
BT_MESH_NET_PENDING,
|
BT_MESH_NET_PENDING,
|
||||||
|
|
|
@ -808,19 +808,29 @@ static int mesh_commit(void)
|
||||||
|
|
||||||
BT_SETTINGS_DEFINE(mesh, mesh_set, mesh_commit, NULL);
|
BT_SETTINGS_DEFINE(mesh, mesh_set, mesh_commit, NULL);
|
||||||
|
|
||||||
|
/* Pending flags that use K_NO_WAIT as the storage timeout */
|
||||||
|
#define NO_WAIT_PENDING_BITS (BIT(BT_MESH_NET_PENDING) | \
|
||||||
|
BIT(BT_MESH_IV_PENDING) | \
|
||||||
|
BIT(BT_MESH_SEQ_PENDING))
|
||||||
|
|
||||||
|
/* Pending flags that use CONFIG_BT_MESH_STORE_TIMEOUT */
|
||||||
|
#define GENERIC_PENDING_BITS (BIT(BT_MESH_KEYS_PENDING) | \
|
||||||
|
BIT(BT_MESH_HB_PUB_PENDING) | \
|
||||||
|
BIT(BT_MESH_CFG_PENDING) | \
|
||||||
|
BIT(BT_MESH_MOD_PENDING))
|
||||||
|
|
||||||
static void schedule_store(int flag)
|
static void schedule_store(int flag)
|
||||||
{
|
{
|
||||||
s32_t timeout;
|
s32_t timeout;
|
||||||
|
|
||||||
atomic_set_bit(bt_mesh.flags, flag);
|
atomic_set_bit(bt_mesh.flags, flag);
|
||||||
|
|
||||||
if (atomic_test_bit(bt_mesh.flags, BT_MESH_NET_PENDING) ||
|
if (atomic_get(bt_mesh.flags) & NO_WAIT_PENDING_BITS) {
|
||||||
atomic_test_bit(bt_mesh.flags, BT_MESH_IV_PENDING) ||
|
|
||||||
atomic_test_bit(bt_mesh.flags, BT_MESH_SEQ_PENDING)) {
|
|
||||||
timeout = K_NO_WAIT;
|
timeout = K_NO_WAIT;
|
||||||
} else if (atomic_test_bit(bt_mesh.flags, BT_MESH_RPL_PENDING) &&
|
} else if (atomic_test_bit(bt_mesh.flags, BT_MESH_RPL_PENDING) &&
|
||||||
(CONFIG_BT_MESH_RPL_STORE_TIMEOUT <
|
(!(atomic_get(bt_mesh.flags) & GENERIC_PENDING_BITS) ||
|
||||||
CONFIG_BT_MESH_STORE_TIMEOUT)) {
|
(CONFIG_BT_MESH_RPL_STORE_TIMEOUT <
|
||||||
|
CONFIG_BT_MESH_STORE_TIMEOUT))) {
|
||||||
timeout = K_SECONDS(CONFIG_BT_MESH_RPL_STORE_TIMEOUT);
|
timeout = K_SECONDS(CONFIG_BT_MESH_RPL_STORE_TIMEOUT);
|
||||||
} else {
|
} else {
|
||||||
timeout = K_SECONDS(CONFIG_BT_MESH_STORE_TIMEOUT);
|
timeout = K_SECONDS(CONFIG_BT_MESH_STORE_TIMEOUT);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue