-
-
-
-
-
Hi - getting the following error in EspruinoHub (not sure what the message is that it's choking on yet):
buffer.js:798 return { type: 'Buffer', data }; ^ RangeError: Maximum call stack size exceeded at Buffer.toJSON (buffer.js:798:5) at Object.stringify (native) at getStatusText (/home/pi/EspruinoHub/lib/status.js:50:37) at dumpStatus (/home/pi/EspruinoHub/lib/status.js:59:14) at Console.console.log (/home/pi/EspruinoHub/lib/status.js:75:5) at getStatusText (/home/pi/EspruinoHub/lib/status.js:45:41) at dumpStatus (/home/pi/EspruinoHub/lib/status.js:59:14) at Console.console.log (/home/pi/EspruinoHub/lib/status.js:75:5) at getStatusText (/home/pi/EspruinoHub/lib/status.js:45:41) at dumpStatus (/home/pi/EspruinoHub/lib/status.js:59:14) pi@raspberrypi:~/EspruinoHub $
-
You could use one of these things: http://www.espruino.com/Order#wifi
Almost too easy... :)
-
-
-
Well, the use case is that I have a puck acting as a sensor (say a movement sensor attached to a door or temperature/light measurement) which is powered by the coin battery and lasts for months/years. I need to send the sensor results to something (a gateway) for further processing and/or recording that may require sending data to a cloud service - it will be powered by mains (or solar). That 'something' needs to have BLE to communicate with the puck as well as whatever other connectivity (eg HTTP) is needed.
A raspberry pi would fit the bill quite well - but so would an espruino powered device with BLE + wifi - and be much simpler to programme!
Attaching the wifi directly to the puck will require more power and negates the advantages of the long life that the puck currently enjoys...
Just a thought...
cheers...
-
-
-
-
Nicely spotted indeed! All working now - thanks...
For my future reference here's the final code that works (note that the res.on() events are only triggered if the server actually returns something:var WIFI_NAME = ""; var WIFI_OPTIONS = { password : "" }; var wifi = require("EspruinoWiFi"); wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(err) { if (err) { console.log("Connection error: "+err); return; } console.log("Connected!"); sendData(); }); function sendData() { var content = "{module:'espruino'}"; var options = { host: '192.168.1.66', // host ip (host name works as well) port: 8081, // (optional) port, defaults to 80 path: '/stats/login/', // path sent to server method: 'POST', headers: { "Content-type" : "application/json", "Content-length": content.length} }; var req = require("http").request(options, function(res) { console.log('res',res); res.on('data', function(data) { console.log("HTTP> "+data); }); res.on('close', function(data) { console.log("Connection closed"); }); }); req.on('error',function(err){ console.log(err); }); req.end(content); console.log("Request sent"); }
-
Not sure if this is the right place for this - but I see you're writing a book: (https://www.amazon.co.uk/Making-Things-Smart-Programming-Transforming/dp/1680451898 )
can I ask that you also release it in kindle? I will buy it in an instant, but really prefer eBooks these days...
cheers!
-
-
Hi Guys - having issues getting an HTTP POST to work. Device is an espruino wifi, flashed to the latest version.
Here's the code:
var WIFI_NAME = "xxxx"; var WIFI_OPTIONS = { password : "yyy" }; var wifi = require("EspruinoWiFi"); wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(err) { if (err) { console.log("Connection error: "+err); return; } console.log("Connected!"); sendData(); }); function sendData() { var options = { host: 'http://192.168.1.66', // host name port: 8081, // (optional) port, defaults to 80 path: '/stats/login/', // path sent to server method: 'POST', headers: { "Content-type" : "application/json" } }; var req = require("http").request(options, function(res) { console.log('res',res); res.on('error', function(data) { console.log("error> "+data); }); res.on('data', function(data) { console.log("HTTP> "+data); }); res.on('close', function(data) { console.log("Connection closed"); }); }); req.end("{module:'espruino'}"); console.log("Request sent");
The connection works OK and I also get the 'request sent' message, but nothing after that on the espruino, and no connection received by the server.
I've verified that the endpoint (which is a server of mine) is working OK (accepts a POST from a REST client), and HTTP.GET works fine (copied one of the examples). I'm doubtless doing something basic wrong, but not sure how to debug further...
-
-
Thanks for the rapid reply! I was aware of setAdvertising, but that line is replaced each time the code is updated isn't it? Unlike the 'Puck.js xxxx' name... So you need to remember to change it to the 'correct' name each time you update the device, which gets confusing (at least for me) when dealing with multiple devices... (but the ability to dump() the current code - and eventually the current device name in the banner - will certainly help...
cheers...
-
Hi,
Great little device (the Puck)! Couple of UI suggestions for the editor:
- Make it possible to load the app currently running on a connected device into the editor
- Display the device name ( eg Puck.js xxxx) in the UI banner so you know which device you are connected to..
(would also be good to be able to permanently change the device name - but I suspect that's not possible)
cheers...
- Make it possible to load the app currently running on a connected device into the editor
well yes, but how much extra (compiled) space does an explicit assignment take?
ie: