2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-21 07:56:03 +00:00

LandroidUtils.pm: reconnect fix

git-svn-id: https://svn.fhem.de/fhem/trunk@27411 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2023-04-07 20:10:13 +00:00
parent 1e420783b6
commit 10cac061dd

View File

@ -63,15 +63,13 @@ Landroid_connect($$;$)
my $rt = ReadingsVal($m2c_name, ".refresh_token", undef);
my $ra = ReadingsAge($m2c_name, ".refresh_token", 0);
my $data;
if($rt && $ra < 1800) { # refresh
if($rt && $ra < 3600) { # refresh
$data = { grant_type=>"refresh_token", refresh_token=>$rt,
client_id=>$t->{clientId}, scope=>"*" };
$ra = 3600-$ra;
} else {
$data = { grant_type=>"password", username=>$usr, password=>$pwd,
client_id=>$t->{clientId}, scope=>"*" };
$ra = 3600;
}
HttpUtils_NonblockingGet({
@ -88,11 +86,11 @@ Landroid_connect($$;$)
Log3 $m2c, 4, "$m2c_name: Got auth info, request: ".$data->{grant_type};
setReadingsVal($m2c, ".refresh_token",
$m2c->{".auth"}{refresh_token}, TimeNow());
InternalTimer(gettimeofday()+$ra-60,
InternalTimer(gettimeofday()+3540,
sub(){
Log3 $m2c, 4, "$m2c_name: requesting new token";
Landroid_connect($m2c_name, $type)
}, "landroidTmr_$m2c_name", 0) if($ra > 60);
}, "landroidTmr_$m2c_name", 0);
Landroid_connect2($m2c_name);
},
header => {