You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been breaking my head to make this work and I keep on receiving the "Unable to connect to device" error when it reaches the connect stage of the code.
The only way it can work is if I disconnect and when successful, automatically unsubscribe and then manually invoke the bluetoothSerial.connect.
The code that is not working is bellow:
function(){
bluetoothSerial.unsubscribe(
function (data) {
console.log("UNSUBSCRIBED-> "+data);
// CONNECT TO NEXT BTDEVICE
app.connect()
},
app.showError
);
}, // stop listening to the port
app.showError // show the error if you fail
);
showError: function(error) {
console.log("ERROR RECEIVED -> "+ error);
},
connect: function () {
// attempt to connect:
console.log("CONNECT");
console.log("TRYING TO CONNECT WITH Mac> "+app.macAddress);
bluetoothSerial.connect(
app.macAddress, // device to connect to
app.openPort, // start listening if you succeed
app.showError // show the error if you fail
);
},
Thanks!
The text was updated successfully, but these errors were encountered:
@manorius I think the correct way to do what you want is unsubscribe, disconnect, connect, subscribe. If the subscription is the same, you may be able to just disconnect from one, and connect to the second. (I haven't tested this.)
The way the code is structured, you can only be connected to on device at a time.
The subscribe and unsubcribe functions only affect how/when the javascript code is notified about the incoming data. Unsubscribing will not change the connection.
I've been breaking my head to make this work and I keep on receiving the "Unable to connect to device" error when it reaches the connect stage of the code.
The only way it can work is if I disconnect and when successful, automatically unsubscribe and then manually invoke the bluetoothSerial.connect.
The code that is not working is bellow:
Thanks!
The text was updated successfully, but these errors were encountered: