Skip to content

Bring changes from Bb repo #3

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "library/ccronexpr"]
path = library/ccronexpr
url = https://github.com/staticlibs/ccronexpr.git
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(COMPONENT_ADD_INCLUDEDIRS "." "include" "library/ccronexpr" "library/jobs")
set(COMPONENT_SRCDIRS "." "library/ccronexpr" "library/jobs")

register_component()

target_compile_definitions(${COMPONENT_TARGET} PUBLIC -D CRON_USE_LOCAL_TIME)
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@

This is a cron-like clone for the esp-idf framework. It uses cron-like sytanx and time libraries included in newlib (esp-idf framework) for task scheduling.

## How to clone

To clone this module you need to do it recursively.

After you add the submodule you should run `git submodule update --init --recursive`

## How to use

We tried to keep module functions interface at minimum there is a creator, a destroyer a cron module starter and a cron module stopper. The workflow would be to define at least one job and then start the module. Then create and destroy jobs as desired. Keep in mind that if there are no jobs to be scheduled the cron module will stop itself, this is by design as we don't want to waste cpu time.
We tried to keep functions modules at minimum there is a creator, a destroyer a cron module starter and a cron module stopper. The workflow would be to define at least one job and then start the module. Then create and destroy jobs as desired. Keep in mind that if there are no jobs to be scheduled the cron module will stop itself.

Please remember that this module relies heavilly on the time.h library. **Time has to be initialized before any job creation.** The library time.h can be set manually or with another component like sntp, but it must have started before to this module is in use. This component will not perform any checks to idetify if time has been set.
Please keep in mind that this module relies heavilly on the time.h library. **Time has to be initialized before any job creation.** The library time.h can be set manually or with another component like sntp, but it must have started before to this module usage.

### Create

Usage is pretty simple, we provided a component factory for cron-job creation.

Usage is pretty simple, we provided a component factory for cron-job creation. Please note that `cron_job_create()` will call `cron_start()` if the module is not running

```C
cron_job *cron_job_create(const char *schedule, cron_job_callback callback, void *data)
Expand Down Expand Up @@ -73,7 +78,7 @@ int cron_stop();

### Clearing all jobs a.k.a destroying all jobs

We defined a helper to stop all cron jobs, we think it might be useful in some situations
We defined a helper to stop all cron jobs, we think it might be useful in some situations. This function calls `cron_stop()`

```C
int cron_job_clear_all();
Expand Down
7 changes: 3 additions & 4 deletions component.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ESP_IDF=${IDF_PATH}
COMPONENT_ADD_INCLUDEDIRS := include ${ESP_IDF}/tools/unit-test-app/components/unity/include/ library/ccronexpr library/jobs .
COMPONENT_SRCDIRS := library/ccronexpr library/jobs test src .
CFLAGS += -D CRON_USE_LOCAL_TIME
COMPONENT_ADD_INCLUDEDIRS += library/ccronexpr library/jobs
COMPONENT_SRCDIRS += library/ccronexpr library/jobs
CPPFLAGS += -D CRON_USE_LOCAL_TIME
Loading