Reason for lost connection
What feature would you like? Currently there's a callback method that is called when the connection is lost. There's however no way (programmatically) to know what happened. I feel that it would be good to provide that information.
Describe the solution you'd like
My suggestion is to consolidate connection_closed and connection_lost into one method and add a reason parameter stating the reason why the connection was closed. The reasons I can come up with this far are:
- Invoked by user (I.e. explicit call to
close, same asconnection_closedtoday) - Connection lost for arbitrary reason, e.g. timeout, reset, etc.
- Heartbeat failure
- Device goes to sleep (
TheDeviceIsGoingToSleeperror code in case of MRP)
This would effectively be a breaking change as it would require modifications to the DeviceListener interface. It can however be implemented to be non-breaking by calling the existing methods and mark them as deprecated for a while.
Any other information to share? No
Also include which protocol that caused disconnect (when applicable).