mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
10_EQ3BT: ssh bugfixes
git-svn-id: https://svn.fhem.de/fhem/trunk@17484 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
51e0b89377
commit
74925619ca
@ -8,6 +8,9 @@
|
|||||||
#
|
#
|
||||||
#############################################################
|
#############################################################
|
||||||
#
|
#
|
||||||
|
# v2.0.5 - 20181007
|
||||||
|
# - BUGFIX: ssh bugfixes by CoolTux
|
||||||
|
#
|
||||||
# v2.0.4 - 20180224
|
# v2.0.4 - 20180224
|
||||||
# - FEATURE: support childlock
|
# - FEATURE: support childlock
|
||||||
#
|
#
|
||||||
@ -156,7 +159,7 @@ sub EQ3BT_Initialize($) {
|
|||||||
$hash->{GetFn} = 'EQ3BT_Get';
|
$hash->{GetFn} = 'EQ3BT_Get';
|
||||||
$hash->{SetFn} = 'EQ3BT_Set';
|
$hash->{SetFn} = 'EQ3BT_Set';
|
||||||
$hash->{AttrFn} = 'EQ3BT_Attribute';
|
$hash->{AttrFn} = 'EQ3BT_Attribute';
|
||||||
$hash->{AttrList} = 'sshHost maxRetries timeout '.
|
$hash->{AttrList} = 'sshHost maxRetries timeout blockingCallLoglevel '.
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -171,7 +174,8 @@ sub EQ3BT_Define($$) {
|
|||||||
my $sshHost;
|
my $sshHost;
|
||||||
|
|
||||||
$hash->{STATE} = "initialized";
|
$hash->{STATE} = "initialized";
|
||||||
$hash->{VERSION} = "2.0.4";
|
$hash->{VERSION} = "2.0.5";
|
||||||
|
$hash->{loglevel} = 4;
|
||||||
Log3 $hash, 3, "EQ3BT: EQ-3 Bluetooth Thermostat ".$hash->{VERSION};
|
Log3 $hash, 3, "EQ3BT: EQ-3 Bluetooth Thermostat ".$hash->{VERSION};
|
||||||
|
|
||||||
if (int(@a) > 4) {
|
if (int(@a) > 4) {
|
||||||
@ -235,12 +239,20 @@ sub EQ3BT_pairDevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub EQ3BT_Attribute($$$$) {
|
sub EQ3BT_Attribute($$$$) {
|
||||||
my ($mode, $devName, $attrName, $attrValue) = @_;
|
my ( $cmd, $name, $attrName, $attrVal ) = @_;
|
||||||
|
my $hash = $defs{$name};
|
||||||
|
|
||||||
if($mode eq "set") {
|
if($cmd eq "set") {
|
||||||
|
if( $attrName eq "blockingCallLoglevel" ) {
|
||||||
} elsif($mode eq "del") {
|
$hash->{loglevel} = $attrVal;
|
||||||
|
Log3 $name, 3, "EQ3BT ($name) - set blockingCallLoglevel to $attrVal";
|
||||||
|
}
|
||||||
|
|
||||||
|
} elsif($cmd eq "del") {
|
||||||
|
if( $attrName eq "blockingCallLoglevel" ) {
|
||||||
|
$hash->{loglevel} = 4;
|
||||||
|
Log3 $name, 3, "EQ3BT ($name) - set blockingCallLoglevel to $attrVal";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -499,15 +511,19 @@ sub EQ3BT_execGatttool($) {
|
|||||||
my ($name, $mac, $workType, $handle, $value, $listen) = split("\\|", $string);
|
my ($name, $mac, $workType, $handle, $value, $listen) = split("\\|", $string);
|
||||||
my $wait = 1;
|
my $wait = 1;
|
||||||
my $hash = $main::defs{$name};
|
my $hash = $main::defs{$name};
|
||||||
|
my $sshHost = AttrVal($name,"sshHost","none");
|
||||||
|
my $gatttool; # = qx(which gatttool);
|
||||||
|
|
||||||
my $gatttool = qx(which gatttool);
|
$gatttool = qx(which gatttool) if($sshHost eq 'none');
|
||||||
|
$gatttool = qx(ssh $sshHost 'which gatttool') if($sshHost ne 'none');
|
||||||
chomp $gatttool;
|
chomp $gatttool;
|
||||||
|
|
||||||
if(-x $gatttool) {
|
#if(-x $gatttool) {
|
||||||
|
if(defined($gatttool) and ($gatttool)) {
|
||||||
my $gtResult;
|
my $gtResult;
|
||||||
my $cmd;
|
my $cmd;
|
||||||
my $sshHost = AttrVal($name,"sshHost","none");
|
my $hciDevice = "hci".$hash->{helper}{hcidevices}[$hash->{helper}{currenthcidevice}];
|
||||||
|
|
||||||
while($wait) {
|
while($wait) {
|
||||||
my $grepGatttool = qx(ps ax| grep -E \'gatttool -b $mac\' | grep -v grep);
|
my $grepGatttool = qx(ps ax| grep -E \'gatttool -b $mac\' | grep -v grep);
|
||||||
if(not $grepGatttool =~ /^\s*$/) {
|
if(not $grepGatttool =~ /^\s*$/) {
|
||||||
@ -518,6 +534,18 @@ sub EQ3BT_execGatttool($) {
|
|||||||
$wait = 0;
|
$wait = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$cmd .= "ssh $sshHost '" if($sshHost ne 'none');
|
||||||
|
$cmd .= "timeout " . AttrVal($name, "timeout", 15) . " " if($listen);
|
||||||
|
$cmd .= "gatttool -i $hciDevice -b $mac ";
|
||||||
|
$cmd .= "--char-write-req -a $handle -n $value";
|
||||||
|
$cmd .= " --listen" if($listen);
|
||||||
|
$cmd .= " 2>&1 /dev/null";
|
||||||
|
$cmd .= "'" if($sshHost ne 'none');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($value eq "03") {
|
if($value eq "03") {
|
||||||
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
|
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
|
||||||
@ -525,24 +553,24 @@ sub EQ3BT_execGatttool($) {
|
|||||||
$value .= $currentDate;
|
$value .= $currentDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $hciDevice = "hci".$hash->{helper}{hcidevices}[$hash->{helper}{currenthcidevice}];
|
|
||||||
#my $cmd = "gatttool -b $mac -i $hciDevice --char-write-req --handle=$handle --value=$value";
|
#my $cmd = "gatttool -b $mac -i $hciDevice --char-write-req --handle=$handle --value=$value";
|
||||||
if( $sshHost ne 'none' ) {
|
# if( $sshHost ne 'none' ) {
|
||||||
$cmd = "ssh $sshHost 'gatttool -b $mac -i $hciDevice --char-write-req --handle=$handle --value=$value";
|
# $cmd = "ssh $sshHost 'gatttool -b $mac -i $hciDevice --char-write-req --handle=$handle --value=$value";
|
||||||
} else {
|
# } else {
|
||||||
$cmd = "gatttool -b $mac -i $hciDevice --char-write-req --handle=$handle --value=$value";
|
# $cmd = "gatttool -b $mac -i $hciDevice --char-write-req --handle=$handle --value=$value";
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
if(defined($listen) && $listen eq "listen") {
|
# if(defined($listen) && $listen eq "listen") {
|
||||||
$cmd = "timeout ".AttrVal($name, "timeout", 15)." ".$cmd." --listen";
|
# $cmd = "timeout ".AttrVal($name, "timeout", 15)." ".$cmd." --listen";
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
#redirect stderr to stdout
|
# #redirect stderr to stdout
|
||||||
if( $sshHost ne 'none' ) {
|
# if( $sshHost ne 'none' ) {
|
||||||
$cmd .= " 2>&1'";
|
# $cmd .= " 2>&1'";
|
||||||
} else {
|
# } else {
|
||||||
$cmd .= " 2>&1";
|
# $cmd .= " 2>&1";
|
||||||
}
|
# }
|
||||||
|
|
||||||
Log3 $name, 5, "EQ3BT ($name): $cmd";
|
Log3 $name, 5, "EQ3BT ($name): $cmd";
|
||||||
$gtResult = qx($cmd);
|
$gtResult = qx($cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user