-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app: transport: Rewrite state handling
Rewrite of the state machine, which affects pretty much all code in the module. A few new states have been added, and all state transitions will now happen from within the state handlers to avoid races and ensure run-to-completion for all events. Signed-off-by: Jan Tore Guggedal <[email protected]>
- Loading branch information
1 parent
ef836d2
commit d92a645
Showing
11 changed files
with
733 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#ifndef _MODULES_COMMON_H_ | ||
#define _MODULES_COMMON_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** @brief Set the initial state for a module. | ||
* | ||
* @note The macro requires that a state machine object named s_obj is defined and that a | ||
* state array named states is defined. | ||
* | ||
* @param _state State to set as initial. | ||
* | ||
* @return see smf_set_initial(). | ||
*/ | ||
#define STATE_SET_INITIAL(_state) smf_set_initial(SMF_CTX(&s_obj), &states[_state]) | ||
|
||
/** @brief Set the state for a module. | ||
* | ||
* @note The macro requires that a state machine object named s_obj is defined and that a | ||
* state array named states is defined. | ||
* | ||
* @param _state State to set. | ||
* | ||
* @return see smf_set_state(). | ||
*/ | ||
#define STATE_SET(_state) smf_set_state(SMF_CTX(&s_obj), &states[_state]) | ||
|
||
/** @brief Set the state for a module and handle the event. | ||
* | ||
* @note The macro requires that a state machine object named s_obj is defined and that a | ||
* state array named states is defined. | ||
* | ||
* @param _state State to set. | ||
* | ||
* @return see smf_set_handled(). | ||
*/ | ||
#define STATE_EVENT_HANDLED(_state) smf_set_handled(SMF_CTX(&s_obj)) | ||
|
||
/** @brief Run the state machine for a module. | ||
* | ||
* @note The macro requires that a state machine object named s_obj is defined. | ||
* | ||
* @return see smf_run_state(). | ||
*/ | ||
#define STATE_RUN() smf_run_state(SMF_CTX(&s_obj)) | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* _MODULES_COMMON_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.