mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
优化 web_log
This commit is contained in:
@@ -227,7 +227,7 @@ exit:
|
||||
static int HttpGetLog(httpd_request_t *req)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
char* logs = GetLogRecord(0);
|
||||
char* logs = GetLogRecord();
|
||||
send_http(logs, strlen(logs), exit, &err);
|
||||
|
||||
exit:
|
||||
|
||||
@@ -24,11 +24,9 @@ void SetLogRecord(LogRecord* lr, char* log)
|
||||
*p_log = log;
|
||||
}
|
||||
|
||||
char* GetLogRecord(int idx)
|
||||
char* GetLogRecord()
|
||||
{
|
||||
if (idx > log_record.idx) return "";
|
||||
|
||||
int i = idx > 0 ? idx : (log_record.idx - LOG_NUM + 1);
|
||||
int i = log_record.idx - LOG_NUM + 1;
|
||||
i = i < 0 ? 0 : i;
|
||||
char* tmp = log_record_str;
|
||||
for (; i <= log_record.idx; i++)
|
||||
@@ -37,6 +35,7 @@ char* GetLogRecord(int idx)
|
||||
sprintf(tmp, "%s\n", log_record.logs[i%LOG_NUM]);
|
||||
tmp += strlen(tmp);
|
||||
}
|
||||
sprintf(tmp, "%d", log_record.idx);
|
||||
return log_record_str;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ extern time_t now;
|
||||
extern char time_buf[];
|
||||
|
||||
void SetLogRecord(LogRecord* lr, char* log);
|
||||
char* GetLogRecord(int idx);
|
||||
char* GetLogRecord();
|
||||
|
||||
#define web_log(format, ...) \
|
||||
LOG_TMP = (char*)malloc(sizeof(char)*LOG_LEN); \
|
||||
|
||||
@@ -168,8 +168,8 @@ static void KeyTimeoutHandler(void* arg)
|
||||
key_time = 101;
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
//button released
|
||||
if (key_time < BUTTON_LONG_PRESS_TIME)
|
||||
@@ -177,7 +177,8 @@ static void KeyTimeoutHandler(void* arg)
|
||||
key_time = 0;
|
||||
os_log("button short pressed:%d",key_time);
|
||||
KeyShortPress();
|
||||
} else if (key_time > 100)
|
||||
}
|
||||
else if (key_time > 100)
|
||||
{
|
||||
MicoSystemReboot();
|
||||
}
|
||||
@@ -189,6 +190,7 @@ static void KeyFallingIrqHandler(void* arg)
|
||||
{
|
||||
mico_rtos_start_timer(&user_key_timer);
|
||||
}
|
||||
|
||||
void KeyInit(void)
|
||||
{
|
||||
MicoGpioInitialize(Button, INPUT_PULL_UP);
|
||||
|
||||
Reference in New Issue
Block a user