-
More ideas
Measuring the awake duty cycle of a sleepy Espruino board.
Using an analog clock would work if the sleepy Espruino on time is longer that one cycle of the clock mains 60 Hz. Or 50 Hz.
If the sleepy Espruino on time is shorter then this would be better.
Given a sleepy Espruino board that wakes up periodically to perform the user’s task, it would be useful to measure that percentage time in a period (24 hrs.) it is awake.
Hardware:
Take a watch crystal oscillator output (32.76803 kHz) as one input to a two input NAND gate.
Use a pull-down resistor on a pin on the sleepy device so that when it’s asleep the pin is low and when awake the pin is high. Tie this pin to the 2nd input of the gate.
Tie the output of the gate to a divide by 256 and follow that by another divide by 128 chip.
If the gate is “on” the output of the 2nd divider would be 1 Hz.
Tie the output of the 2nd divider to a pin on a 2nd Espruino board, programmed to count the pulses on the pin. Then 100* pulse_count / elapsed_time is the percent on duty cycle.
Of course an even faster clock and divisor chain could be used.
Is there some way to use a pin on the measurement Espruino board to gate the watch crystal oscillator and eliminate the extra hardware?
Is there a way to use the counters on the ARM chip to implement this?Another method if E.getTemperature() is available.
In a room with relatively constant temperature, load the Espruino with code to sleep for an hour, wake up, measure and report the chip temperature T1.
Then load your program to sleep, wakeup, do your job and sleep again. Add code to read and report the chip temperature after an hour T2.
And finally run code fully awake for an hour, then read and report the chip temperature T3.
Duty cycle % = 100*T2/(T3-T1). -
Removing it doesn't fix it
Old C++ habits linger.
The left side:Post URL { "method": "GET", "host": "", "path": "/CMD", "pathname": "/CMD", "search": null, "port": null, "query": null } XXX /CMD Length 70 pdata= {"name":"LED1","a":0,"cmd":"pobj.a=!pobj.a;digitalWrite(LED1,pobj.a)"} pdata length= 70 { "name": "LED1", "a": 0, "cmd": "pobj.a=!pobj.a;digitalWrite(LED1,pobj.a)" } Uncaught SyntaxError: BREAK statement outside of SWITCH, FOR or WHILE loop at line 93 col 5 break; ^ Closed >
And the code with the default break commented
function doPost1(req,res){ var length; var a = url.parse(req.url, true); console.log("URL ",a); console.log("XXX ",a.pathname); length=req.headers["Content-Length"]; console.log("Length ",length); console.log("pdata= ",pdata); console.log("pdata length= ",pdata.length); switch (a.pathname){ case "/CMD": if(pdata.length==length){ pobj=JSON.parse(pdata); console.log(pobj); if(pobj.cmd !==null){ eval(pobj.cmd); pdata=JSON.stringify(pobj); res.writeHead(200); res.end(pdata); }else{ res.writeHead(201); res.end(); } //end if pobj.cmd }//endif length else break; case "/LOGdata": console.log("LOGdata= ",pdata); res.writeHead(200); res.end(pdata); break; default: res.writeHead(404); res.end(); // break; }//end switch pdata=""; }//end doPost1
-
Uncaught SyntaxError: BREAK statement outside of SWITCH, FOR or WHILE loop
(But it's not.)
On the left side:Post URL { "method": "GET", "host": "", "path": "/CMD", "pathname": "/CMD", "search": null, "port": null, "query": null } XXX /CMD Length 67 pdata= {"name":"Btemp","a":0,"cmd":"pobj.a=E.getTemperature().toFixed(2)"} pdata length= 67 { "name": "Btemp", "a": 0, "cmd": "pobj.a=E.getTemperature().toFixed(2)" } Uncaught SyntaxError: BREAK statement outside of SWITCH, FOR or WHILE loop at line 97 col 5 break; ^ Closed >
The program continues running.
Part of the code on the right sideswitch (a.pathname){ case "/CMD": pobj=JSON.parse(pdata); console.log(pobj); if(pobj.cmd !==null){ eval(pobj.cmd); pdata=JSON.stringify(pobj); res.writeHead(200); res.end(pdata); }else{ res.writeHead(201); res.end(); }//end if pobj.cmd break; //this is the break being flaged on line 94 case "/LOGdata": console.log("LOGdata= ",pdata); res.writeHead(200); // this is the line reported 97 res.end(pdata); break; default: res.writeHead(404); res.end(); break; }//end switch pdata=""; }//end doPost1
Changing the code removes the error.
function doPost1(req,res){ var length; var a = url.parse(req.url, true); console.log("URL ",a); console.log("XXX ",a.pathname); length=req.headers["Content-Length"]; console.log("Length ",length); console.log("pdata= ",pdata); console.log("pdata length= ",pdata.length); if(pdata.length!=length){ res.writeHead(404); res.end(); pdata=""; return; }//end if length switch (a.pathname){ case "/CMD": doCMD(req,res); break; case "/LOGdata": console.log("LOGdata= ",pdata); res.writeHead(200); res.end(pdata); break; default: res.writeHead(404); res.end(); break; }//end switch pdata=""; }//end doPost1 function doCMD(req,res){ pobj=JSON.parse(pdata); console.log(pobj); if(pobj.cmd !==null){ eval(pobj.cmd); pdata=JSON.stringify(pobj); res.writeHead(200); res.end(pdata); }else{ res.writeHead(201); res.end(); } //end if pobj.cmd }//end doCMD
And on the left side:
Get/ Get/JPpostT9.html html End Pipe Uncaught Error: Expecting a function to call, got Number Post URL { "method": "GET", "host": "", "path": "/CMD", "pathname": "/CMD", "search": null, "port": null, "query": null } XXX /CMD Length 70 pdata= {"name":"LED1","a":0,"cmd":"pobj.a=!pobj.a;digitalWrite(LED1,pobj.a)"} pdata length= 70 { "name": "LED1", "a": 0, "cmd": "pobj.a=!pobj.a;digitalWrite(LED1,pobj.a)" } Closed >
-
Another method
We can measure current when the device is asleep and when it is awake.
It's a question of duty cycle.
Use a solid state switch to control an analog electric clock and change the code to turn the clock on at wakeup and off just before going asleep, with your application code in the middle. Run it for a period of time (24 hrs.). Then the analog clock elapsed time divided by the total elapsed time gives the duty cycle fraction. -
Accuracy?
You are correct. This kit would most likely measure the on current pulse after it is stretched over the time constant of the RC filter. Likely the low power current would be down in the noise.
For estimating total Amp-hours, add the low power current times time to the measured on current.
Setting the gain on the op-amp figures into the setup and calibration.My experience tells me that trying it in a freezer is prudent. The cold can affect the battery.
The measurement method is based on linear assumptions. Batteries have some non-linear characteristics, especially with regards to temperature. -
Limiting the length of POST data to prevent filling memory?
A POST from a client sends a header and a block of data. If a client sends too much data at once the server will run out of space and crash. I added code to ignore POST data over a certain size.
Is this sufficient or should an req.on('data) be used to drain the buffer at the req source?function serveHTML(){ var http=require("http").createServer(onPageRequest).listen(8080); }//end serveFile var pdata=""; function onPageRequest(req, res) { //console.log("Req= ",req); //console.log("Header",req.headers); if (req.method=="POST") { console.log("Post"); doPost(req,res); }else{ doGet(req,res); }//endif }//end on PageRequest var pobj; function doPost(req,res){ var length; length=req.headers["Content-Length"]; //do we want to take the message based on length? if(length<1024){ req.on("data", function(d) {pdata+=d;if(pdata.length==length)doPost1(req,res);}); }else{ /********* Should an req.on('data') be used here to drain the source and toss the data? */ res.writeHead(413); //Too big error res.end(); }//end if length req.on('close',"console.log(\"Closed\",pdata);"); }
The POST message processing code follows.
function doPost1(req,res){ var length; var a = url.parse(req.url, true); console.log("URL ",a); console.log("XXX ",a.pathname); length=req.headers["Content-Length"]; console.log("Length ",length); console.log("pdata= ",pdata); console.log("pdata length= ",pdata.length); switch (a.pathname){ case "/CMD": //Process JSON command structure if(pdata.length==length){ pobj=JSON.parse(pdata); console.log(pobj); if(pobj.cmd !==null){ eval(pobj.cmd); pdata=JSON.stringify(pobj); res.writeHead(200); res.end(pdata); }else{ res.writeHead(201); res.end(); } //end if pobj.cmd }//endif length else break; case "/LOGdata": // Process data POSTed into a form, simple Echo for now console.log("LOGdata= ",pdata); res.writeHead(200); res.end(pdata); break; default: res.writeHead(404); res.end(); }//end switch pdata=""; }//end doPost1
-
A practical solution
ACS712 with op-amp such as this one
https://www.sparkfun.com/products/8883
Add a low pass filter on the output of the op-amp with a long time constant.
http://www.learningaboutelectronics.com/Articles/Low-pass-filter-calculator.php
I figure 10k resistor and 100uF capacitor would do the trick. -
**This is a strange way to measure Coulombs **
Some history:
http://www.metering.com/the-history-of-the-electricity-meter/
https://en.wikipedia.org/wiki/Electricity_meterA bit more modern.
http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19700022950.pdfand what I had in mind if you can find the gadget on the surplus market. The last time I saw some was in the late 1980's. They were a couple of dollars each.
https://www.youtube.com/watch?v=Cxj399LuX1M
-
-
Processing POST using Forms
This link shows how a Form is setup in HTML using both the GET and POST methods.
http://www.w3schools.com/tags/att_form_method.asp
The first line action refers to an ASP file on the server. The Posted data is processed by the ASP code.form action="demo_form_method_post.asp" method="post">
For Espruino perhaps we can replace the ASP with a word that is used to steer the message to an appropriate handler.
One idea would be to use a Form to setup the column titles in a CSV file. It would create a CSV file on the SD card, taking the filename and column headers from the posted form. Ideas?
In previous forum posts we did the JSON POST from Java Script.
http://forum.espruino.com/conversations/285131/
Set up an HTML file called Postform2.html and copy it to the SD cardI tried to list it here but it doesn't work in the preview. So I attached it.
Part of the server code with console.log(“Header “,req.headers) added.
var pdata=""; function serveHTML(){ var http=require("http").createServer(onPageRequest).listen(8080); }//end serveFile function onPageRequest(req, res) { //console.log("Req= ",req); console.log("Header",req.headers); var a = url.parse(req.url, true); console.log("URL ",a); if (req.method=="POST") { console.log("Post"); doPost(req,res); }else{ doGet(req,res); }//endif }//end on PageRequest
The header and results of url.parse when Postform2.html is loaded and the Submit button is pressed.
Header { "Accept": "text/html, application/xhtml+xml, */*", "Referer": "http://192.168.1.3:8080/PostForm2.html", "Accept-Language": "en-US", "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko", "Content-Type": "application/x-www-form-urlencoded", "Accept-Encoding": "gzip, deflate", "Host": "192.168.1.3:8080", "Content-Length": "19", "DNT": "1", "Connection": "Keep-Alive", "Cache-Control": "no-cache" } URL { "method": "GET", "host": "", "path": "/LOGdata", "pathname": "/LOGdata", "search": null, "port": null, "query": null } Post Length 19 pdata= fname=xxx&lname=yyy pdata length= 19
It’s strange to see GET in the URL results. Suggestions?
The pdata is the message received after the header.
It would be prudent to add code to limit the number of characters we can receive so that memory isn’t exhausted. The server code as of now crashes when the Submit button is pressed.Repeating with the JPpost9.HTML using the JSON post from a script. The LED1 button was clicked.
The header and results of url.parseHeader { "Accept": "*/*", "Content-Type": "application/json;charset=utf8", "Referer": "http://192.168.1.3:8080/JPpostT9.html", "Accept-Language": "en-US", "Accept-Encoding": "gzip, deflate", "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko", "Host": "192.168.1.3:8080", "Content-Length": "70", "DNT": "1", "Connection": "Keep-Alive", "Cache-Control": "no-cache" } URL { "method": "GET", "host": "", "path": "/CMD", "pathname": "/CMD", "search": null, "port": null, "query": null } Post Length 70 pdata= {"name":"LED1","a":0,"cmd":"pobj.a=!pobj.a;digitalWrite(LED1,pobj.a)"} pdata length= 70 { "name": "LED1", "a": 0, "cmd": "pobj.a=!pobj.a;digitalWrite(LED1,pobj.a)" } Closed >
So the code needs to use req.method to determine GET or POST.
If it’s a POST, then use
var a = url.parse(req.url, true);
and a.”path”, or a.”pathname” to determine if it’s a “CMD” or a “LOGdata” POST.
Anyone have a guess which is the right one?
If it’s not what’s coded in the server, the reply header should be 404?One issue is that when the Submit button is pressed a new tab in the browser is opened.
This is resolved by changing the target attribute in the HTML file.
http://www.w3schools.com/tags/att_form_target.asp
form action="LOGdata" method="post" target="_blank">More to follow.
-
-
Temporary work around
In the Web IDE click on the settings (gear icon) and go to project.
Create a sandbox directory. Mine is called EP.
Another button appears under the send to Espruino button.
With Explorer copy your program into EP/Projects.
Now for the modules. With a browser go to
http://espruino.com/modules/
Click on the module you need, and it will fill the screen.
Select all and copy into Notepad and save with the same name in
EP/modules.
You might look to see if your module requires other modules. If so, copy and save them as well.In Web IDE load your program into the right side from EP/Projects/
Now try the send to Espruino.
With any luck your program will load.I used the following to test this method. The ESP8266 module requires the AT module as well.
console.log("aaa"); require("ESP8266WiFi_0v25"); console.log("bbb");
-
http://www.espruino.com/modules/
The modules can be seen using a browser.
I'm wondering if the latest Windows update changed something that blocks Web IDE from fetching the modules when the send to Espruino button is clicked. -
Uncaught Error: Function "setBootCode" not found!
Some simple code on the right side to test require()
console.log("aaa"); //require("ESP8266WiFi_0v25"); console.log("bbb");
Produces the following on the left side when send to Espruino is clicked
>reset(); =undefined _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v80 Copyright 2015 G.Williams >echo(0); Uncaught Error: Function "setBootCode" not found! at line 1 col 3 E.setBootCode("console.log(\"aaa\");\n//require(\"ESP8266WiF... ^ =undefined >
In the Web IDE Setting:Communications
See if Save on Send is checked, uncheck it
On the left side enter reset(); followed by save();>reset(); =undefined _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v80 Copyright 2015 G.Williams >save(); =undefined Erasing Flash..... Writing... Compressed 81600 bytes to 878 Checking... Done! >
Now try the send to Espruino button.
>reset(); =undefined _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v80 Copyright 2015 G.Williams >save(); =undefined Erasing Flash..... Writing... Compressed 81600 bytes to 878 Checking... Done! >reset(); =undefined _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v80 Copyright 2015 G.Williams >echo(0); aaa bbb =undefined >
This was tried on an Espruino board and a Pico
-
It was working but now it doesn't.
Simple programs on the right side get sent to Espruino just fine.> >1+1 =2 >require("ESP8266WiFi_0v25"); ERROR: Could not open file : NO_FILE WARNING: Module "ESP8266WiFi_0v25" not found =undefined > >
Module URL
http://www.espruino.com/modules
Module Extensions
.min.js|.jsvar serial=Serial4; serial.removeAllListeners(); serial.setup(115200, { rx: C11, tx : C10 }); var wifi = require("ESP8266WiFi_0v25").connect(serial, function(err) { if (err) throw err; wifi.reset(function(err) { if (err) throw err; console.log("Connecting to WiFi"); wifi.connect(WiFi_Name,WPA2_Key, function(err) { if (err) throw err; console.log("Connected "); getpage(); }); }); }); function getpage(){ require("http").get("http://www.pur3.co.uk/hello.txt", function(res) { console.log("Response: ",res); res.on('data', function(d) { console.log("--->"+d); }); }); }//end get page
-
Taking a break
It seems the WEB IDE doesn't want to load the ESP8266 module tonight for some reason. Other files get sent to the board and run.
Thanks Gordon for the pipe suggested arguments. The weird error occurs even using the original Example f.pipe(res); // streams the file to the HTTP response
I have a Pico and ESP8266 but no shim as yet. Sparkfun has mico SD card breakout boards or you can use an adapter as shown on the Espruino site. I'm curious to find out if this code would work on the Pico as well.I was working on the GET side of the code with the pipe function, it's arguments and the error message that appears. It seems this didn't fix the POST bug like I thought. Just getting a better handle on how the on('data') function works was part of the learning curve that fixed the problem.
I did manage to edit the HTML file to remove the message from the header and replace it with "CMD". The message gets posted after the header. This change works.
Leaving the field as "" doesn't work. I have considered using this field in a switch statement so that other types of POST message could be developed. Candidates might be delete a file, or write a file...//yhttp.open("POST",sendText, true); yhttp.open("POST","CMD", true);
-
Program is working now, files attached
Thanks for the suggestions.
Checking the length in the header against the length of the data collected in the on('data') event and the proceeding to process the message and reply made it work.var reqq; var ress; function doPost(req,res){ var length; length=req.headers["Content-Length"]; reqq=req;ress=res; req.on("data", function(d) {pdata+=d;if(pdata.length==length)doPost1(reqq,ress);}); req.on('close',"console.log(\"Closed\",pdata);"); }
-
Found the bug
It was in the Get section of the code. I know the light was better in the POST code:)
File Server Example
http://www.espruino.com/http_file_serverswitch (ext){ case "html": res.writeHead(200, {'Content-Type': 'text/HTML'}); f.pipe(res); // streams the file to the HTTP response break;
Notice that in the example fileserver code and my program there is no res.end().
Both produce an obscure error:Uncaught Error: Expecting a function to call, got Number
By changing the program as follows:
case "html": res.writeHead(200, {'Content-Type': 'text/HTML'}); f.pipe(res,{chunkSize:4096,end:true,complete:res.end()}); // streams the file to the HTTP response break;
The error goes away. I first tried 512 instead of 4096 and only got a partial load of my HTML file. The 4096 is the length of the HTML file. Does the chunkSize parameter need to be the file length?
So now the POST code req.on('data') works.var pdata=""; function onPageRequest(req, res) { var a = url.parse(req.url, true); req.on("data", function(d) {pdata+=d;});
Pdata= {"name":"LED2","a":true,"cmd":"pobj.a=!pobj.a;digitalWrite(LED2,pobj.a)"}{"name":"LED2","a":0,"cmd":"pobj.a=!pobj.a;digitalWrite(LED2,pobj.a)"}
So there are two questions.
- Is the chunkSize the file length?
- The res.end() worked, what about closing the file after the Pipe finishes?
- Is the chunkSize the file length?
-
Hi Gordon,
I'm running 1v85 using the WebIDE. The ESP8266 AT reply is as follows.
1v85 Copyright 2016 G.Williamsecho(0);
=undefined
""
"AT+GMR\r\r\nAT version:0.40.0.0(Aug 8 2015 14:45:58)\r\nSDK version:1.3.0\r\nAi-Thinker Technology Co.,Ltd.\r\nBuild:1.3.0.2 Sep 11 2015 11:48:04\r\nOK\r\n"
")m\xE9M\xAAK\xF8"
Done!One thing I've tried to troubleshoot the POST problem is to use a
serial.on('data') to grab everything coming from the client.
I get the POST header followed by the POST message. The client is sending it all.
A req.read() gets the POST message with varying results. About 1 in 7 tries I get the whole message. The req.on('data') just isn't working and should have fixed the problem. I'm open to suggestions including a bifocal error on my part. If needed I can run some diagnostics and post them.I set out to modify a program I used on Android using SL4A that reads analog inputs and plots them on a strip chart on the client. It makes use of the Flot graphics. The HTML loads a Flot JS file which is rather large even in minified form.
I stubbed the Android calls in the HTML program, put the HTML and Flot JS files on the SD card. It runs but takes several minutes to load at 115k Baud. I've yet to try loading the Flot JS file from the client side which should speed up the loading. Otherwise it's create a light version of a strip chart.
-
Current files are attached.
The html file goes on the SD card to be served by the JS file to the client.
The JS file serves the files and responds to the POST request in the html page.
The req.read, req.on('data') methods don't seem to work.
I stuffed the POST message in the header. On the server side the message from the header has to have octal characters parsed back to the original message.
Any help with getting the POST message to show up will be greatly appreciated. -
This runs on an Espruino board connected to an ESP8266 running the AT commands.
The ESP8266 is on a separate 3.3V supply and connects to Serial port 4 of the Espruino board
Put an HTML and a CSV file on an SD card and insert it into the Espruino board,
Load the following code into the Espruino board via USB.
Open a browser and use the IP address to access the hardware via Wi-Fi.
Example:
http://192.168.1.3:8080/You should see a directory of the SD card.
If you click on an HTML file, it will load the Webpage instead of displaying the content as text.
If the HTML file loads a .js file on the SD card it should work as well.From the SD card directory, if you clicl on a .csv file, your browser will launch Excel and download the csv file into a workbook. You can then save the data to your hard drive.
The code follows:
//Use for Espruino board wired to AT ESP8266 //Uses HTTP to access and load a web site and display on console var serial=Serial4; var SSID="ssid"; var key= "passcode"; var filename,ext; serial.setup(115200, { rx: C11, tx : C10 }); var wifi = require("ESP8266WiFi_0v25").connect(serial, function(err) {//5 if (err) throw err; wifi.reset(function(err) {//4 if (err) throw err; console.log("Connecting to WiFi"); wifi.connect(SSID,key, function(err) {//3 if (err) throw err; console.log("Connected"); // Now you can do something, like an HTTP request var l=""; serveHTML(); });//3 });//4 });//5 function onPageRequest(req, res) { var a = url.parse(req.url, true); if (req.method=="POST") { console.log("Post"); doPost(req,res); }else{ doGet(req,res); }//endif }//end on PageRequest function doPost(req,res){ //Stub function for now var info = url.parse(req.url, true);// console.log("res= ",res); res.writeHead(200); res.end(); }//end doPost function doGet(req,res){ var a = url.parse(req.url, true); filename=a.pathname; ext=filename.split(".").pop(); console.log("Get"+filename); if (a.pathname.substr(-1)=="/") { // a slash at the end, list the directory res.writeHead(200, {'Content-Type': 'text/html'}); res.write("<html><body><p>Contents of "+a.pathname+"</p><ul>"); require("fs").readdir(a.pathname.substr(0,a.pathname.length-1)).map(function(f) { res.write('<li><a href="'+a.pathname+f+'">'+f+'</a></li>'); }); res.end("</ul></body></html>"); } else { // No slash, try and open file var f = E.openFile(a.pathname, "r"); //1 if (f !== undefined) { // File open succeeded - send it! console.log(ext); switch (ext){ case "html": res.writeHead(200, {'Content-Type': 'text/HTML'}); f.pipe(res); // streams the file to the HTTP response break; case "js": res.writeHead(200,{'Content-Type':'text/javascript'}); f.pipe(res); // streams the file to the HTTP response break; case "csv": res.writeHead(200,{'Content-Type':'text/csv'}); f.pipe(res); // streams the file to the HTTP response break; default: res.writeHead(200, {'Content-Type': 'text/plain'}); f.pipe(res); // streams the file to the HTTP response break; }//end switch ext } else { // couldn't open file //1 // first check if this was a directory if (require("fs").readdir()!==undefined) { // it was a directory - forward us to a page with the '/' on the end res.writeHead(301, {'Location': a.pathname+"/", 'Content-Type': 'text/plain'}); res.end("Moved"); } else { // else not found - send a 404 message res.writeHead(404, {'Content-Type': 'text/plain'}); res.end("404: Page "+a.pathname+" not found"); } } } } function serveHTML(){ var http=require("http").createServer(onPageRequest).listen(8080); }//end serveFile
Note the POST function is a stub for now.
These links may be of use in the switch statement
https://en.wikipedia.org/wiki/Media_type
https://www.iana.org/assignments/media-types/media-types.xhtml#application
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields -
Retired. Just having fun now.
I'm running an Espruino Board connected to ESP8266 via serial port.Working on a program derived from the SD card file server example.
When you request a file from the displayed list, it looks at the file extension and modifies the MIME header field.
This causes files with the extension .HTML to load the Web page.
Files with the extension .js allow an .HTML file to include scripts.
Files with the extension .csv cause Excel to load the file into a spreadsheet, which can be saved on your hard drive.I'm having problems with another part that accepts POSTs from a client.
Correction
Duty cycle % = 100*(T2-T1)/(T3-T1)