From 4a9a958bd4947209a93ddea744a5cc84291ce93b Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sat, 1 Apr 2023 20:10:06 +0000 Subject: [PATCH] 00_MQTT2_CLIENT.pm: landroid worx / AWS-IOT stuff (Forum #111959) git-svn-id: https://svn.fhem.de/fhem/trunk@27382 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_MQTT2_CLIENT.pm | 23 ++++++++++++++++++++++- fhem/FHEM/HttpUtils.pm | 8 ++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/fhem/FHEM/00_MQTT2_CLIENT.pm b/fhem/FHEM/00_MQTT2_CLIENT.pm index c519ac3ec..b6ea18155 100644 --- a/fhem/FHEM/00_MQTT2_CLIENT.pm +++ b/fhem/FHEM/00_MQTT2_CLIENT.pm @@ -40,6 +40,7 @@ MQTT2_CLIENT_Initialize($) clientId clientOrder connectTimeout + connectFn disable:1,0 disabledForIntervals disconnectAfter @@ -97,7 +98,17 @@ MQTT2_CLIENT_Define($$) $hash->{connecting} = 1; $hash->{nrConnects} = 0; - InternalTimer(1, "MQTT2_CLIENT_connect", $hash, 0); # need attributes + InternalTimer(1, sub($){ + my $cfn = AttrVal($hash->{NAME}, "connectFn", undef); + if($cfn) { + my %specials= ("%NAME" => $hash->{NAME}); + $cfn = EvalSpecials($cfn, %specials); + AnalyzeCommand(undef, $cfn); # $cfn calls connect + } else { + MQTT2_CLIENT_connect($hash); + } + }, $hash, 0); + return undef; } @@ -136,6 +147,8 @@ MQTT2_CLIENT_doinit($) if($hash->{connecting} == 1) { my $usr = AttrVal($name, "username", ""); my ($err, $pwd) = getKeyValue($name); + $usr = $hash->{".usr"} if($hash->{".usr"}); # AWS/WORX + $pwd = $hash->{".pwd"} if($hash->{".pwd"}); $pwd = undef if($usr eq ""); if($err) { Log 1, "ERROR: $err"; @@ -876,6 +889,14 @@ MQTT2_CLIENT_feedTheList($$$) Note: Changing the attribute affects _all_ MQTT2_CLIENT instances.
+ +
  • connectFn {...}
    + if set, do not connect immediately, but evaluate the argument, which in + turn has to call the connect function via fhem("set NAME connect") or + MQTT2_CLIENT_connect(...).
    + Needed by AWS-IOT connect with custom auth. +

  • +
  • connectTimeout <seconds>
    change the HTTP connect timeout, default is 4 seconds. This seems to be diff --git a/fhem/FHEM/HttpUtils.pm b/fhem/FHEM/HttpUtils.pm index 853112058..ebe85cf78 100644 --- a/fhem/FHEM/HttpUtils.pm +++ b/fhem/FHEM/HttpUtils.pm @@ -557,6 +557,14 @@ HttpUtils_Connect2NonblockingSSL($$) } $hash->{hu_sslAdded} = $hash->{keepalive} ? 1 : 2; + + Log 4, "alpn_selected:".$hash->{conn}->alpn_selected() + if($par->{SSL_alpn_protocols} && + $hash->{conn}->can('alpn_selected')); + Log 4, "next_proto_negotiated:".$hash->{conn}->next_proto_negotiated() + if($par->{SSL_npn_protocols} && + $hash->{conn}->can('next_proto_negotiated')); + return HttpUtils_Connect2($hash); # Continue with HTML-Processing };