mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 21:18:13 +08:00
运行时间OK
This commit is contained in:
@@ -46,7 +46,8 @@
|
|||||||
static bool is_http_init;
|
static bool is_http_init;
|
||||||
static bool is_handlers_registered;
|
static bool is_handlers_registered;
|
||||||
struct httpd_wsgi_call g_app_handlers[];
|
struct httpd_wsgi_call g_app_handlers[];
|
||||||
char power_info_json[1140] = { 0 };
|
char power_info_json[1536] = { 0 };
|
||||||
|
char up_time[16] = "00:00:00";
|
||||||
|
|
||||||
static int HttpGetIndexPage(httpd_request_t *req)
|
static int HttpGetIndexPage(httpd_request_t *req)
|
||||||
{
|
{
|
||||||
@@ -68,7 +69,7 @@ static int HttpGetTc1Status(httpd_request_t *req)
|
|||||||
char* tc1_status = malloc(384);
|
char* tc1_status = malloc(384);
|
||||||
sprintf(tc1_status, TC1_STATUS_JSON, sockets, ip_status.mode,
|
sprintf(tc1_status, TC1_STATUS_JSON, sockets, ip_status.mode,
|
||||||
sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key,
|
sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key,
|
||||||
ELAND_AP_SSID, ELAND_AP_KEY, "MQTT.ADDR", 1883, ip_status.ip, ip_status.mask, ip_status.gateway, time(NULL));
|
ELAND_AP_SSID, ELAND_AP_KEY, "MQTT.ADDR", 1883, ip_status.ip, ip_status.mask, ip_status.gateway, 0L);
|
||||||
|
|
||||||
OSStatus err = kNoErr;
|
OSStatus err = kNoErr;
|
||||||
send_http(tc1_status, strlen(tc1_status), exit, &err);
|
send_http(tc1_status, strlen(tc1_status), exit, &err);
|
||||||
@@ -107,10 +108,19 @@ static int HttpGetPowerInfo(httpd_request_t *req)
|
|||||||
int idx = 0;
|
int idx = 0;
|
||||||
sscanf(buf, "%d", &idx);
|
sscanf(buf, "%d", &idx);
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||||
|
mico_time_t past_ms = 0;
|
||||||
|
mico_time_get_time(&past_ms);
|
||||||
|
int past = past_ms / 1000;
|
||||||
|
int h = past / 3600;
|
||||||
|
int m = past / 60 % 60;
|
||||||
|
int s = past % 60;
|
||||||
|
sprintf(up_time, "%d:%02d:%02d", h, m, s);
|
||||||
|
|
||||||
char* powers = GetPowerRecord(idx);
|
char* powers = GetPowerRecord(idx);
|
||||||
static int p_count = 0;
|
static int p_count = 0;
|
||||||
p_count += 1;
|
p_count += 1;
|
||||||
sprintf(power_info_json, POWER_INFO_JSON, power_record.idx, PW_NUM, p_count, powers);
|
sprintf(power_info_json, POWER_INFO_JSON, power_record.idx, PW_NUM, p_count, powers, up_time);
|
||||||
send_http(power_info_json, strlen(power_info_json), exit, &err);
|
send_http(power_info_json, strlen(power_info_json), exit, &err);
|
||||||
exit:
|
exit:
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
'start_time':%ld\
|
'start_time':%ld\
|
||||||
}"
|
}"
|
||||||
|
|
||||||
#define POWER_INFO_JSON "{'idx':%d,'len':%d,'p_count':%d,'powers':[%s]}"
|
#define POWER_INFO_JSON "{'idx':%d,'len':%d,'p_count':%d,'powers':[%s],'up_time':'%s'}"
|
||||||
|
|
||||||
int AppHttpdStart(void);
|
int AppHttpdStart(void);
|
||||||
int AppHttpdStop();
|
int AppHttpdStop();
|
||||||
|
|||||||
@@ -179,7 +179,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="right">Uptime:</td>
|
<td class="right">Uptime:</td>
|
||||||
<td class="info" id="uptime"></td>
|
<td class="success" id="uptime"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -283,10 +283,11 @@ function GetPowerRecord() {
|
|||||||
}
|
}
|
||||||
if (power.powers.length != 0) {
|
if (power.powers.length != 0) {
|
||||||
power_line.innerHTML += html;
|
power_line.innerHTML += html;
|
||||||
power_line.scrollTo(power_line.scrollWidth, 0);
|
power_line.scrollTo(power_line.scrollWidth, 0); //滑动到最后
|
||||||
}
|
}
|
||||||
window.setTimeout(GetPowerRecord, 3000); //滑动到最后
|
|
||||||
w.innerHTML = power.p_count; //累加功率
|
w.innerHTML = power.p_count; //累加功率
|
||||||
|
uptime.innerHTML = power.up_time;
|
||||||
|
window.setTimeout(GetPowerRecord, 3000);
|
||||||
}, power_idx.toString());
|
}, power_idx.toString());
|
||||||
}
|
}
|
||||||
GetPowerRecord();
|
GetPowerRecord();
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user