Using the websocket library with Spacebrew

Branching off the discussion from Websockets losing connection to server:

@leo3linbeck, I am trying to get your sparkWebsocket library running, with a specific purpose – to have my Cores connect to my Spacebrew server and effectively transmit all Core sensor data through the websocket.

I’m having some trouble digesting the example code you posted – do I have to instantiate both a WebSocketClient and a TCPClient instance? Right now I’m just getting Connection failed in the Serial output. I’d appreciate it if you could post an example of this. As you can tell the subject of the Websocket protocol is beyond me at this point. A nudge in the right direction will help - a lot!

The Spacebrew API relies on JSON data in this format. Any chance you might be able to try this out?

On a side note, I’ve also been tinkering with @ekbduffy’s version here: Through his library I was able to establish a connection and have the server return a Sec-WebSocket-Accept response:

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: (key)

However, I was not able to go any further – subsequent configuration or data messages sent out never gets received by the Spacebrew server.

1 Like

Can you tell me what time took passing message to spacebrew and then receive in on Spark and parse on it in Your code?
I’ve testing this with clicking on html page with SpacebrewJS and then pass boolean message to spark. And message arriving so fast to spark then in parses about half of second… Thinking how to speed up this…

I’ve merged this with your thread, my timings are posted there:

1 Like