03-19-2022 01:01
03-19-2022 01:01
I am currently running code using the Fitbit Ionic, and for some reason, my messaging stopped working; everything was running fine last week, and now all of a sudden, this line below won't work. The connection remains closed. Please provide advice on how to troubleshoot to see why the Fitbit stop communicating with the companion:
/messaging.peerSocket.readyState === messaging.peerSocket.OPEN
03-19-2022 05:48
03-19-2022 06:39
03-19-2022 06:39
Hi @Guy_, when you say that the bridge could be in a corrupted state when performing many tests, are you saying that something has happened on the companion side and that I should log out of the Fitbit app on the device or turn the app off on the Fitbit.
03-19-2022 07:51
03-19-2022 07:51
Also, @Guy_, thank you for your response! This code below is how I found out the connection wasn't working. I wondered if it would cause this line down below to execute every time.
if (messaging.peerSocket.readyState === messaging.peerSocket.CLOSED) {
console.error("Error: Connection is not open");
}
03-19-2022 08:14
03-19-2022 08:14
@Guy_, I tried logging out of the system like you suggested (I believe I interpreted what you said correctly) that didn't seem to work, I also wanted to force it open, but that didn't seem to work either by following the suggested code:
Are there any other steps that I might be able to take?
03-19-2022 21:54
03-20-2022 07:00
03-20-2022 07:00
@Guy_ - I tried to restart the watch and phone. I also erased all program instances from the watch, simulator, and phone to clear the bridges. The private link/ public link install is that something that is used in Fitbit studio? I'm not sure if I executed all you mentioned above, but I believe that I have, and it didn't work. I also tried to force the channel open here is the snippet of code that I have been trying to adjust in my code:
messaging.peerSocket.onopen = function() {
console.log("connection open for sendMessageHeart")
// Ready to send messages
sendMessageHeart();
}
// Listen for the onerror event
messaging.peerSocket.onerror = function(err) {
// Handle any errors
console.log("Connection error: " + err.code + " - " + err.message);
}
function sendMessageHeart() {
// Sample data
var dataA;
var dataC;
//The actual time sent to thingspeak
if(sentHeart[1]==60)
dataC = [60,sentHeart[0]];
else
dataC = [30,sentHeart];
if (messaging.peerSocket.readyState === messaging.peerSocket.OPEN) {
// Send the data to peer as a message
messaging.peerSocket.send(dataC);
}
else {//trying to open a connection by force to see if this is the problem
messaging.peerSocket.onopen = () => {
console.log("Data sent");
messaging.peerSocket.send(dataC)
}
}
if (messaging.peerSocket.readyState === messaging.peerSocket.CLOSED) {
console.error("Error: Connection is not open");
}
}
03-20-2022 07:33
03-20-2022 11:04
03-20-2022 11:04
@Guy_, thanks for the help. @Gondwana or @JonFitbit, do you have any suggestions for me? I appreciate any help you can provide.
03-20-2022 11:33
03-20-2022 11:33
@Guy_, my phone updated, and now it's starting to work, so I guess that was the problem. I appreciate your help.
03-20-2022 11:35