Fixed TILT_STOP command issuing chain that was causing a running channel
to be stopped when an opposite direction tilting requested. For exeample:
RUN_FORWARD > TILT_REVERSE. Refs #1105 and fixes #1110.
Added a state to string public API function. There was already
a private function (`relay_chn_state_str`) that provides
this functionality. So this function has been renamed to
`relay_chn_state_to_str` and made publicly available.
Refs #1104, #1105 and closes #1108.
- Add check for empty listener list in find_listener_entry function.
- Reset notification queue when all listeners are removed.
- Change queue operation to send remove_listener message to the front of the queue.
Refs #1085, #1096 and fixes #1102
- Implemented a dedicated background task to decouple long-running code from the main application task.
- Improved the NVS commit code logic, especially for batch writes to minimize flash wear.
- Updated NVS functions to support asynchronous writes and synchronous reads.
- Added default value parameters to `get` functions for better usability.
- Improved error handling and logging in NVS operations.
- Refactored related code in multiple source files to accommodate these changes.
Refs #1085, #1096 and closes #1098
- Fixed a critical NVS key generation bug that would cause overwriting the values for all channels.
- Optimized the code for single channel mode since no formatting required.
- Improved multi-channel test coverage to cover that each value for each channel stored correctly.
Refs #1096, #1098 and fixes #1100
- Introduced a new notification module to handle state change listeners.
- Added functions to register and unregister listeners for relay channel state changes.
- Implemented a queue-based system to manage notifications and listener callbacks.
- Updated core relay channel logic to utilize the new notification system.
- Removed old listener management code from relay channel core.
- Refactored the former listener tests to notify tests and added tests for the notification system, including handling of multiple listeners and queue overflow scenarios.
- Updated CMakeLists.txt to include new source files and headers for the notification module.
- Revised README.md to include warnings about callback execution context and performance considerations.
Refs #1096, #1085 and closes #1097
The tilt sensitivity values were passed to the NVS module without
the boundaries being checked, even though the maximum
percent value is 100. This commit fixes this issue.
Also test cases are added to cover the upper boundary checks
for the tilt sensitivity settings.
Fixes #1086
- `TILT_STOP` command is prioritized in `relay_chn_tilt_issue_cmd()` because it should override any other tilt commands.
- The debug logs are cleaned up.
Fixes #1088
Refs #1085
Specific `_*all` and `_*all_with` functions were implemented to make
the API more concise and clean, and to replace the use of
`RELAY_CHN_ID_ALL`, which caused confusion within the API.
Refs #1085
Unnecessary `#if CONFIG_FOO == 1` checks were removed and the
statements were simplified to` #if CONFIG_FOO`.
`#ifdef CONFIG_FOO` statements were also changed to `#if CONFIG_FOO`
to keep the style as uniform as possible.
Refs #1085
The config parameter names defined in the relay_chn_defs.h file
have been changed back to their original names (with the CONFIG_ prefix),
so that they are not confused with application-level defines.
Refs #1085
It turned out that esp_event was adding extra complexity to the code base and it was completely unnecessary. So it has been removed from the component completely. The actions are now executed directly in the `relay_chn_distpacth_cmd()` and `relay_chn_tilt_dispatch_cmd()` functions.
This change has simplified the component as well as reduced the memory footprint.
Fixes #1084, refs #1083
- Introduced configuration options for enabling run limits in Kconfig.
- Added APIs to get and set run limits for individual relay channels.
- Implemented run limit timer functionality to automatically stop channels.
- Updated NVS handling to store and retrieve run limit values.
- Enhanced documentation in README and code comments to reflect new feature.
Closes #1080
- Optimized tilt counting data by reducing the tilt counter variables into one for smaller memory footprint. So the `relay_chn_tilt_counter_t` type is replaced by a single `uint16_t` variable in the `relay_chn_tilt_ctl_t` structure. Hence the `relay_chn_tilt_counter_t` type has been removed since it is not necessary anymore.
- Refactored tilt count handling in NVS: consolidate forward and reverse counts into a single tilt count parameter.
- Updated NVS test files that affected by the data type and function signature changes.
Fixes #1079
- Introduced NVS configuration options in Kconfig.
- Implemented NVS initialization and deinitialization in relay_chn_core.
- Added functions for storing and retrieving relay channel direction and tilt sensitivity in NVS.
- Updated relay_chn_tilt and relay_chn_output to utilize NVS for state management.
- Created relay_chn_nvs.c and relay_chn_nvs.h for NVS-related functionalities.
Closes #1074.
The addition of a single-channel mode implied further modularisation of the component. This commit has broken the component down into the following modules to avoid a huge single source file and to make unit testing easier.
The modules:
- Separation of public and private code
- *types and *defs
- public relay_chn API
- *adapter
- *output
- *run_info
- *core
- *ctl (control)
- *tilt
Closes #957.
- Replaced the buggy, oldschool, plain pointer based list approach with more robust FreeRTOS linked list implementation for the listener API. Fixes #1049.
- Added relevant test cases. Refs #1030.
The component allocates resources (timers, event loop) in relay_chn_create but never frees them. This is a resource leak.
Hence, a destroy function added to free the resources gracefully.
Fixes #1048.
Restructure the whole project tree so that the component can be unit tested. Also update some cmake files to update the modified paths, update test cases etc.
This commit adds reverse tilting capability using tilt counters.
Normally tilting action is based on the last run command of the channel
and reverse tilting was not possible before this implementation.
Reverse tilting means when TILT_REVERSE command is issued while the
last run was forward. In this case the channel will not tilt unless it has tilted
forward (TILT_FORWARD) before. If the channel has tilted forward before,
the forward tilt is counted. This tilt count is the limit for reverse tilting.
So when reverse tilting, the channel automatically will issue the TILT_STOP
command as soon as the tilt count value has reached.
Improves the code structure by reorganizing functions, minimizing
the interaction with the relay channel driving API and independizing
the tilting codes as much as possible from the plain channel driving
API for more reliable operation.
With this change the tilting API;
* has its own events and event handler
* does not depend on the channel's state change listener
* does not interfere with channel driver API
* has its own tilt command issuing logic
* has its own timing management
"relay_chn_tilt_sensitivity_set" and "relay_chn_tilt_sensitivity_get"
functions wasn't capable of dealing with "RELAY_CHN_ID_ALL"
channel ID. Hence it was causing load access system errors. This
commit fixes this bug and matures the sensitivity setter and getter.
* Add tilt feature.
* Fix the following bugs:
* warning: comparison is always true due to limited range of data type.
* Remove unnecessary esp_timer checks.
* The scheduled FREE command disrupts the current command.
* Fatal pin mapping issue.
* Make code optimizations and improvements:
* Optimize event loop queue size depending on channel count.
* Change the channels' starting state to FREE.
* Remove the unnecessary relay_chn_invalidate_inertia_timer function.
* Change the relay_chn_start_inertia_timer function as relay_chn_start_esp_timer_once and modify the function so that it be a generic esp timer start function.
* Optimize the if statement that checks the last run cmd in the relay_chn_execute_stop.