22#include <zephyr/kernel.h>
23#include <zephyr/logging/log.h>
52 LOG_DBG(
"Transition: BS_SCAN_WAIT_FOR_SYNC -> BS_SYNC");
58 LOG_DBG(
"Transition: BS_SYNC -> BS_UPDATE");
64 LOG_DBG(
"Transition: BS_UPDATE -> BS_ADV");
68 LOG_DBG(
"Transition: BS_UPDATE -> BS_SCAN_WAIT_FOR_SYNC");
75 LOG_DBG(
"Transition: BS_ADV -> BS_STOP");
79 LOG_DBG(
"Transition: BS_ADV -> BS_WAIT_SYNC");
86 LOG_DBG(
"Transition: BS_STOP -> BS_ADV");
93 LOG_DBG(
"Transition: INIT -> BS_STOP");
97 LOG_DBG(
"Transition: INIT -> BS_WAIT_SYNC");
109 LOG_ERR(
"Error: no handlers set...");
161 LOG_DBG(
"set role %d",
role );
struct bs_sm_handlers handlers
static struct bs_sm_param sm_param
bs_sm_state_t transition(bluesync_role_t role, bs_sm_state_t current_state, bs_sm_event_t event)
bs_sm_state_t bs_state_machine_get_state()
Get the current state.
void bs_state_machine_init(struct bs_sm_handlers *handlers)
Init the state machine by passing the list of callbacks.
void bs_state_machine_set_role(bluesync_role_t role)
Indicate the role to the state machine.
bluesync_role_t bs_state_machine_get_role()
Get the node role.
void bs_state_machine_run(bs_sm_event_t event)
Annonce an event to the state machine.
LOG_MODULE_REGISTER(bs_state_machine, CONFIG_BLUESYNC_LOG_LEVEL)
bs_sm_state_t
Type definition representing the states.
bs_sm_event_t
Type definition representing the events.
bluesync_role_t
Defines the operational roles for a BlueSync node.
@ BLUESYNC_AUTHORITY_ROLE
Public API for the BlueSync time synchronization module.
Struct defining the callbacks of the state machine.
void(* bs_adv_cb)(void)
This callback is called when entering in adv state.
void(* bs_stop_cb)(void)
This callback is called when entering in stop state.
void(* bs_sync_cb)()
This callback is called when entering in sync state.
void(* bs_scan_wait_for_sync_cb)(void)
This callback is called when entering in wait_for_sync state.
void(* bs_update_cb)(void)
This callback is called when entering in update state.
bs_sm_state_t current_state
struct bs_sm_handlers * handlers