I think the timeout is around 2 minutes. It happens whether I write from time to time or not.
I am pretty sure that the problem is that the connection breaks down: I checked from the iPhone with LightBlue and saw the peripheral Puck listed there after a while. And I was also able to connect to it from LightBlue. I think that is evidence that the connection between the two Pucks is no longer existing.
Another interesting observation is that when doing the connection from LightBlue as a central I see the same problem: After about 2 minutes I get a "Disconnected Alert" from LightBlue. So for whatever reason the connection is disconnected from the peripheral after 2 minutes (or so).
I agree that it is necessary to handle the breakdown of connections. But on the other hand having a connection for more than 2 minutes is probably important for a lot of applications. Especially since the reconnect takes about 10-15 seconds.
I like the idea of using gatt.connected to check upfront if the connection is still existing. However in my case it still returns true, although writing fails. Even with a regular timer it still returns true at a point where the connection is no longer existing (because LightBlue lists the peripheral Puck again as advertising).
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.
Hi @Gordon, thanks for your answers!
I think the timeout is around 2 minutes. It happens whether I write from time to time or not.
I am pretty sure that the problem is that the connection breaks down: I checked from the iPhone with LightBlue and saw the peripheral Puck listed there after a while. And I was also able to connect to it from LightBlue. I think that is evidence that the connection between the two Pucks is no longer existing.
Another interesting observation is that when doing the connection from LightBlue as a central I see the same problem: After about 2 minutes I get a "Disconnected Alert" from LightBlue. So for whatever reason the connection is disconnected from the peripheral after 2 minutes (or so).
I agree that it is necessary to handle the breakdown of connections. But on the other hand having a connection for more than 2 minutes is probably important for a lot of applications. Especially since the reconnect takes about 10-15 seconds.
I like the idea of using gatt.connected to check upfront if the connection is still existing. However in my case it still returns true, although writing fails. Even with a regular timer it still returns true at a point where the connection is no longer existing (because LightBlue lists the peripheral Puck again as advertising).