diff --git a/src/httpserver/new_http.c b/src/httpserver/new_http.c index 51fe9454f..5f079cfd8 100644 --- a/src/httpserver/new_http.c +++ b/src/httpserver/new_http.c @@ -308,8 +308,12 @@ const char *g_header = "

"); poststr(request,g_build_str); + poststr(request,"
Online for "); + misc_formatUpTimeString(Time_getUpTimeSeconds(), upTimeStr); + poststr(request,upTimeStr); } @@ -352,6 +356,37 @@ int poststr(http_request_t *request, const char *str){ return postany(request, str, strlen(str)); } +void misc_formatUpTimeString(int totalSeconds, char *o) { + int rem_days; + int rem_hours; + int rem_minutes; + int rem_seconds; + + rem_days = totalSeconds / (24*60*60); + totalSeconds = totalSeconds % (24*60*60); + rem_hours = totalSeconds / (60*60); + totalSeconds = totalSeconds % (60*60); + rem_minutes = totalSeconds / (60); + rem_seconds = totalSeconds % 60; + + *o = 0; + if(rem_days > 0) + { + sprintf(o,"%i days, %i hours, %i minutes and %i seconds ",rem_days,rem_hours,rem_minutes,rem_seconds); + } + else if(rem_hours > 0) + { + sprintf(o,"%i hours, %i minutes and %i seconds ",rem_hours,rem_minutes,rem_seconds); + } + else if(rem_minutes > 0) + { + sprintf(o,"%i minutes and %i seconds ",rem_minutes,rem_seconds); + } + else + { + sprintf(o,"just %i seconds ",rem_seconds); + } +} int HTTP_ProcessPacket(http_request_t *request) { int i, j; char tmpA[128]; @@ -606,6 +641,10 @@ int HTTP_ProcessPacket(http_request_t *request) { }*/ poststr(request,"

Check networks reachable by module

This will lag few seconds.
"); if(http_getArg(urlStr,"scan",tmpA,sizeof(tmpA))) { +#ifdef WINDOWS + + poststr(request,"Not available on Windows
"); +#else AP_IF_S *ar; uint32_t num; @@ -617,6 +656,7 @@ int HTTP_ProcessPacket(http_request_t *request) { poststr(request,tmpA); } tuya_hal_wifi_release_ap(ar); +#endif } poststr(request,"
\ \ diff --git a/src/httpserver/new_http.h b/src/httpserver/new_http.h index 739a6dcdd..fa4d97deb 100644 --- a/src/httpserver/new_http.h +++ b/src/httpserver/new_http.h @@ -38,6 +38,7 @@ typedef struct http_request_tag { int HTTP_ProcessPacket(http_request_t *request); void http_setup(http_request_t *request, const char *type); int poststr(http_request_t *request, const char *str); +void misc_formatUpTimeString(int totalSeconds, char *o); enum { HTTP_ANY = -1, diff --git a/src/user_main.c b/src/user_main.c index 9ff0624c1..3dd64ebae 100644 --- a/src/user_main.c +++ b/src/user_main.c @@ -67,6 +67,9 @@ static int g_openAP = 0; #define tcp_server_log(M, ...) os_printf("TCP", M, ##__VA_ARGS__) +int Time_getUpTimeSeconds() { + return g_secondsElapsed; +} // from wlan_ui.c, no header void bk_wlan_status_register_cb(FUNC_1PARAM_PTR cb); diff --git a/src/win_main.c b/src/win_main.c index 8cb01b69e..55d95ab01 100644 --- a/src/win_main.c +++ b/src/win_main.c @@ -25,6 +25,14 @@ void strcat_safe_test(){ char tmpA[16]; char tmpB[16]; char buff[128]; + char timeStrA[128]; + char timeStrB[128]; + char timeStrC[128]; + char timeStrD[128]; + char timeStrE[128]; + char timeStrF[128]; + char timeStrG[128]; + char timeStrH[128]; int res0, res1, res2, res3, res4, res5; tmpA[0] = 0; res0 = strcat_safe(tmpA,"Test1",sizeof(tmpA)); @@ -43,6 +51,19 @@ void strcat_safe_test(){ urldecode2_safe(buff,"qqqqqq%40qqqq",sizeof(buff)); urldecode2_safe(buff,"qqqqqq%40qqqq",sizeof(buff)); + + + misc_formatUpTimeString(15, timeStrA); + misc_formatUpTimeString(65, timeStrB); + misc_formatUpTimeString(125, timeStrC); + misc_formatUpTimeString(60*60, timeStrD); + misc_formatUpTimeString(4*60*60, timeStrE); + misc_formatUpTimeString(24*60*60, timeStrF); + misc_formatUpTimeString(24*60*60+60*60+50, timeStrG); + misc_formatUpTimeString(100*24*60*60+60*60+15*60+50, timeStrH); +} +int Time_getUpTimeSeconds() { + return rand()% 100000; } // placeholder - TODO char myIP[] = "127.0.0.1"; diff --git a/windowsTest_msvc2008.vcproj b/windowsTest_msvc2008.vcproj index 7e19e0d66..a3e7a6075 100644 --- a/windowsTest_msvc2008.vcproj +++ b/windowsTest_msvc2008.vcproj @@ -183,6 +183,18 @@ RelativePath=".\src\jsmn\jsmn.c" > + + + + + @@ -207,13 +219,25 @@ RelativePath=".\src\httpserver\new_http.c" > + + + + + + + + + +