change code for --listen option
This commit is contained in:
parent
817c315801
commit
c04ca68254
@ -53,8 +53,8 @@ my $version = "2.0.8";
|
|||||||
|
|
||||||
|
|
||||||
my %XiaomiModels = (
|
my %XiaomiModels = (
|
||||||
flowerSens => {'rdata' => '0x35' ,'wdata' => '0x33' ,'wdataValue' => 'A01F' ,'battery' => '0x38' ,'firmware' => '0x38'},
|
flowerSens => {'rdata' => '0x35' ,'wdata' => '0x33' ,'wdataValue' => 'A01F' ,'wdatalisten' => 0 ,'battery' => '0x38' ,'firmware' => '0x38'},
|
||||||
thermoHygroSens => {'wdata' => '0x10' ,'wdataValue' => '0100' ,'battery' => '0x18' ,'firmware' => '0x24' ,'devicename' => '0x3'},
|
thermoHygroSens => {'wdata' => '0x10' ,'wdataValue' => '0100' ,'wdatalisten' => 1 ,'battery' => '0x18' ,'firmware' => '0x24' ,'devicename' => '0x3'},
|
||||||
);
|
);
|
||||||
|
|
||||||
my %CallBatteryAge = ( '8h' => 28800,
|
my %CallBatteryAge = ( '8h' => 28800,
|
||||||
@ -416,7 +416,7 @@ sub XiaomiBTLESens_CreateParamGatttool($@) {
|
|||||||
Log3 $name, 5, "XiaomiBTLESens ($name) - Read XiaomiBTLESens_ExecGatttool_Run $name|$mac|$mod|$handle";
|
Log3 $name, 5, "XiaomiBTLESens ($name) - Read XiaomiBTLESens_ExecGatttool_Run $name|$mac|$mod|$handle";
|
||||||
|
|
||||||
} elsif( $mod eq 'write' ) {
|
} elsif( $mod eq 'write' ) {
|
||||||
$hash->{helper}{RUNNING_PID} = BlockingCall("XiaomiBTLESens_ExecGatttool_Run", $name."|".$mac."|".$mod."|".$handle."|".$value, "XiaomiBTLESens_ExecGatttool_Done", 60, "XiaomiBTLESens_ExecGatttool_Aborted", $hash) unless( exists($hash->{helper}{RUNNING_PID}) );
|
$hash->{helper}{RUNNING_PID} = BlockingCall("XiaomiBTLESens_ExecGatttool_Run", $name."|".$mac."|".$mod."|".$handle."|".$value."|".$XiaomiModels{AttrVal($name,'model','')}{wdatalisten}, "XiaomiBTLESens_ExecGatttool_Done", 60, "XiaomiBTLESens_ExecGatttool_Aborted", $hash) unless( exists($hash->{helper}{RUNNING_PID}) );
|
||||||
|
|
||||||
readingsSingleUpdate($hash,"state","write sensor data",1);
|
readingsSingleUpdate($hash,"state","write sensor data",1);
|
||||||
|
|
||||||
@ -428,7 +428,7 @@ sub XiaomiBTLESens_ExecGatttool_Run($) {
|
|||||||
|
|
||||||
my $string = shift;
|
my $string = shift;
|
||||||
|
|
||||||
my ($name,$mac,$gattCmd,$handle,$value) = split("\\|", $string);
|
my ($name,$mac,$gattCmd,$handle,$value,$listen) = split("\\|", $string);
|
||||||
my $sshHost = AttrVal($name,"sshHost","none");
|
my $sshHost = AttrVal($name,"sshHost","none");
|
||||||
my $gatttool;
|
my $gatttool;
|
||||||
my $json_notification;
|
my $json_notification;
|
||||||
@ -447,6 +447,21 @@ sub XiaomiBTLESens_ExecGatttool_Run($) {
|
|||||||
my $sshHost = AttrVal($name,"sshHost","none");
|
my $sshHost = AttrVal($name,"sshHost","none");
|
||||||
my $hci = AttrVal($name,"hciDevice","hci0");
|
my $hci = AttrVal($name,"hciDevice","hci0");
|
||||||
|
|
||||||
|
$cmd = "ssh $sshHost '" if($sshHost ne 'none');
|
||||||
|
$cmd .= "timeout 5 " if($listen);
|
||||||
|
$cmd .= "gatttool -i $hci -b $mac ";
|
||||||
|
$cmd .= "--char-read -a $handle" if($gattCmd eq 'read');
|
||||||
|
$cmd .= "--char-write-req -a $handle -n $value" if($gattCmd eq 'write');
|
||||||
|
$cmd .= " --listen" if($listen);
|
||||||
|
$cmd .= " 2>&1 /dev/null";
|
||||||
|
$cmd .= "'" if($sshHost ne 'none');
|
||||||
|
|
||||||
|
#$cmd = "ssh $sshHost 'timeout 5 gatttool -i $hci -b $mac --char-write-req -a $handle -n $value --listen 2>&1 /dev/null'" if( $sshHost ne 'none' and AttrVal($name,"model","none") eq 'thermoHygroSens' and $gattCmd eq 'write' and $handle eq '0x10');
|
||||||
|
#$cmd = "timeout 5 gatttool -i $hci -b $mac --char-write-req -a $handle -n $value --listen 2>&1 /dev/null" if( $sshHost eq 'none' and AttrVal($name,"model","none") eq 'thermoHygroSens' and $gattCmd eq 'write' and $handle eq '0x10');
|
||||||
|
|
||||||
|
$cmd = "ssh $sshHost 'gatttool -i $hci -b $mac --char-write-req -a 0x33 -n A01F && gatttool -i $hci -b $mac --char-read -a 0x35 2>&1 /dev/null'" if($sshHost ne 'none' and $gattCmd eq 'write' and AttrVal($name,"model","none") eq 'flowerSens');
|
||||||
|
|
||||||
|
|
||||||
while($wait) {
|
while($wait) {
|
||||||
|
|
||||||
my $grepGatttool;
|
my $grepGatttool;
|
||||||
@ -461,20 +476,6 @@ sub XiaomiBTLESens_ExecGatttool_Run($) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd .= "ssh $sshHost '" if($sshHost ne 'none');
|
|
||||||
$cmd .= "gatttool -i $hci -b $mac ";
|
|
||||||
$cmd .= "--char-read -a $handle" if($gattCmd eq 'read');
|
|
||||||
$cmd .= "--char-write-req -a $handle -n $value" if($gattCmd eq 'write');
|
|
||||||
$cmd .= " 2>&1 /dev/null";
|
|
||||||
$cmd .= "'" if($sshHost ne 'none');
|
|
||||||
|
|
||||||
|
|
||||||
$cmd = "ssh $sshHost 'timeout 5 gatttool -i $hci -b $mac --char-write-req -a $handle -n $value --listen 2>&1 /dev/null'" if( $sshHost ne 'none' and AttrVal($name,"model","none") eq 'thermoHygroSens' and $gattCmd eq 'write' and $handle eq '0x10');
|
|
||||||
$cmd = "timeout 5 gatttool -i $hci -b $mac --char-write-req -a $handle -n $value --listen 2>&1 /dev/null" if( $sshHost eq 'none' and AttrVal($name,"model","none") eq 'thermoHygroSens' and $gattCmd eq 'write' and $handle eq '0x10');
|
|
||||||
|
|
||||||
|
|
||||||
$cmd = "ssh $sshHost 'gatttool -i $hci -b $mac --char-write-req -a 0x33 -n A01F && gatttool -i $hci -b $mac --char-read -a 0x35 2>&1 /dev/null'" if($sshHost ne 'none' and $gattCmd eq 'write' and AttrVal($name,"model","none") eq 'flowerSens');
|
|
||||||
|
|
||||||
$loop = 0;
|
$loop = 0;
|
||||||
do {
|
do {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user