Debugausgaben auskommentiert, verbessertes Fehlerhandling
This commit is contained in:
parent
f3622b05dc
commit
c85006ac21
@ -35,7 +35,7 @@ use POSIX;
|
|||||||
use JSON;
|
use JSON;
|
||||||
use Blocking;
|
use Blocking;
|
||||||
|
|
||||||
my $version = "0.1.51";
|
my $version = "0.1.54";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -169,6 +169,7 @@ sub XiaomiFlowerSens_stateRequest($) {
|
|||||||
|
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
|
readingsSingleUpdate ( $hash, "state", "active", 1 ) if( ReadingsVal($name, "state", 0) eq "initialized" or ReadingsVal($name, "state", 0) eq "unreachable" );
|
||||||
XiaomiFlowerSens($hash);
|
XiaomiFlowerSens($hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +260,6 @@ sub XiaomiFlowerSens_gattCharRead($$) {
|
|||||||
my ($mac,$wfr) = @_;
|
my ($mac,$wfr) = @_;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
my $loop = 0;
|
my $loop = 0;
|
||||||
while ( (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop = 0) or (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop < 5) ) {
|
while ( (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop = 0) or (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop < 5) ) {
|
||||||
printf "\n(Sub XiaomiFlowerSens_Run) - gatttool noch aktiv, wait 0.5s for new check\n";
|
printf "\n(Sub XiaomiFlowerSens_Run) - gatttool noch aktiv, wait 0.5s for new check\n";
|
||||||
@ -267,11 +267,10 @@ sub XiaomiFlowerSens_gattCharRead($$) {
|
|||||||
$loop++;
|
$loop++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#printf "\n\nSub XiaomiFlowerSens - WriteForRead: $wfr";
|
||||||
Log3 $name, 4, "Sub XiaomiFlowerSens_Done ($name) - WriteForRead: $wfr";
|
|
||||||
## support for Firmware 2.6.6, man muß erst einen Characterwert schreiben
|
## support for Firmware 2.6.6, man muß erst einen Characterwert schreiben
|
||||||
my $wresp = qx(gatttool -b $mac --char-write-req -a 0x33 -n A01F) if($wfr == 1);
|
my $wresp = qx(gatttool -b $mac --char-write-req -a 0x33 -n A01F) if($wfr == 1);
|
||||||
Log3 $name, 4, "Sub XiaomiFlowerSens_Done ($name) - WriteResponse: $wresp";
|
#printf "\nSub XiaomiFlowerSens - WriteResponse: $wresp\n\n";
|
||||||
|
|
||||||
my @readData = split(": ",qx(gatttool -b $mac --char-read -a 0x35));
|
my @readData = split(": ",qx(gatttool -b $mac --char-read -a 0x35));
|
||||||
|
|
||||||
@ -292,6 +291,7 @@ sub XiaomiFlowerSens_readBatFW($) {
|
|||||||
|
|
||||||
my ($mac) = @_;
|
my ($mac) = @_;
|
||||||
|
|
||||||
|
|
||||||
my $loop = 0;
|
my $loop = 0;
|
||||||
while ( (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop = 0) or (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop < 5) ) {
|
while ( (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop = 0) or (qx(ps ax | grep -v grep | grep "gatttool -b $mac") and $loop < 5) ) {
|
||||||
printf "\n(Sub XiaomiFlowerSens_Run) - gatttool noch aktiv, wait 0.5s for new check\n";
|
printf "\n(Sub XiaomiFlowerSens_Run) - gatttool noch aktiv, wait 0.5s for new check\n";
|
||||||
@ -299,7 +299,6 @@ sub XiaomiFlowerSens_readBatFW($) {
|
|||||||
$loop++;
|
$loop++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my @readData = split(": ",qx(gatttool -b $mac --char-read -a 0x38));
|
my @readData = split(": ",qx(gatttool -b $mac --char-read -a 0x38));
|
||||||
|
|
||||||
return (undef,undef,undef,undef)
|
return (undef,undef,undef,undef)
|
||||||
@ -368,7 +367,7 @@ sub XiaomiFlowerSens_Done($) {
|
|||||||
readingsBulkUpdate($hash, "moisture", $response_json->{moisture});
|
readingsBulkUpdate($hash, "moisture", $response_json->{moisture});
|
||||||
readingsBulkUpdate($hash, "fertility", $response_json->{fertility});
|
readingsBulkUpdate($hash, "fertility", $response_json->{fertility});
|
||||||
readingsBulkUpdate($hash, "firmware", $response_json->{firmware});
|
readingsBulkUpdate($hash, "firmware", $response_json->{firmware});
|
||||||
readingsBulkUpdate($hash, "state", "active") if( ReadingsVal($name,"state", 0) eq "call data" );
|
readingsBulkUpdate($hash, "state", "active") if( ReadingsVal($name,"state", 0) eq "call data" or ReadingsVal($name,"state", 0) eq "unreachable" );
|
||||||
readingsEndUpdate($hash,1);
|
readingsEndUpdate($hash,1);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user