-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs for main module #129
Merged
Merged
Docs for main module #129
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,11 +1,105 @@ | ||
# Main module | ||
# Main Module | ||
|
||
What does this module do | ||
The Main module serves as the central control unit of the Asset Tracker Template application. It implements a hierarchical state machine that coordinates the activities of all other modules through [zbus](https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/services/zbus/index.html) messages. | ||
This module handles the application's business logic, including cloud connectivity, data sampling, firmware updates, configuration updates, and user interactions. | ||
|
||
## Messages | ||
|
||
The main module does not implement messages available to other modules. Instead, it processes messages from other modules to control the application's behavior. | ||
It subscribes to messages on the following zbus channels: | ||
|
||
The Main module uses the following zbus channels, both for subscribing to incoming data and publishing outbound requests or status updates: | ||
|
||
* **BUTTON_CHAN** | ||
- Processes user button presses for manually triggering data samples. | ||
|
||
* **CLOUD_CHAN** | ||
- Receive connectivity status (connected, disconnected) and cloud response data. | ||
- Trigger device shadow polling to retrieve configuration updates. | ||
|
||
* **ENVIRONMENTAL_CHAN** | ||
- Request sensor data from the environmental module. | ||
|
||
* **FOTA_CHAN** | ||
- Poll for FOTA updates and manage the FOTA process. | ||
- Apply FOTA updates to install the new firmware image. | ||
|
||
* **LED_CHAN** | ||
- Update LED pattern to indicate system state. | ||
|
||
* **LOCATION_CHAN** | ||
- Requests new location data when a sample is due. | ||
|
||
* **NETWORK_CHAN** | ||
- Control LTE network connection. | ||
- Track cellular connectivity events. | ||
- Request network quality samples. | ||
|
||
* **POWER_CHAN** | ||
- Request battery status. | ||
- Initiate low-power mode. | ||
|
||
* **TIMER_CHAN** | ||
- Handle timer events for sampling. | ||
|
||
|
||
## Configurations | ||
|
||
Kconfig and device tree | ||
The Main module can be configured using the following Kconfig options: | ||
|
||
* **CONFIG_APP_LOG_LEVEL** | ||
Controls logging level for the main module. | ||
|
||
* **CONFIG_APP_MODULE_TRIGGER_TIMEOUT_SECONDS** | ||
Default data sampling interval. | ||
|
||
* **CONFIG_APP_REQUEST_NETWORK_QUALITY** | ||
When enabled, requests network quality metrics during regular sampling. | ||
|
||
* **CONFIG_APP_MSG_PROCESSING_TIMEOUT_SECONDS** | ||
Maximum time allowed for processing a single message. | ||
|
||
* **CONFIG_APP_WATCHDOG_TIMEOUT_SECONDS** | ||
Defines the watchdog timeout for the main module. | ||
|
||
|
||
## State Diagram | ||
|
||
The Main module implements a hierarchical state machine with the following states: | ||
|
||
```mermaid | ||
stateDiagram-v2 | ||
[*] --> STATE_RUNNING | ||
|
||
state STATE_RUNNING { | ||
[*] --> STATE_IDLE | ||
|
||
STATE_IDLE --> STATE_TRIGGERING : CLOUD_CONNECTED_READY_TO_SEND | ||
STATE_TRIGGERING --> STATE_IDLE : CLOUD_DISCONNECTED/CLOUD_CONNECTED_PAUSED | ||
|
||
state STATE_TRIGGERING { | ||
[*] --> STATE_SAMPLE_DATA | ||
STATE_WAIT_FOR_TRIGGER --> STATE_SAMPLE_DATA : timer_trigger/button_press | ||
|
||
STATE_SAMPLE_DATA --> STATE_WAIT_FOR_TRIGGER : LOCATION_SEARCH_DONE | ||
} | ||
} | ||
|
||
STATE_RUNNING --> STATE_FOTA : FOTA_DOWNLOADING_UPDATE | ||
|
||
state STATE_FOTA { | ||
[*] --> STATE_FOTA_DOWNLOADING | ||
|
||
STATE_FOTA_DOWNLOADING --> STATE_FOTA_WAITING_FOR_NETWORK_DISCONNECT : FOTA_SUCCESS_REBOOT_NEEDED | ||
STATE_FOTA_DOWNLOADING --> STATE_FOTA_WAITING_FOR_NETWORK_DISCONNECT_TO_APPLY_IMAGE : FOTA_IMAGE_APPLY_NEEDED | ||
|
||
STATE_FOTA_WAITING_FOR_NETWORK_DISCONNECT --> STATE_FOTA_REBOOTING : NETWORK_DISCONNECTED | ||
|
||
STATE_FOTA_WAITING_FOR_NETWORK_DISCONNECT_TO_APPLY_IMAGE --> STATE_FOTA_APPLYING_IMAGE : NETWORK_DISCONNECTED | ||
STATE_FOTA_APPLYING_IMAGE --> STATE_FOTA_REBOOTING : FOTA_SUCCESS_REBOOT_NEEDED | ||
|
||
STATE_FOTA_REBOOTING --> [*] : sys_reboot() | ||
} | ||
|
||
## State diagram | ||
STATE_FOTA --> STATE_RUNNING : FOTA_DOWNLOAD_CANCELED/TIMED_OUT/FAILED | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of
APP_MODULE_THREAD_STACK_SIZE
might affect users who need to configure the stack size for specific application requirements. Consider providing documentation or guidance on how stack sizes are managed after this change.