mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 02:10:32 +00:00
00_MQTT2_CLIENT.pm: implement CONNACK timeout (Forum #114166)
git-svn-id: https://svn.fhem.de/fhem/trunk@22936 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
efa873dfa1
commit
319ac2fac3
@ -131,6 +131,7 @@ MQTT2_CLIENT_doinit($)
|
|||||||
pack("C",0x10).
|
pack("C",0x10).
|
||||||
MQTT2_CLIENT_calcRemainingLength(length($msg)).$msg, 1, 1); # Forum #92946
|
MQTT2_CLIENT_calcRemainingLength(length($msg)).$msg, 1, 1); # Forum #92946
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
|
$hash->{waitingForConnack} = 1;
|
||||||
if($keepalive) {
|
if($keepalive) {
|
||||||
InternalTimer(gettimeofday()+$keepalive,"MQTT2_CLIENT_keepalive",$hash,0);
|
InternalTimer(gettimeofday()+$keepalive,"MQTT2_CLIENT_keepalive",$hash,0);
|
||||||
}
|
}
|
||||||
@ -182,10 +183,13 @@ MQTT2_CLIENT_keepalive($)
|
|||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
if($hash->{waitingForConnack}) {
|
||||||
|
Log3 $name, 2, "$hash->{NAME}: No CONNACK, disconnecting";
|
||||||
|
return MQTT2_CLIENT_Disco($hash);
|
||||||
|
}
|
||||||
if($hash->{waitingForPingRespSince}) {
|
if($hash->{waitingForPingRespSince}) {
|
||||||
Log3 $name, 2, "$hash->{NAME}: No PINGRESP for last PINGREQ (".
|
Log3 $name, 2, "$hash->{NAME}: No PINGRESP for last PINGREQ (".
|
||||||
"at $hash->{waitingForPingRespSince}), disconnecting";
|
"at $hash->{waitingForPingRespSince}), disconnecting";
|
||||||
delete $hash->{waitingForPingRespSince};
|
|
||||||
return MQTT2_CLIENT_Disco($hash);
|
return MQTT2_CLIENT_Disco($hash);
|
||||||
}
|
}
|
||||||
my $keepalive = AttrVal($name, "keepaliveTimeout", 30);
|
my $keepalive = AttrVal($name, "keepaliveTimeout", 30);
|
||||||
@ -224,6 +228,9 @@ MQTT2_CLIENT_Disco($;$$)
|
|||||||
delete($hash->{disconnectTimerHash});
|
delete($hash->{disconnectTimerHash});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete $hash->{waitingForConnack};
|
||||||
|
delete $hash->{waitingForPingRespSince};
|
||||||
|
|
||||||
readingsSingleUpdate($hash, "state", "disconnected", 1);
|
readingsSingleUpdate($hash, "state", "disconnected", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,6 +425,7 @@ MQTT2_CLIENT_Read($@)
|
|||||||
|
|
||||||
####################################
|
####################################
|
||||||
if($cpt eq "CONNACK") {
|
if($cpt eq "CONNACK") {
|
||||||
|
delete($hash->{waitingForConnack});
|
||||||
my $rc = ord(substr($pl,1,1));
|
my $rc = ord(substr($pl,1,1));
|
||||||
if($rc == 0) {
|
if($rc == 0) {
|
||||||
MQTT2_CLIENT_doinit($hash);
|
MQTT2_CLIENT_doinit($hash);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user