Bluetooth: Mesh: Convert RPL storage timer into a generic one
To reduce stack consumption, and to avoid blocking the CPU during network activity, prepare for a generic timer that can be used for most (possibly all) mesh storage values. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
d536ffa694
commit
ace198142e
2 changed files with 25 additions and 9 deletions
|
@ -197,6 +197,14 @@ struct bt_mesh_lpn {
|
|||
ATOMIC_DEFINE(to_remove, LPN_GROUPS);
|
||||
};
|
||||
|
||||
/* bt_mesh_net.flags */
|
||||
enum {
|
||||
BT_MESH_RPL_UPDATE,
|
||||
|
||||
/* Don't touch - intentionally last */
|
||||
BT_MESH_FLAG_COUNT,
|
||||
};
|
||||
|
||||
struct bt_mesh_net {
|
||||
u32_t iv_index; /* Current IV Index */
|
||||
u32_t seq:24, /* Next outgoing sequence number */
|
||||
|
@ -208,6 +216,8 @@ struct bt_mesh_net {
|
|||
|
||||
s64_t last_update; /* Time since last IV Update change */
|
||||
|
||||
ATOMIC_DEFINE(flags, BT_MESH_FLAG_COUNT);
|
||||
|
||||
/* Local network interface */
|
||||
struct k_work local_work;
|
||||
sys_slist_t local_queue;
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "proxy.h"
|
||||
#include "settings.h"
|
||||
|
||||
static struct k_delayed_work pending_store;
|
||||
|
||||
/* Mesh network storage information */
|
||||
struct net_val {
|
||||
u16_t primary_addr;
|
||||
|
@ -600,10 +602,7 @@ static void store_rpl(struct bt_mesh_rpl *entry)
|
|||
settings_save_one(path, str);
|
||||
}
|
||||
|
||||
#if CONFIG_BT_MESH_RPL_STORE_TIMEOUT > 0
|
||||
static struct k_delayed_work rpl_store;
|
||||
|
||||
static void rpl_store_timeout(struct k_work *work)
|
||||
static void store_pending_rpl(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -618,13 +617,22 @@ static void rpl_store_timeout(struct k_work *work)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void store_pending(struct k_work *work)
|
||||
{
|
||||
BT_DBG("");
|
||||
|
||||
if (atomic_test_and_clear_bit(bt_mesh.flags, BT_MESH_RPL_UPDATE)) {
|
||||
store_pending_rpl();
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_store_rpl(struct bt_mesh_rpl *entry)
|
||||
{
|
||||
#if CONFIG_BT_MESH_RPL_STORE_TIMEOUT > 0
|
||||
entry->store = true;
|
||||
k_delayed_work_submit(&rpl_store,
|
||||
atomic_set_bit(bt_mesh.flags, BT_MESH_RPL_UPDATE);
|
||||
k_delayed_work_submit(&pending_store,
|
||||
K_SECONDS(CONFIG_BT_MESH_RPL_STORE_TIMEOUT));
|
||||
BT_DBG("Waiting %d seconds", CONFIG_BT_MESH_RPL_STORE_TIMEOUT);
|
||||
#else
|
||||
|
@ -732,7 +740,5 @@ void bt_mesh_clear_rpl(void)
|
|||
|
||||
void bt_mesh_settings_init(void)
|
||||
{
|
||||
#if CONFIG_BT_MESH_RPL_STORE_TIMEOUT > 0
|
||||
k_delayed_work_init(&rpl_store, rpl_store_timeout);
|
||||
#endif
|
||||
k_delayed_work_init(&pending_store, store_pending);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue