From e83e5011550c0db47f14ec718b1e28e13214fa45 Mon Sep 17 00:00:00 2001
From: Stephan Hadinger
Date: Mon, 21 Feb 2022 22:22:30 +0100
Subject: [PATCH 1/2] Berry add cron timers
---
lib/libesp32/berry/default/be_modtab.c | 2 +
lib/libesp32/berry/generate/be_const_strtab.h | 8 +
.../berry/generate/be_const_strtab_def.h | 2114 +++++++++--------
.../generate/be_fixed_be_class_ccronexpr.h | 20 +
.../generate/be_fixed_be_class_tasmota.h | 158 +-
.../berry_mapping/src/be_class_wrapper.c | 8 +
.../berry_tasmota/src/be_cron_class.cpp | 66 +
.../berry_tasmota/src/be_tasmotalib.c | 509 ++--
.../berry_tasmota/src/be_trigger_class.c | 60 +-
.../berry_tasmota/src/embedded/Tasmota.be | 92 +-
lib/libesp32/ccronexpr/LICENSE.txt | 201 ++
lib/libesp32/ccronexpr/README.md | 97 +
lib/libesp32/ccronexpr/appveyor.yml | 29 +
lib/libesp32/ccronexpr/ccronexpr.c | 1272 ++++++++++
lib/libesp32/ccronexpr/ccronexpr.h | 95 +
lib/libesp32/ccronexpr/ccronexpr_test.c | 409 ++++
lib/libesp32/ccronexpr/library.json | 17 +
tasmota/xdrv_52_9_berry.ino | 1 +
18 files changed, 3844 insertions(+), 1314 deletions(-)
create mode 100644 lib/libesp32/berry/generate/be_fixed_be_class_ccronexpr.h
create mode 100644 lib/libesp32/berry_tasmota/src/be_cron_class.cpp
create mode 100644 lib/libesp32/ccronexpr/LICENSE.txt
create mode 100644 lib/libesp32/ccronexpr/README.md
create mode 100644 lib/libesp32/ccronexpr/appveyor.yml
create mode 100644 lib/libesp32/ccronexpr/ccronexpr.c
create mode 100644 lib/libesp32/ccronexpr/ccronexpr.h
create mode 100644 lib/libesp32/ccronexpr/ccronexpr_test.c
create mode 100644 lib/libesp32/ccronexpr/library.json
diff --git a/lib/libesp32/berry/default/be_modtab.c b/lib/libesp32/berry/default/be_modtab.c
index 3bc875f47..684174821 100644
--- a/lib/libesp32/berry/default/be_modtab.c
+++ b/lib/libesp32/berry/default/be_modtab.c
@@ -167,6 +167,7 @@ extern void be_load_webclient_lib(bvm *vm);
extern void be_load_tcpclient_lib(bvm *vm);
extern void be_load_udp_lib(bvm *vm);
extern void be_load_crypto_lib(bvm *vm);
+extern void be_load_ccronexpr_class(bvm *vm);
extern void be_load_Leds_ntv_class(bvm *vm);
extern void be_load_Leds_class(bvm *vm);
extern void be_load_Leds_animator_class(bvm *vm);
@@ -207,6 +208,7 @@ BERRY_API void be_load_custom_libs(bvm *vm)
be_load_md5_lib(vm);
be_load_serial_lib(vm);
be_load_ctypes_lib(vm);
+ be_load_ccronexpr_class(vm);
#ifdef USE_LIGHT
be_load_light_state_class(vm);
#endif
diff --git a/lib/libesp32/berry/generate/be_const_strtab.h b/lib/libesp32/berry/generate/be_const_strtab.h
index d99ac8b6b..5dbac143f 100644
--- a/lib/libesp32/berry/generate/be_const_strtab.h
+++ b/lib/libesp32/berry/generate/be_const_strtab.h
@@ -199,6 +199,7 @@ extern const bcstring be_const_str__buffer;
extern const bcstring be_const_str__ccmd;
extern const bcstring be_const_str__class;
extern const bcstring be_const_str__cmd;
+extern const bcstring be_const_str__crons;
extern const bcstring be_const_str__debug_present;
extern const bcstring be_const_str__def;
extern const bcstring be_const_str__dirty;
@@ -228,6 +229,7 @@ extern const bcstring be_const_str_acos;
extern const bcstring be_const_str_add;
extern const bcstring be_const_str_add_anim;
extern const bcstring be_const_str_add_cmd;
+extern const bcstring be_const_str_add_cron;
extern const bcstring be_const_str_add_driver;
extern const bcstring be_const_str_add_event_cb;
extern const bcstring be_const_str_add_fast_loop;
@@ -283,6 +285,7 @@ extern const bcstring be_const_str_cb;
extern const bcstring be_const_str_cb_do_nothing;
extern const bcstring be_const_str_cb_event_closure;
extern const bcstring be_const_str_cb_obj;
+extern const bcstring be_const_str_ccronexpr;
extern const bcstring be_const_str_ceil;
extern const bcstring be_const_str_char;
extern const bcstring be_const_str_chars_in_string;
@@ -385,6 +388,7 @@ extern const bcstring be_const_str_event;
extern const bcstring be_const_str_event_cb;
extern const bcstring be_const_str_event_send;
extern const bcstring be_const_str_every_100ms;
+extern const bcstring be_const_str_every_250ms;
extern const bcstring be_const_str_every_50ms;
extern const bcstring be_const_str_every_second;
extern const bcstring be_const_str_except;
@@ -577,10 +581,12 @@ extern const bcstring be_const_str_month;
extern const bcstring be_const_str_montserrat_font;
extern const bcstring be_const_str_name;
extern const bcstring be_const_str_nan;
+extern const bcstring be_const_str_next;
extern const bcstring be_const_str_nil;
extern const bcstring be_const_str_no_X20GPIO_X20specified_X20for_X20neopixelbus;
extern const bcstring be_const_str_null_cb;
extern const bcstring be_const_str_number;
+extern const bcstring be_const_str_o;
extern const bcstring be_const_str_obj_class_create_obj;
extern const bcstring be_const_str_obj_event_base;
extern const bcstring be_const_str_offset;
@@ -647,6 +653,7 @@ extern const bcstring be_const_str_remote_ip;
extern const bcstring be_const_str_remote_port;
extern const bcstring be_const_str_remove;
extern const bcstring be_const_str_remove_cmd;
+extern const bcstring be_const_str_remove_cron;
extern const bcstring be_const_str_remove_driver;
extern const bcstring be_const_str_remove_light;
extern const bcstring be_const_str_remove_rule;
@@ -673,6 +680,7 @@ extern const bcstring be_const_str_rtc;
extern const bcstring be_const_str_rule;
extern const bcstring be_const_str_run;
extern const bcstring be_const_str_run_bat;
+extern const bcstring be_const_str_run_cron;
extern const bcstring be_const_str_run_deferred;
extern const bcstring be_const_str_running;
extern const bcstring be_const_str_sat;
diff --git a/lib/libesp32/berry/generate/be_const_strtab_def.h b/lib/libesp32/berry/generate/be_const_strtab_def.h
index 763f364a5..abf3e7d10 100644
--- a/lib/libesp32/berry/generate/be_const_strtab_def.h
+++ b/lib/libesp32/berry/generate/be_const_strtab_def.h
@@ -1,844 +1,852 @@
-be_define_const_str(, "", 2166136261u, 0, 0, &be_const_str_SERIAL_6E1);
-be_define_const_str(_X0A, "\n", 252472541u, 0, 1, NULL);
-be_define_const_str(_X20, " ", 621580159u, 0, 1, &be_const_str_Unknown);
-be_define_const_str(_X21_X3D, "!=", 2428715011u, 0, 2, &be_const_str_LVG_X3A_X20object_X3A);
-be_define_const_str(_X21_X3D_X3D, "!==", 559817114u, 0, 3, &be_const_str_SERIAL_7O1);
-be_define_const_str(_X22, "\"", 655135397u, 0, 1, &be_const_str__X2Ep);
-be_define_const_str(_X22_X3A, "\":", 399167565u, 0, 2, NULL);
-be_define_const_str(_X23, "#", 638357778u, 0, 1, &be_const_str_a);
-be_define_const_str(_X23autoexec_X2Ebat, "#autoexec.bat", 3382890497u, 0, 13, &be_const_str_min);
-be_define_const_str(_X23autoexec_X2Ebe, "#autoexec.be", 1181757091u, 0, 12, &be_const_str__X3Coption_X20value_X3D_X27reset_X27_X3E_X26lt_X3BRemove_X20autoconf_X26gt_X3B_X3C_X2Foption_X3E);
+be_define_const_str(, "", 2166136261u, 0, 0, &be_const_str_before_del);
+be_define_const_str(_X0A, "\n", 252472541u, 0, 1, &be_const_str__X3Cbutton_X20name_X3D_X27reapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3ERe_X2Dapply_X20current_X20configuration_X3C_X2Fbutton_X3E);
+be_define_const_str(_X20, " ", 621580159u, 0, 1, &be_const_str_delay);
+be_define_const_str(_X21_X3D, "!=", 2428715011u, 0, 2, &be_const_str__X3Cselect_X20name_X3D_X27zip_X27_X3E);
+be_define_const_str(_X21_X3D_X3D, "!==", 559817114u, 0, 3, NULL);
+be_define_const_str(_X22, "\"", 655135397u, 0, 1, &be_const_str_name);
+be_define_const_str(_X22_X3A, "\":", 399167565u, 0, 2, &be_const_str_destructor_cb);
+be_define_const_str(_X23, "#", 638357778u, 0, 1, &be_const_str_group_def);
+be_define_const_str(_X23autoexec_X2Ebat, "#autoexec.bat", 3382890497u, 0, 13, &be_const_str_atleast1);
+be_define_const_str(_X23autoexec_X2Ebe, "#autoexec.be", 1181757091u, 0, 12, &be_const_str_h);
be_define_const_str(_X23display_X2Eini, "#display.ini", 182218220u, 0, 12, NULL);
-be_define_const_str(_X23init_X2Ebat, "#init.bat", 3297595077u, 0, 9, &be_const_str_bool);
-be_define_const_str(_X23preinit_X2Ebe, "#preinit.be", 687035716u, 0, 11, &be_const_str_setitem);
-be_define_const_str(_X2502d_X25s_X2502d, "%02d%s%02d", 1587999717u, 0, 10, NULL);
-be_define_const_str(_X2504d_X2D_X2502d_X2D_X2502dT_X2502d_X3A_X2502d_X3A_X2502d, "%04d-%02d-%02dT%02d:%02d:%02d", 3425528601u, 0, 29, &be_const_str_refr_size);
-be_define_const_str(_X2508x_X2D_X2504x_X2D_X2504x_X2D_X2504x_X2D_X2504x_X2508x, "%08x-%04x-%04x-%04x-%04x%08x", 1670063141u, 0, 28, &be_const_str_ceil);
-be_define_const_str(_X25s_X2Eautoconf, "%s.autoconf", 3560383524u, 0, 11, &be_const_str_area);
-be_define_const_str(_X26lt_X3BError_X3A_X20apply_X20new_X20or_X20remove_X26gt_X3B, "<Error: apply new or remove>", 2855507949u, 0, 34, &be_const_str_keys);
-be_define_const_str(_X26lt_X3BNone_X26gt_X3B, "<None>", 2602165498u, 0, 12, &be_const_str_char);
-be_define_const_str(_X28_X29, "()", 685372826u, 0, 2, &be_const_str_get_log);
-be_define_const_str(_X2B, "+", 772578730u, 0, 1, &be_const_str_tomap);
-be_define_const_str(_X2C, ",", 688690635u, 0, 1, &be_const_str__settings_def);
-be_define_const_str(_X2C_X22AXP192_X22_X3A_X7B_X22VBusVoltage_X22_X3A_X25_X2E3f_X2C_X22VBusCurrent_X22_X3A_X25_X2E1f_X2C_X22BattVoltage_X22_X3A_X25_X2E3f_X2C_X22BattCurrent_X22_X3A_X25_X2E1f_X2C_X22Temperature_X22_X3A_X25_X2E1f_X7D, ",\"AXP192\":{\"VBusVoltage\":%.3f,\"VBusCurrent\":%.1f,\"BattVoltage\":%.3f,\"BattCurrent\":%.1f,\"Temperature\":%.1f}", 2598755376u, 0, 106, &be_const_str_attrdump);
-be_define_const_str(_X2D_X2D_X3A_X2D_X2D, "--:--", 1370615441u, 0, 5, &be_const_str__energy);
-be_define_const_str(_X2E, ".", 722245873u, 0, 1, &be_const_str__X3Clambda_X3E);
-be_define_const_str(_X2E_X2E, "..", 2748622605u, 0, 2, &be_const_str__X2Fac);
-be_define_const_str(_X2Eautoconf, ".autoconf", 2524679088u, 0, 9, &be_const_str_get_current_module_name);
-be_define_const_str(_X2Ebe, ".be", 1325797348u, 0, 3, &be_const_str__dirty);
-be_define_const_str(_X2Ebec, ".bec", 3985273221u, 0, 4, NULL);
-be_define_const_str(_X2Elen, ".len", 850842136u, 0, 4, &be_const_str_BRY_X3A_X20Exception_X3E_X20_X27_X25s_X27_X20_X2D_X20_X25s);
-be_define_const_str(_X2Ep, ".p", 1171526419u, 0, 2, &be_const_str_event_send);
-be_define_const_str(_X2Ep1, ".p1", 249175686u, 0, 3, &be_const_str_minute);
-be_define_const_str(_X2Ep2, ".p2", 232398067u, 0, 3, &be_const_str_clear_first_time);
-be_define_const_str(_X2Esize, ".size", 1965188224u, 0, 5, &be_const_str_make_cb);
-be_define_const_str(_X2Etapp, ".tapp", 1363391594u, 0, 5, &be_const_str_init);
-be_define_const_str(_X2Ew, ".w", 1255414514u, 0, 2, NULL);
-be_define_const_str(_X2F, "/", 705468254u, 0, 1, &be_const_str_True);
-be_define_const_str(_X2F_X2Eautoconf, "/.autoconf", 2212074393u, 0, 10, &be_const_str_get_input_power_status);
-be_define_const_str(_X2F_X3Frst_X3D, "/?rst=", 580074707u, 0, 6, &be_const_str__X3Clegend_X3E_X3Cb_X20title_X3D_X27New_X20autoconf_X27_X3E_X26nbsp_X3BSelect_X20new_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E);
-be_define_const_str(_X2Fac, "/ac", 3904651978u, 0, 3, &be_const_str_compress);
-be_define_const_str(_X2Flights_X2F, "/lights/", 2370247908u, 0, 8, NULL);
-be_define_const_str(_X2Fstate_X2F, "/state/", 4226179876u, 0, 7, NULL);
-be_define_const_str(_X3A, ":", 1057798253u, 0, 1, &be_const_str_set_text);
-be_define_const_str(_X3C, "<", 957132539u, 0, 1, &be_const_str_r);
-be_define_const_str(_X3C_X2Fform_X3E_X3C_X2Fp_X3E, "
", 3546571739u, 0, 11, &be_const_str_ctor);
-be_define_const_str(_X3C_X2Fselect_X3E_X3Cp_X3E_X3C_X2Fp_X3E, "", 1863865923u, 0, 16, &be_const_str_srand);
-be_define_const_str(_X3C_X3D, "<=", 2499223986u, 0, 2, &be_const_str_detect);
-be_define_const_str(_X3Cbutton_X20name_X3D_X27reapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3ERe_X2Dapply_X20current_X20configuration_X3C_X2Fbutton_X3E, "", 3147934216u, 0, 82, &be_const_str_consume_mono);
-be_define_const_str(_X3Cbutton_X20name_X3D_X27zipapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3EApply_X20configuration_X3C_X2Fbutton_X3E, "", 1205771629u, 0, 72, &be_const_str__X3Cp_X3E_X3C_X2Fp_X3E_X3C_X2Ffieldset_X3E_X3Cp_X3E_X3C_X2Fp_X3E);
-be_define_const_str(_X3Cfieldset_X3E_X3Cstyle_X3E_X2Ebdis_X7Bbackground_X3A_X23888_X3B_X7D_X2Ebdis_X3Ahover_X7Bbackground_X3A_X23888_X3B_X7D_X3C_X2Fstyle_X3E, "", 2052843416u, 0, 25, &be_const_str_energy_struct);
-be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dac_X20action_X3D_X27ac_X27_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20method_X3D_X27get_X27_X3E_X3Cbutton_X3EAuto_X2Dconfiguration_X3C_X2Fbutton_X3E_X3C_X2Fform_X3E_X3C_X2Fp_X3E, "", 2058443583u, 0, 110, &be_const_str_loop);
-be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dreapply_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20action_X3D_X27_X2Fac_X27_X20method_X3D_X27post_X27_X20, "", 3546571739u, 0, 11, &be_const_str_copy);
+be_define_const_str(_X3C_X2Fselect_X3E_X3Cp_X3E_X3C_X2Fp_X3E, "", 1863865923u, 0, 16, &be_const_str_lv_extra);
+be_define_const_str(_X3C_X3D, "<=", 2499223986u, 0, 2, &be_const_str_member);
+be_define_const_str(_X3Cbutton_X20name_X3D_X27reapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3ERe_X2Dapply_X20current_X20configuration_X3C_X2Fbutton_X3E, "", 3147934216u, 0, 82, &be_const_str_True);
+be_define_const_str(_X3Cbutton_X20name_X3D_X27zipapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3EApply_X20configuration_X3C_X2Fbutton_X3E, "", 1205771629u, 0, 72, &be_const_str__archive);
+be_define_const_str(_X3Cfieldset_X3E_X3Cstyle_X3E_X2Ebdis_X7Bbackground_X3A_X23888_X3B_X7D_X2Ebdis_X3Ahover_X7Bbackground_X3A_X23888_X3B_X7D_X3C_X2Fstyle_X3E, "", 2052843416u, 0, 25, &be_const_str_pc);
+be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dac_X20action_X3D_X27ac_X27_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20method_X3D_X27get_X27_X3E_X3Cbutton_X3EAuto_X2Dconfiguration_X3C_X2Fbutton_X3E_X3C_X2Fform_X3E_X3C_X2Fp_X3E, "", 2058443583u, 0, 110, &be_const_str_c);
+be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dreapply_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20action_X3D_X27_X2Fac_X27_X20method_X3D_X27post_X27_X20, "", 3546571739u, 0, 11, &be_const_str_copy);
-be_define_const_str(_X3C_X2Fselect_X3E_X3Cp_X3E_X3C_X2Fp_X3E, "", 1863865923u, 0, 16, &be_const_str_lv_extra);
-be_define_const_str(_X3C_X3D, "<=", 2499223986u, 0, 2, &be_const_str_member);
-be_define_const_str(_X3Cbutton_X20name_X3D_X27reapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3ERe_X2Dapply_X20current_X20configuration_X3C_X2Fbutton_X3E, "", 3147934216u, 0, 82, &be_const_str_True);
-be_define_const_str(_X3Cbutton_X20name_X3D_X27zipapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3EApply_X20configuration_X3C_X2Fbutton_X3E, "", 1205771629u, 0, 72, &be_const_str__archive);
-be_define_const_str(_X3Cfieldset_X3E_X3Cstyle_X3E_X2Ebdis_X7Bbackground_X3A_X23888_X3B_X7D_X2Ebdis_X3Ahover_X7Bbackground_X3A_X23888_X3B_X7D_X3C_X2Fstyle_X3E, "", 2052843416u, 0, 25, &be_const_str_pc);
-be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dac_X20action_X3D_X27ac_X27_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20method_X3D_X27get_X27_X3E_X3Cbutton_X3EAuto_X2Dconfiguration_X3C_X2Fbutton_X3E_X3C_X2Fform_X3E_X3C_X2Fp_X3E, "", 2058443583u, 0, 110, &be_const_str_c);
-be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dreapply_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20action_X3D_X27_X2Fac_X27_X20method_X3D_X27post_X27_X20, "", 3546571739u, 0, 11, &be_const_str_try_rule);
+be_define_const_str(_X3C_X2Fselect_X3E_X3Cp_X3E_X3C_X2Fp_X3E, "", 1863865923u, 0, 16, &be_const_str_check_not_method);
+be_define_const_str(_X3C_X3D, "<=", 2499223986u, 0, 2, NULL);
+be_define_const_str(_X3Cbutton_X20name_X3D_X27reapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3ERe_X2Dapply_X20current_X20configuration_X3C_X2Fbutton_X3E, "", 3147934216u, 0, 82, &be_const_str_SERIAL_6O1);
+be_define_const_str(_X3Cbutton_X20name_X3D_X27zipapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3EApply_X20configuration_X3C_X2Fbutton_X3E, "", 1205771629u, 0, 72, &be_const_str_dimmer);
+be_define_const_str(_X3Cfieldset_X3E_X3Cstyle_X3E_X2Ebdis_X7Bbackground_X3A_X23888_X3B_X7D_X2Ebdis_X3Ahover_X7Bbackground_X3A_X23888_X3B_X7D_X3C_X2Fstyle_X3E, "", 2052843416u, 0, 25, &be_const_str_animate);
+be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dac_X20action_X3D_X27ac_X27_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20method_X3D_X27get_X27_X3E_X3Cbutton_X3EAuto_X2Dconfiguration_X3C_X2Fbutton_X3E_X3C_X2Fform_X3E_X3C_X2Fp_X3E, "", 2058443583u, 0, 110, &be_const_str_set_reachable);
+be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dreapply_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20action_X3D_X27_X2Fac_X27_X20method_X3D_X27post_X27_X20, "