All, am running the following code - which often works !
function onPageRequest(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<html><body>');
res.write('<p>Button is '+(BTN.read()?'on':'off')+'</p>');
res.write('<p>Turn LED1 <a href="/on1">on</a> or <a href="/off1">off</a></p>');
res.write('<p>Turn LED3 <a href="/on2">on</a> or <a href="/off2">off</a></p>');
res.end('</body></html>');
if (req.url=="/on1") digitalWrite(LED1, 1);
if (req.url=="/off1") digitalWrite(LED1, 0);
if (req.url=="/on2") digitalWrite(LED3, 1);
if (req.url=="/off2") digitalWrite(LED3, 0);
}
var wlan = require("CC3000").connect();
wlan.connect( "mbed", "*********", function (s) {
if (s=="dhcp") {
console.log("My IP is "+wlan.getIP().ip);
require("http").createServer(onPageRequest).listen(80);
}
});
But it will often also not initialise, or initialise - pick up a nice IP from DHCP and work away for a bit but eventually die with timeout (16384) errors ...
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
All, am running the following code - which often works !
But it will often also not initialise, or initialise - pick up a nice IP from DHCP and work away for a bit but eventually die with timeout (16384) errors ...
Is there anything to be done ??
Pat