05-24-2022 10:02
05-24-2022 10:02
I have a watch face that used the companion app to determine distance based on gps coordinates.
I am calling the companion using
if (messaging.peerSocket.readyState === messaging.peerSocket.OPEN) {
messaging.peerSocket.send(data);
} else {
console.log("No peerSocket connection");
}
In the companion it takes data and then returns a json with gps info.
Code in companion to receive the message:
messaging.peerSocket.onmessage = function(evt) {
if (evt.data.key) {
....
If I use the simulator and the companion sim. This works perfectly. When I load this to the watch and phone, I don't see this happening. I have tried putting console.log() messages to see what is happening but I am not seeing any action.
I have run in background enabled.
My device is syncing with the phone no problem. I did notice that it is not showing up in the connected bluetooth devices list.
Any thoughts/tips?
Thanks,
Paul
Answered! Go to the Best Answer.
05-24-2022 15:43
05-24-2022 15:43
If console.log("No peerSocket connection")
then you should start a retry sending the data. I retry every 2 seconds
The simulator always has connection. the watch not so often. I often have connection problems with the Sense.
I guess the companion sends the date (GPS) and your watch calls the companion.
You can do it in reverse when you have GPS on the watch of course.
05-24-2022 15:43
05-24-2022 15:43
If console.log("No peerSocket connection")
then you should start a retry sending the data. I retry every 2 seconds
The simulator always has connection. the watch not so often. I often have connection problems with the Sense.
I guess the companion sends the date (GPS) and your watch calls the companion.
You can do it in reverse when you have GPS on the watch of course.
05-24-2022 16:24
05-24-2022 16:24
Thanks Mario! I will give that a try. I am getting the
GPS data from watch, then sending to companion where it looks for the best match in json object with loads of entries. I'm basically using companion like database to host large data so it is not on watch side.
Thanks again, Paul