-
• #2
Yes, the socket.io libs are just too big for Espruino (even the slim one seems to be 50kB!). I can't find any documentation at all on the actual low-level protocol either - so I think your best bet would be to have Espruino connect straight to a Node.js server.
Espruino's socket implementation is designed to be a cut-down version of Node's, so if you take a look at http://www.espruino.com/Internet#sockets then you should be able to run the 'server' code on the server, and the 'client' code on Espruino - basically without modification.
Your other option I guess is to run MQTT on your server, and to bridge it with socket.io. It might be an easier way to ensure everything stays as individual packets, since the socket's just a stream of bytes, and there is no guarantee that sending
abcdef
won't result in two callbacks, one forabc
and one fordef
. -
• #3
Thanks Gordon,
I was going to look at MQTT next - it sounds like the way to go.
Cheers,
Sean
-
• #4
The idea of routing/bridging packets between socket.io (for web browsers) and MQTT (for Espruino) via node.js works really well. It provides a very nice way for my web-based artworks to communicate with microcontroller-based ones. I think I could probably move completely over to MQTT (on the browser too) but for now I'll stick with what I have produced.
My next step is to sort out the lost packets when using neopixels (with that test version of the library) and get DMX light control working.
Still loving the platform!
Sean
I use socket.io to enable browser to browser communication in a number of projects.
For example, a client running in Chrome might include:
And on the node.js server. This would "bounce" the messages between clients:
How do I get a client running on the Espruino to join in? I don't think there is a socket.io library for Espruino so do I need to use ordinary sockets to do the same job? Would I need to take messages received in socket.io and resend them to the Esprunio and visa versa? Are there some good examples of Espruino to node.js communication via sockets that I should be looking at?
Thanks,
Sean