You could respond to gattserverdisconnected and setTimeout a reconnect, but then you'll have to cope with rescheduling that if the reconnect fails. The setInterval is easy
Only thing I'd say is 3 secs might be a bit tight - I think there's a possibility that some devices could almost take 3 seconds to connect, and then you might get an error when you tried to connect a second time while in the process of connecting.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Yes, it 's a bug in the 2v04 firmware. If you install 2v05 it should work fine
But it should be harmless as you say -with the
gattserverdisconnected
handler you should be fine. Does it not work?No, that one is called when a device disconnects from Espruino, rather than the other way around :)
I think that's a nice easy solution. I think rather than a
connected
flag you could even usedevcie.connected
: http://www.espruino.com/Reference#l_BlueÂtoothDevice_connectedYou could respond to
gattserverdisconnected
andsetTimeout
a reconnect, but then you'll have to cope with rescheduling that if the reconnect fails. The setInterval is easyOnly thing I'd say is 3 secs might be a bit tight - I think there's a possibility that some devices could almost take 3 seconds to connect, and then you might get an error when you tried to connect a second time while in the process of connecting.