mirror of
https://github.com/oopuuu/zTC1.git
synced 2026-05-12 03:04:45 +08:00
后台增加重启功能。修复已知问题
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <httpd.h>
|
||||
#include <http_parse.h>
|
||||
#include <http-strings.h>
|
||||
#include "stdlib.h"
|
||||
|
||||
#include "mico.h"
|
||||
#include "httpd_priv.h"
|
||||
@@ -286,6 +287,19 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int HttpSetRebootSystem(httpd_request_t *req)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
|
||||
send_http("OK", 2, exit, &err);
|
||||
|
||||
char c[1] = { 0 };
|
||||
sprintf(c, "reboot now !%s", "reboot");
|
||||
|
||||
exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int HttpSetMqttConfig(httpd_request_t *req)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
@@ -306,6 +320,7 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
static int HttpSetMqttReportFreq(httpd_request_t *req)
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
@@ -453,6 +468,7 @@ const struct httpd_wsgi_call g_app_handlers[] = {
|
||||
{ "/wifi/config", HTTPD_HDR_DEFORT, 0, HttpGetWifiConfig, HttpSetWifiConfig, NULL, NULL },
|
||||
{ "/wifi/scan", HTTPD_HDR_DEFORT, 0, HttpGetWifiScan, HttpSetWifiScan, NULL, NULL },
|
||||
{ "/mqtt/config", HTTPD_HDR_DEFORT, 0, NULL, HttpSetMqttConfig, NULL, NULL },
|
||||
{ "/reboot", HTTPD_HDR_DEFORT, 0, NULL, HttpSetRebootSystem, NULL, NULL },
|
||||
{ "/mqtt/report/freq", HTTPD_HDR_DEFORT, 0, HttpGetMqttReportFreq, HttpSetMqttReportFreq, NULL, NULL },
|
||||
{ "/log", HTTPD_HDR_DEFORT, 0, HttpGetLog, NULL, NULL, NULL },
|
||||
{ "/task", HTTPD_HDR_DEFORT, APP_HTTP_FLAGS_NO_EXACT_MATCH, HttpGetTasks, HttpAddTask, NULL, HttpDelTask },
|
||||
|
||||
@@ -33,6 +33,11 @@
|
||||
<li class="mdl-menu__item" onclick="ChangeLanguage('cn')">中文</li>
|
||||
<li class="mdl-menu__item" onclick="ChangeLanguage('jp')">日本語</li>
|
||||
</ul>
|
||||
<div>
|
||||
<a href="javascript:reboot();" class="mdl-button mdl-js-button mdl-js-ripple-effect">
|
||||
重启
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div class="demo-drawer mdl-layout__drawer mdl-color--blue-grey-900 mdl-color-text--blue-grey-50">
|
||||
@@ -974,6 +979,20 @@ function GetReportFreq() {
|
||||
}
|
||||
GetReportFreq();
|
||||
|
||||
function reboot(){
|
||||
var r=confirm("确定要重启吗?");
|
||||
if (r==true)
|
||||
{
|
||||
setRebootSystem();
|
||||
}
|
||||
}
|
||||
|
||||
function setRebootSystem() {
|
||||
HttpPost("/reboot", function (re) {
|
||||
ShowToast("已重启");
|
||||
}, "000");
|
||||
}
|
||||
|
||||
function setReportFreq(seconds) {
|
||||
if(!seconds||seconds==0){
|
||||
seconds=1;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user