diff --git a/TC1/http_server/app_httpd.c b/TC1/http_server/app_httpd.c index 1c20872..bccdef5 100644 --- a/TC1/http_server/app_httpd.c +++ b/TC1/http_server/app_httpd.c @@ -43,7 +43,7 @@ #include "user_power.h" #include "main.h" #include "web_data.c" -#include"timed_task/timed_task.h" +#include "timed_task/timed_task.h" static bool is_http_init; static bool is_handlers_registered; @@ -219,14 +219,15 @@ static int HttpAddTask(httpd_request_t *req) //TODO 从url获取参数 char buf[16] = "5 1234567 0"; //假设已经获取到了. - TimedTask task; + struct TimedTask task; sscanf(buf, "%d %d %d", &task.time, &task.socket_idx, &task.on); - char mess[] = AddTask(task) ? "OK" : "NO"; + char* mess = AddTask(&task) ? "OK" : "NO"; OSStatus err = kNoErr; send_http(mess, strlen(mess), exit, &err); exit: + return err; } static int HttpDelTask(httpd_request_t *req) @@ -237,11 +238,12 @@ static int HttpDelTask(httpd_request_t *req) int time; sscanf(buf, "%d", &time); - char mess[] = DelTask(time) ? "OK" : "NO"; + char* mess = DelTask(time) ? "OK" : "NO"; OSStatus err = kNoErr; send_http(mess, strlen(mess), exit, &err); exit: + return err; } struct httpd_wsgi_call g_app_handlers[] = { diff --git a/TC1/main.c b/TC1/main.c index 413a46c..72c37fb 100644 --- a/TC1/main.c +++ b/TC1/main.c @@ -8,7 +8,7 @@ #include "mqtt_server/user_mqtt_client.h" #include "mqtt_server/user_function.h" #include "http_server/app_httpd.h" -#include "time_task/time_task.h" +#include "timed_task/timed_task.h" #define os_log(format, ...) custom_log("TC1", format, ##__VA_ARGS__); web_log(format, ##__VA_ARGS__) diff --git a/TC1/timed_task/timed_task.c b/TC1/timed_task/timed_task.c index 5807681..231e0e3 100644 --- a/TC1/timed_task/timed_task.c +++ b/TC1/timed_task/timed_task.c @@ -64,7 +64,7 @@ bool DelTask(int time) { pTimedTask tmp = task_top; task_top = task_top->next; - free(task_top); + free(tmp); return true; } else if (task_top->next == NULL)