Skip to content

Commit

Permalink
- Simplify code for delayable work
Browse files Browse the repository at this point in the history
  • Loading branch information
Kampi committed Nov 20, 2023
1 parent cf556e2 commit 90017af
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/src/applications/settings/settings_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ static void on_pairing_enable_changed(lv_setting_value_t value, bool final);
static void on_reset_steps_changed(lv_setting_value_t value, bool final);
static void on_clear_bonded_changed(lv_setting_value_t value, bool final);

static void ble_pairing_work_handler(struct k_work *work);

LV_IMG_DECLARE(settings);

typedef struct setting_app {
Expand All @@ -38,7 +40,7 @@ typedef struct setting_app {
zsw_settings_ble_aoa_int_t ble_aoa_tx_interval;
} setting_app_t;

static struct k_work_delayable ble_pairing_dwork;
K_WORK_DELAYABLE_DEFINE(ble_pairing_dwork, ble_pairing_work_handler);

// Default values.
static setting_app_t settings_app = {
Expand Down Expand Up @@ -232,12 +234,8 @@ static void on_pairing_enable_changed(lv_setting_value_t value, bool final)
if (final) {
ble_comm_set_pairable(true);

if (!k_work_delayable_is_pending(&ble_pairing_dwork)) {
LOG_DBG("Schedule new work");

k_work_init_delayable(&ble_pairing_dwork, ble_pairing_work_handler);
k_work_schedule(&ble_pairing_dwork, K_MSEC(60 * 1000UL));
}
LOG_DBG("Schedule new work");
k_work_reschedule(&ble_pairing_dwork, K_MSEC(60 * 1000UL));
} else {
ble_comm_set_pairable(false);
}
Expand Down

0 comments on commit 90017af

Please sign in to comment.