2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 05:16:45 +00:00

00_HMUARTLGW.pm: delay reconnect when remote disconnects immediately

git-svn-id: https://svn.fhem.de/fhem/trunk@11981 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
mgernoth 2016-08-17 21:05:13 +00:00
parent bb9e1ce3c8
commit bbeb17b8f5

View File

@ -181,6 +181,7 @@ sub HMUARTLGW_DoInit($)
delete($hash->{owner}); delete($hash->{owner});
$hash->{DevState} = HMUARTLGW_STATE_NONE; $hash->{DevState} = HMUARTLGW_STATE_NONE;
$hash->{XmitOpen} = 0; $hash->{XmitOpen} = 0;
$hash->{LastOpen} = gettimeofday();
$hash->{LGW_Init} = 1 if ($hash->{DevType} =~ m/^LGW/); $hash->{LGW_Init} = 1 if ($hash->{DevType} =~ m/^LGW/);
@ -298,6 +299,12 @@ sub HMUARTLGW_Ready($)
Log3($hash, 4, "HMUARTLGW ${name} ready: ".$hash->{STATE}); Log3($hash, 4, "HMUARTLGW ${name} ready: ".$hash->{STATE});
if ((!$hash->{lgwHash}) && $hash->{STATE} eq "disconnected") { if ((!$hash->{lgwHash}) && $hash->{STATE} eq "disconnected") {
#don't immediately reconnect when we just connected, delay
#for 5s because remote closed the connection on us
if (defined($hash->{LastOpen}) &&
$hash->{LastOpen} + 5 >= gettimeofday()) {
return 0;
}
return HMUARTLGW_Reopen($hash, 1); return HMUARTLGW_Reopen($hash, 1);
} }
@ -2146,8 +2153,8 @@ sub HMUARTLGW_getVerbLvl($$$$) {
<li>LAN Gateway at <code>192.168.42.23</code>:<br> <li>LAN Gateway at <code>192.168.42.23</code>:<br>
<code>define myHmLGW HMUARTLGW 192.168.42.23</code><br>&nbsp;</li> <code>define myHmLGW HMUARTLGW 192.168.42.23</code><br>&nbsp;</li>
<li>Remote HM-MOD-UART using <code>socat</code> on a Raspberry Pi:<br> <li>Remote HM-MOD-UART using <code>socat</code> on a Raspberry Pi:<br>
Remote Raspberry Pi:<br><code>$ socat TCP4-LISTEN:12345,fork,reuseaddr /dev/ttyAMA0,raw,echo=0,b115200</code><br><br> <code>define myRemoteHmUART HMUARTLGW uart://192.168.42.23:12345</code><br><br>
Fhem:<br><code>define myRemoteHmUART HMUARTLGW uart://192.168.42.23:12345</code></li> Remote Raspberry Pi:<br><code>$ socat TCP4-LISTEN:12345,fork,reuseaddr /dev/ttyAMA0,raw,echo=0,b115200</code></li>
</ul> </ul>
</ul> </ul>
<br> <br>