real time wifi
Dependencies: RemoteIR TextLCD
Diff: main.cpp
- Revision:
- 5:4026062a6fdf
- Parent:
- 4:a365d6acec8f
--- a/main.cpp Thu Sep 03 00:30:32 2020 +0000 +++ b/main.cpp Thu Sep 03 04:43:03 2020 +0000 @@ -79,6 +79,7 @@ startserver(); while(1) { + if(DataRX==1) { pc.printf("\f\n\r------------ main while > if --------------\n\r"); // click_flag = 1; @@ -170,10 +171,10 @@ strcat(webbuff, "</html>"); strcat(webbuff, "<script language=\"javascript\" type=\"text/javascript\">"); strcat(webbuff, "function send_mes(btnmes,btnval){"); - + /* strcat(webbuff, "try {xhr.abort();console.log(1);}"); strcat(webbuff, "catch(err) {console.log(0);}"); - +*/ strcat(webbuff, "var url = \"http://\" + window.location.hostname + \"/cargo?a=\" + btnval;"); strcat(webbuff, "htmlacs(url);"); strcat(webbuff, "console.log(url);"); @@ -182,9 +183,48 @@ strcat(webbuff, "function htmlacs(url) {"); strcat(webbuff, "var xhr = new XMLHttpRequest();"); strcat(webbuff, "xhr.open(\"GET\", url ,true);"); +/* +//begin 0903 stop xml when state=2 +strcat(webbuff, "xhr.onreadystatechange = function(){console.log(111);"); +//strcat(webbuff, "xhr.onload = function(){console.log(111);"); + + //strcat(webbuff, "console.log(\"onready function is being reload!\");"); + strcat(webbuff, "if(this.readyState == 1 ){"); + strcat(webbuff, "console.log(222);this.abort();}};"); + //strcat(webbuff, "console.log(res);}};"); + +//end 0903 stop xml when state=2 +*/ + strcat(webbuff, "xhr.send();"); +//strcat(webbuff, "console.log(xhr.readyState);"); +//start abort after send +strcat(webbuff, "setTimeout(function(){xhr.abort();},100);"); + +//strcat(webbuff, "setTimeout(xhr.abort(),\"100\");"); + // strcat(webbuff, "xhr.abort();"); + //end abort after send +/* +//begin 0903 esp onload kakkuninn + strcat(webbuff, "xhr.onload = function() {concole.log(\"onload\");"); +strcat(webbuff, "if (xhr.status != 200) { "); + strcat(webbuff, "console.log(200);} else {"); + strcat(webbuff, "console.log(xhr.responseText);"); + strcat(webbuff, "Button_Update(xhr.responseText,\"0\");}};"); + +//end 0903 esp onload kakkuninn +*/ strcat(webbuff, "}"); +//0903 begin abort function +/* +strcat(webbuff, "function abort_click(){"); +strcat(webbuff, "xhr.abort();"); +strcat(webbuff, "}"); +*/ + +//0903 end abort function + //0902 beging /* //0824 battery update auto