-
Thank you for fixing the relay. I was able to upload a scripts and communicate with the Puck through it successfully. I might still, out of curiosity, try to set up a working version on my local machine using a self signed certificate.
In regards to WebRTC. You have to broker the connection yes, but this is (theoretically) possible, without using a dedicated server. There is a demo which just provides you with the signaling payload and you can use what ever way you want to transfer it to the other client. Based upon that someone created a demo for signaling via QR-Code, which unfortunately doesn't work for me.
But even if the websocket connection is still used for the signaling, it might be an option to do the rest of the communication via p2p. The benefit could be faster communication with the Puck and it would not require additional communication with the server, after the channel is created, so it could provide more stability if you want to use the relay somewhere, where you don't have a fast or stable internet connection.
-
Hi,
I got my Puck.JS today and wanted to get right into programming without waiting for my bluetooth dongle to arrive. So I tried to use the relay function.
Unfortunately I could not get it to work though. It always stopped with the message "Starting Websocket connection" on the phone. I tried it with my Nexus 5X on Android 7.1.1 and Chrome 57.0.2987.132.
I then tried to start up the server on my own computer to potentially see what went wrong
node server.js
did not server anything under/relay
and I also read that it only supports one session at a time, which would probably cause problems with the relaying anyways.With the python server twisted I managed to server the root directory with ssl including the
/relay
subdirectory usingtwistd -no web --https=4444 --path=.
. But I could not figure out if there is a websocket relay server included or if there is a default one that I should be running.I also tried setting
var WS_HOST = 'wss://espruino.com:8443';
with the UI hosted from my computer. With that and the following code added torelay.js
, I got the outputEncountered an error: {"isTrusted": true}
. Which didn't yield any additional insights and might just be due to Cross-Origin restrictions.socket.addEventListener('error', function (error) { term("Encountered an error: "+JSON.stringify(error)); });
Any pointers on how to properly run a local setup or maybe get the relay on espruino.com working are much appreciated.
On a related note: @Gordon Did you try or think about using peer-to-peer communication using WebRTC instead of websockets for the communication between the browsers? That way there might not be a need for a websocket server.
Just a little project I did to get familiar with the Puck, but maybe it's interesting to someone nonetheless. A self-calibrating volume control knob using the magnetometer and bluetooth hid.
To use it, upload the script, lay the Puck flat on the table, spin it slowly one or two times to calibrate the magnetometer readings. Then press the Puck once and spin it to control the volume of the devices it is connected to via bluetooth (if it is supported). There are some problems with detecting overflow, but it works ok.
Beware, this is polling the magnetometer with 10 Hz, so it might drain the battery if you keep it running.