Simple “local” (cloud disabled) websocket server implementation ported from https://github.com/brandenhall/Arduino-Websocket.git.
The server by default handles up-to 4 simultaneous clients.
I had to change the TCPServer (spark_wiring_tcpserver.cpp). For some reason the TCPServer had a references to a TCPClient, beside not making sense to me it was preventing me of having more than one client attached, hence the changes.
NOTE, I have only tested this with local builds, so try it with sparkulator on your own risk :).
I did not have time to create new make files, so for now, you have to copy files (backup original the files first).
Copy files from src|inc|build to core-firmware/src|inc|build. My plan is to learn how to create a proper sparkcore lib from this…
The applicaiton.cpp is a simplified version of the tinker firmware that I used for my testing and currently can handle: digitalread, digitalwrite, analogread and analogwrite. When I get a chance I will add something like Spark.publish…
applicaiton.cpp requires Serial connection, the core will halt the execution in the setup (the RGB led will flash blue, green and pink) until the serial communication is established.
example syntax to how use the tinker firmware
/digitalwrite?D3=HIGH
/digitalread?D3
If you develop on Linux and if you have nodejs installed read on.
After flashing the core for the first time, you can use “doit” in the build folder. “doit” will put the core in the dfu mode, compile, and flash the core again.
tinker.js in the example folder can be used for demo and or testing, currently it has a loop that will turn on/off the first four digital outputs on the core.
Note you have to change the <IP>:< PORT> in the tinker.js before using it.
get it from git:
short video:
Just noticed that the video does not have any audio :(, here is a short description on what you see in the video:
On the right, the browser is connected to the core’s WebSocket server. The serial output from the core is on the left. After connection is established to the core, I change the state of the digital pins by clicking on the pins, When I click on the analog pins the core replies with analogue values for the pin in question.