ioBroker / ioBroker.rflink

Support of RFLink
MIT License
11 stars 11 forks source link

Random disconnect serial #33

Open evanes68 opened 4 years ago

evanes68 commented 4 years ago

My rflink works well, but sometimes I get a disconnect and the adapter instance goes yellow.

I looked at the code in lib/serial.js and I see there is reconnect logic in the write routine, but there is no automatic reconnect on random disconnect.

In order to enable this please add the following lines in serial.js in the this.disconnected = function() (the disconnectTimeout line is an existing line to show where to add the code):

this.disconnectTimeout = null;

// reconnect logic if we receive an unexpected disconnect while still have the interface open.
if (this._interface) {
    this._interface.close();
    this._interface = null;
    this._interfaceParser = null;

    setTimeout(() => openSerial(), 2000);
}
evanes68 commented 4 years ago

Hmm, I now see the closed issue on disconnecttimeout...

It seems the connection is disconnected in my instance because for 10 minutes there are no messages. Which is logical because I am in a rural area with only some remotes sending signals.

The only reason I can understand such a timeout is if the rflink goes silent. But would you not want a reconnect in this situation? And not only on a write command but also on a system that only reads rflink messages?

I think I may have to increase the disconnecttimeout a little, but I still think the adapter need reconnect logic.

What is your position on this?

Apollon77 commented 4 years ago

What is your position on this?

Happy to get a PR :-)

evanes68 commented 4 years ago

It took me a while to figure out what a PR is. This being my first, be gentle...