Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
e742ad6159
|
|
@ -31,7 +31,7 @@
|
|||
</section>
|
||||
</main>
|
||||
<script>
|
||||
drawtimers(timarr_test);
|
||||
drawtimers(timarr);
|
||||
showMenu('header-toggle','navbar');
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,24 @@
|
|||
objects_test = ["scene_1", "scene_2", "scene_3", "scene_4", "scene_5", "scene_6", "scene_7", "scene_8", "scene_9", "scene_10", "scene_11", "scene_12", "scene_13", "scene_14", "scene_15", "scene_16"];
|
||||
actions_test = ["start", "stop"];
|
||||
objects_test = ["object_1", "object_2", "object_3", "object_4", "object_5", "object_6", "object_7", "object_8", "object_9", "object_10", "object_11", "object_12", "object_13", "object_14", "object_15", "object_16"];
|
||||
actions_test = ["action_1", "action_2", "action_3", "action_4"];
|
||||
timarr = [
|
||||
~crontmr(0)~,
|
||||
~crontmr(1)~,
|
||||
~crontmr(2)~,
|
||||
~crontmr(3)~,
|
||||
~crontmr(4)~,
|
||||
~crontmr(5)~,
|
||||
~crontmr(6)~,
|
||||
~crontmr(7)~,
|
||||
~crontmr(8)~,
|
||||
~crontmr(9)~,
|
||||
~crontmr(10)~,
|
||||
~crontmr(11)~,
|
||||
~crontmr(12)~,
|
||||
~crontmr(13)~,
|
||||
~crontmr(14)~,
|
||||
~crontmr(15)~
|
||||
];
|
||||
|
||||
timarr_test = [
|
||||
{ "num": 1, "enab":1, "name":"Timer1 name", "obj": 2, "act": 0, "cron": "*/2 * * * * *" },
|
||||
{ "num": 2, "enab":0, "name":"Timer2 name", "obj": 12, "act": 1, "cron": "6 0 12 * * *" },
|
||||
|
|
@ -28,7 +47,7 @@ payload += "\"act\":"+document.getElementById("action"+n).value+",";
|
|||
payload += "\"cron\":\""+document.getElementById("cron"+n).value+"\"";
|
||||
payload += "}";
|
||||
console.log(payload);
|
||||
PostData(payload, "application.html", false, false, false);
|
||||
PostData(payload, "application.html", false, false, true);
|
||||
}
|
||||
|
||||
function extractSelectArr(select)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ dependencies:
|
|||
source:
|
||||
type: idf
|
||||
version: 4.4.4
|
||||
manifest_hash: 31dd4ec84ade1450fc168388f4adce2efacd1516170670735140bc772e9d72bd
|
||||
manifest_hash: f9b3d78d7d56685d1c543701158a0fab7a56c908117ed70644f77e4247c831ae
|
||||
target: esp32
|
||||
version: 1.0.0
|
||||
|
|
|
|||
|
|
@ -39,9 +39,26 @@
|
|||
* the default values will be loaded.
|
||||
*/
|
||||
|
||||
#define CRON_TIMERS_NUMBER (16)
|
||||
#define TIMER_NAME_LENGTH (16)
|
||||
#define TIMER_CRONSTRING_LENGTH (32)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int num;
|
||||
bool enab;
|
||||
char name[TIMER_NAME_LENGTH];
|
||||
int obj;
|
||||
int act;
|
||||
char cron[TIMER_CRONSTRING_LENGTH];
|
||||
} cron_timer_t;
|
||||
|
||||
typedef struct appconf
|
||||
{
|
||||
int test;
|
||||
|
||||
cron_timer_t Timers[CRON_TIMERS_NUMBER];
|
||||
|
||||
} APP_CONFIG;
|
||||
|
||||
void UserInitIO(void);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "webguiapp.h"
|
||||
#include "cron.h"
|
||||
#include "jobs.h"
|
||||
#include "AppConfiguration.h"
|
||||
|
||||
int HTTPPrintCustom(httpd_req_t *req, char *buf, char *var, int arg);
|
||||
HTTP_IO_RESULT AfterPostHandlerCustom(httpd_req_t *req, const char *filename, char *PostData);
|
||||
|
|
@ -17,6 +18,12 @@ void app_main(void)
|
|||
regAfterPostHandlerCustom(&AfterPostHandlerCustom);
|
||||
regUserEventHandler(&UserMQTTEventHndlr, (void*)my_context_data);
|
||||
WebGuiAppInit();
|
||||
if (GetUserAppNeedReset())
|
||||
{
|
||||
SetUserAppNeedReset(false);
|
||||
ESP_ERROR_CHECK(InitAppConfig());
|
||||
}
|
||||
ESP_ERROR_CHECK(InitAppConfig());
|
||||
|
||||
void test_cron_job_sample_callback(cron_job *job)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -113,6 +113,15 @@ void ResetAppConfig(APP_CONFIG *Conf)
|
|||
{
|
||||
//default init test param
|
||||
GetAppConf()->test = 0;
|
||||
for (int i = 0; i < CRON_TIMERS_NUMBER; i++ )
|
||||
{
|
||||
GetAppConf()->Timers[i].num = i+1;
|
||||
GetAppConf()->Timers[i].enab = false;
|
||||
GetAppConf()->Timers[i].obj = 0;
|
||||
GetAppConf()->Timers[i].act = 0;
|
||||
strcpy(GetAppConf()->Timers[i].name, "Timer Name");
|
||||
strcpy(GetAppConf()->Timers[i].cron, "* * * * * *");
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t ReadNVSAppConfig(APP_CONFIG *AppConf)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* \copyright Apache License, Version 2.0
|
||||
*/
|
||||
#include "webguiapp.h"
|
||||
#include "jRead.h"
|
||||
#include "AppConfiguration.h"
|
||||
|
||||
const char pg_40[] = "index40.html";
|
||||
const char pg_42[] = "index42.html";
|
||||
|
|
@ -37,7 +39,6 @@ static HTTP_IO_RESULT HTTPPostApplication(httpd_req_t *req, char *PostData);
|
|||
HTTP_IO_RESULT AfterPostHandlerCustom(httpd_req_t *req, const char *filename, char *PostData)
|
||||
{
|
||||
|
||||
|
||||
if (!memcmp(filename, pg_40, sizeof(pg_40)))
|
||||
return HTTPPostIndex40(req, PostData);
|
||||
if (!memcmp(filename, pg_42, sizeof(pg_42)))
|
||||
|
|
@ -52,13 +53,26 @@ HTTP_IO_RESULT AfterPostHandlerCustom(httpd_req_t *req, const char *filename, ch
|
|||
return HTTP_IO_DONE;
|
||||
}
|
||||
|
||||
|
||||
static HTTP_IO_RESULT HTTPPostApplication(httpd_req_t *req, char *PostData)
|
||||
{
|
||||
char tmp[512];
|
||||
if (httpd_query_key_value(PostData, "tmrec", tmp, sizeof(tmp)) == ESP_OK)
|
||||
{
|
||||
ESP_LOGI("HTTP_POST", "%s", tmp);
|
||||
struct jReadElement result;
|
||||
cron_timer_t T = {0};
|
||||
jRead(tmp, "", &result);
|
||||
if (result.dataType == JREAD_OBJECT)
|
||||
{
|
||||
T.num = jRead_int(tmp, "{'num'", NULL);
|
||||
T.enab = jRead_int(tmp, "{'enab'", NULL);
|
||||
jRead_string(tmp, "{'name'", T.name, sizeof(T.name), NULL);
|
||||
T.obj = jRead_int(tmp, "{'obj'", NULL);
|
||||
T.act = jRead_int(tmp, "{'act'", NULL);
|
||||
jRead_string(tmp, "{'cron'", T.cron, sizeof(T.cron), NULL);
|
||||
memcpy(&GetAppConf()->Timers[T.num-1], &T, sizeof(cron_timer_t));
|
||||
WriteNVSAppConfig(GetAppConf());
|
||||
}
|
||||
}
|
||||
return HTTP_IO_DONE;
|
||||
}
|
||||
|
|
@ -136,4 +150,3 @@ static HTTP_IO_RESULT HTTPPostIndex44(httpd_req_t *req, char *PostData)
|
|||
return HTTP_IO_DONE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,29 @@
|
|||
* \copyright Apache License, Version 2.0
|
||||
*/
|
||||
#include "webguiapp.h"
|
||||
#include "jWrite.h"
|
||||
#include "AppConfiguration.h"
|
||||
|
||||
static void HTTPPrint_crontmr(char *VarData, void *arg)
|
||||
{
|
||||
int idx = *((int*)(arg));
|
||||
if(idx < CRON_TIMERS_NUMBER)
|
||||
{
|
||||
char data[256];
|
||||
cron_timer_t T;
|
||||
memcpy(&T, &GetAppConf()->Timers[idx], sizeof(cron_timer_t));
|
||||
jwOpen(data, sizeof(data), JW_OBJECT, JW_COMPACT);
|
||||
jwObj_int("num", (unsigned int) T.num);
|
||||
jwObj_int("enab", (T.enab)?1:0);
|
||||
jwObj_string("name", T.name);
|
||||
jwObj_int("obj", (unsigned int) T.obj);
|
||||
jwObj_int("act", (unsigned int) T.act);
|
||||
jwObj_string("cron", T.cron);
|
||||
jwEnd();
|
||||
jwClose();
|
||||
snprintf(VarData, MAX_DYNVAR_LENGTH, "%s", data);
|
||||
}
|
||||
}
|
||||
|
||||
//Default string if not found handler
|
||||
static void HTTPPrint_DEF(char *VarData, void *arg)
|
||||
|
|
@ -35,6 +58,7 @@ static void HTTPPrint_status_fail(char *VarData, void *arg)
|
|||
|
||||
dyn_var_handler_t HANDLERS_ARRAY_CUST[] = {
|
||||
|
||||
{ "crontmr", sizeof("crontmr") - 1, &HTTPPrint_crontmr },
|
||||
/*ERROR report*/
|
||||
{ "status_fail", sizeof("status_fail") - 1, &HTTPPrint_status_fail },
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user