");
@@ -244,17 +219,17 @@ function drawtimers(tarr) {
content += ("
");
content +=("
");
content += ("
");
content += ("
");
content +=("
");
content += ("
");
content += ("
");
@@ -272,11 +247,4 @@ function drawtimers(tarr) {
}
target.innerHTML = content;
}
-function applytm() {
-}
-function addtm() {
- var num = timarr_test.length + 1;
- timarr_test.push({ 'num': num, 'enab':1, 'name':'Timer'+num+' name', 'obj': 0, 'act': 0, 'cron': '* * * * * *' });
- drawtimers(timarr_test);
-}
\ No newline at end of file
diff --git a/main/include/AppConfiguration.h b/main/include/AppConfiguration.h
index f6965dc..2e66c95 100644
--- a/main/include/AppConfiguration.h
+++ b/main/include/AppConfiguration.h
@@ -51,6 +51,7 @@ typedef struct
int obj;
int act;
char cron[TIMER_CRONSTRING_LENGTH];
+ bool del;
} cron_timer_t;
typedef struct appconf
diff --git a/main/src/AppConfiguration.c b/main/src/AppConfiguration.c
index bee4119..48de8f3 100644
--- a/main/src/AppConfiguration.c
+++ b/main/src/AppConfiguration.c
@@ -116,11 +116,12 @@ void ResetAppConfig(APP_CONFIG *Conf)
for (int i = 0; i < CRON_TIMERS_NUMBER; i++ )
{
GetAppConf()->Timers[i].num = i+1;
- GetAppConf()->Timers[i].enab = false;
+ GetAppConf()->Timers[i].enab = true;
GetAppConf()->Timers[i].obj = 0;
GetAppConf()->Timers[i].act = 0;
strcpy(GetAppConf()->Timers[i].name, "Timer Name");
strcpy(GetAppConf()->Timers[i].cron, "* * * * * *");
+ GetAppConf()->Timers[i].del = true;
}
}
diff --git a/main/src/HTTPPostCustom.c b/main/src/HTTPPostCustom.c
index 7ef3976..db13048 100644
--- a/main/src/HTTPPostCustom.c
+++ b/main/src/HTTPPostCustom.c
@@ -70,10 +70,34 @@ static HTTP_IO_RESULT HTTPPostApplication(httpd_req_t *req, char *PostData)
T.obj = jRead_int(tmp, "{'obj'", NULL);
T.act = jRead_int(tmp, "{'act'", NULL);
jRead_string(tmp, "{'cron'", T.cron, sizeof(T.cron), NULL);
+ T.del = jRead_int(tmp, "{'del'", NULL);
memcpy(&GetAppConf()->Timers[T.num-1], &T, sizeof(cron_timer_t));
WriteNVSAppConfig(GetAppConf());
}
}
+ if (httpd_query_key_value(PostData, "deltimer", tmp, sizeof(tmp)) == ESP_OK)
+ {
+ int num = (atoi(tmp) - 1);
+ if(num >= 0 && num <16)
+ {
+ GetAppConf()->Timers[num].del = true;
+ }
+ return HTTP_IO_DONE;
+ }
+ if (httpd_query_key_value(PostData, "addtimer", tmp, sizeof(tmp)) == ESP_OK)
+ {
+ for(int i = 0; i< CRON_TIMERS_NUMBER; i++)
+ {
+ if(GetAppConf()->Timers[i].del == 1)
+ {
+ GetAppConf()->Timers[i].del = 0;
+
+ return HTTP_IO_DONE;
+ }
+ }
+ }
+
+
return HTTP_IO_DONE;
}
diff --git a/main/src/HTTPPrintCustom.c b/main/src/HTTPPrintCustom.c
index 8fab5ee..ad2aee7 100644
--- a/main/src/HTTPPrintCustom.c
+++ b/main/src/HTTPPrintCustom.c
@@ -39,6 +39,7 @@ static void HTTPPrint_crontmr(char *VarData, void *arg)
jwObj_int("obj", (unsigned int) T.obj);
jwObj_int("act", (unsigned int) T.act);
jwObj_string("cron", T.cron);
+ jwObj_int("del", (T.del)?1:0);
jwEnd();
jwClose();
snprintf(VarData, MAX_DYNVAR_LENGTH, "%s", data);