Finite State Machine (FSM) API
#include "src/btstack_fsm.h"
btstack_fsm_transit
btstack_fsm_state_t btstack_fsm_transit(btstack_fsm_t * const me, btstack_fsm_state_handler_t target);
@title: Finite State Machine (FSM)
/
ifndef BTSTACK_FSM_H
define BTSTACK_FSM_H
if defined __cplusplus
extern "C" {
endif
include
typedef uint16_t btstack_fsm_signal_t; enum btstack_fsm_reserved_signals_e { BTSTACK_FSM_EMPTY_SIG, BTSTACK_FSM_INIT_SIG, BTSTACK_FSM_ENTRY_SIG, BTSTACK_FSM_EXIT_SIG, BTSTACK_FSM_USER_SIG };
typedef struct { btstack_fsm_signal_t sig; } btstack_fsm_event_t;
typedef struct btstack_fsm_s btstack_fsm_t;
typedef enum { BTSTACK_FSM_TRAN_STATUS, BTSTACK_FSM_SUPER_STATUS, BTSTACK_FSM_HANDLED_STATUS, BTSTACK_FSM_UNHANDLED_STATUS, BTSTACK_FSM_IGNORED_STATUS } btstack_fsm_state_t;
typedef btstack_fsm_state_t (*btstack_fsm_state_handler_t)(btstack_fsm_t * const me, btstack_fsm_event_t const * const e);
struct btstack_fsm_s { btstack_fsm_state_handler_t state; };
/* API_START */
/*
Request the transition from the current state to the given new state
Parameters
- me: the current state machine
- target: the new state to transit to
Returns
- btstack_fsm_state_t: transition status
btstack_fsm_constructor
void btstack_fsm_constructor(btstack_fsm_t * const me, btstack_fsm_state_handler_t initial);
@title: Finite State Machine (FSM)
/
ifndef BTSTACK_FSM_H
define BTSTACK_FSM_H
if defined __cplusplus
extern "C" {
endif
include
typedef uint16_t btstack_fsm_signal_t; enum btstack_fsm_reserved_signals_e { BTSTACK_FSM_EMPTY_SIG, BTSTACK_FSM_INIT_SIG, BTSTACK_FSM_ENTRY_SIG, BTSTACK_FSM_EXIT_SIG, BTSTACK_FSM_USER_SIG };
typedef struct { btstack_fsm_signal_t sig; } btstack_fsm_event_t;
typedef struct btstack_fsm_s btstack_fsm_t;
typedef enum { BTSTACK_FSM_TRAN_STATUS, BTSTACK_FSM_SUPER_STATUS, BTSTACK_FSM_HANDLED_STATUS, BTSTACK_FSM_UNHANDLED_STATUS, BTSTACK_FSM_IGNORED_STATUS } btstack_fsm_state_t;
typedef btstack_fsm_state_t (*btstack_fsm_state_handler_t)(btstack_fsm_t * const me, btstack_fsm_event_t const * const e);
struct btstack_fsm_s { btstack_fsm_state_handler_t state; };
/* API_START */
/*
Request the transition from the current state to the given new state
Constructs a new state hierarchical machine machine, with storage for maximum hierarchy depth.
Parameters
- me: the current state machine
- target: the new state to transit to
- me: the current state machine
- initial: the initial state
btstack_fsm_init
void btstack_fsm_init(btstack_fsm_t * const me, btstack_fsm_event_t const * const e);
@title: Finite State Machine (FSM)
/
ifndef BTSTACK_FSM_H
define BTSTACK_FSM_H
if defined __cplusplus
extern "C" {
endif
include
typedef uint16_t btstack_fsm_signal_t; enum btstack_fsm_reserved_signals_e { BTSTACK_FSM_EMPTY_SIG, BTSTACK_FSM_INIT_SIG, BTSTACK_FSM_ENTRY_SIG, BTSTACK_FSM_EXIT_SIG, BTSTACK_FSM_USER_SIG };
typedef struct { btstack_fsm_signal_t sig; } btstack_fsm_event_t;
typedef struct btstack_fsm_s btstack_fsm_t;
typedef enum { BTSTACK_FSM_TRAN_STATUS, BTSTACK_FSM_SUPER_STATUS, BTSTACK_FSM_HANDLED_STATUS, BTSTACK_FSM_UNHANDLED_STATUS, BTSTACK_FSM_IGNORED_STATUS } btstack_fsm_state_t;
typedef btstack_fsm_state_t (*btstack_fsm_state_handler_t)(btstack_fsm_t * const me, btstack_fsm_event_t const * const e);
struct btstack_fsm_s { btstack_fsm_state_handler_t state; };
/* API_START */
/*
Request the transition from the current state to the given new state
Constructs a new state hierarchical machine machine, with storage for maximum hierarchy depth.
Takes the initial transition of the state machine and sending it a BTSTACK_HSM_INIT_SIG
Parameters
- me: the current state machine
- target: the new state to transit to
- me: the current state machine
- initial: the initial state / void btstack_fsm_constructor(btstack_fsm_t * const me, btstack_fsm_state_handler_t initial); /*
- me: the current state machine
- e: event
btstack_fsm_dispatch
btstack_fsm_state_t btstack_fsm_dispatch(btstack_fsm_t * const me, btstack_fsm_event_t const * const e);
@title: Finite State Machine (FSM)
/
ifndef BTSTACK_FSM_H
define BTSTACK_FSM_H
if defined __cplusplus
extern "C" {
endif
include
typedef uint16_t btstack_fsm_signal_t; enum btstack_fsm_reserved_signals_e { BTSTACK_FSM_EMPTY_SIG, BTSTACK_FSM_INIT_SIG, BTSTACK_FSM_ENTRY_SIG, BTSTACK_FSM_EXIT_SIG, BTSTACK_FSM_USER_SIG };
typedef struct { btstack_fsm_signal_t sig; } btstack_fsm_event_t;
typedef struct btstack_fsm_s btstack_fsm_t;
typedef enum { BTSTACK_FSM_TRAN_STATUS, BTSTACK_FSM_SUPER_STATUS, BTSTACK_FSM_HANDLED_STATUS, BTSTACK_FSM_UNHANDLED_STATUS, BTSTACK_FSM_IGNORED_STATUS } btstack_fsm_state_t;
typedef btstack_fsm_state_t (*btstack_fsm_state_handler_t)(btstack_fsm_t * const me, btstack_fsm_event_t const * const e);
struct btstack_fsm_s { btstack_fsm_state_handler_t state; };
/* API_START */
/*
Request the transition from the current state to the given new state
Constructs a new state hierarchical machine machine, with storage for maximum hierarchy depth.
Takes the initial transition of the state machine and sending it a BTSTACK_HSM_INIT_SIG
Dispatches the given event to the state machine, if a transition is requested, leave the old states and enter the new on. Handling entering/exiting all states on the way.
Parameters
- me: the current state machine
- target: the new state to transit to
- me: the current state machine
- initial: the initial state / void btstack_fsm_constructor(btstack_fsm_t * const me, btstack_fsm_state_handler_t initial); /*
- me: the current state machine
- e: event / void btstack_fsm_init(btstack_fsm_t * const me, btstack_fsm_event_t const * const e); /*
- me: the current state machine
- e: event
Returns
- btstack_fsm_state_t: transition status / btstack_fsm_state_t btstack_fsm_transit(btstack_fsm_t * const me, btstack_fsm_state_handler_t target); /*
btstack_fsm_dispatch_until
void btstack_fsm_dispatch_until(btstack_fsm_t * const me, btstack_fsm_event_t const * const e);
@title: Finite State Machine (FSM)
/
ifndef BTSTACK_FSM_H
define BTSTACK_FSM_H
if defined __cplusplus
extern "C" {
endif
include
typedef uint16_t btstack_fsm_signal_t; enum btstack_fsm_reserved_signals_e { BTSTACK_FSM_EMPTY_SIG, BTSTACK_FSM_INIT_SIG, BTSTACK_FSM_ENTRY_SIG, BTSTACK_FSM_EXIT_SIG, BTSTACK_FSM_USER_SIG };
typedef struct { btstack_fsm_signal_t sig; } btstack_fsm_event_t;
typedef struct btstack_fsm_s btstack_fsm_t;
typedef enum { BTSTACK_FSM_TRAN_STATUS, BTSTACK_FSM_SUPER_STATUS, BTSTACK_FSM_HANDLED_STATUS, BTSTACK_FSM_UNHANDLED_STATUS, BTSTACK_FSM_IGNORED_STATUS } btstack_fsm_state_t;
typedef btstack_fsm_state_t (*btstack_fsm_state_handler_t)(btstack_fsm_t * const me, btstack_fsm_event_t const * const e);
struct btstack_fsm_s { btstack_fsm_state_handler_t state; };
/* API_START */
/*
Request the transition from the current state to the given new state
Constructs a new state hierarchical machine machine, with storage for maximum hierarchy depth.
Takes the initial transition of the state machine and sending it a BTSTACK_HSM_INIT_SIG
Dispatches the given event to the state machine, if a transition is requested, leave the old states and enter the new on. Handling entering/exiting all states on the way.
Dispatches the given event to the state machine until it was handled.
Parameters
- me: the current state machine
- target: the new state to transit to
- me: the current state machine
- initial: the initial state / void btstack_fsm_constructor(btstack_fsm_t * const me, btstack_fsm_state_handler_t initial); /*
- me: the current state machine
- e: event / void btstack_fsm_init(btstack_fsm_t * const me, btstack_fsm_event_t const * const e); /*
- me: the current state machine
- e: event / btstack_fsm_state_t btstack_fsm_dispatch(btstack_fsm_t * const me, btstack_fsm_event_t const * const e); /*
- me: the current state machine
- e: event