Thanks Gordon! I tried the dev IDE and it works a bit better, but I still can't make a proper POST. The CC3000 times out and restarts everytime, or I get a socket-1 error.
Here is my code:
var wlan = require("CC3000");
var http = require("http");
var data = JSON.stringify([{
x : 0,
y : 1,
type : "scatter",
mode : "markers"
}]);
var layout = JSON.stringify({
fileopt : "extend",
filename : "Espruino"
});
var payload = {
un : "demos",
key : "tj6mr52zgp",
origin : "plot",
platform : "rest",
args : data,
kwargs : layout,
version : "0.0.1"
};
function request() {
var urlpayload = "un="+payload.un+"&key="+payload.key+"&origin="+payload.origin+"&platform="+payload.platform+"&args="+payload.args+"&kwargs="+payload.kwargs+"&version="+payload.version;
var options = {
host: 'plot.ly',
method: 'POST',
path: '/clientresp',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': urlpayload.length
}
};
var req = http.request(options, function(res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
req.write(urlpayload);
req.end();
}
wlan.connect( "evilfriends", "password", function (s) {
if (s=="dhcp") {
console.log('wifi connected!');
request();
}
});
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.
Thanks Gordon! I tried the dev IDE and it works a bit better, but I still can't make a proper POST. The CC3000 times out and restarts everytime, or I get a socket-1 error.
Here is my code:
It seems to be OK until it hits