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

AndroidDB: Bugfix

git-svn-id: https://svn.fhem.de/fhem/trunk@24428 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
zap 2021-05-12 18:06:45 +00:00
parent d9a5def6f0
commit ecf0873682
2 changed files with 14 additions and 8 deletions

View File

@ -4,7 +4,7 @@
# #
# 89_AndroidDB # 89_AndroidDB
# #
# Version 0.1 # Version 0.2
# #
# FHEM Integration for Android Devices # FHEM Integration for Android Devices
# #
@ -44,8 +44,6 @@ package AndroidDB;
use strict; use strict;
use warnings; use warnings;
use Data::Dumper;
use SetExtensions; use SetExtensions;
use GPUtils qw(:all); use GPUtils qw(:all);
@ -178,7 +176,7 @@ sub Get ($@)
$opt = lc($opt); $opt = lc($opt);
if ($opt eq 'presets') { if ($opt eq 'presets') {
return Dumper (\%PRESET); return "Command not implemented";
} }
else { else {
return "Unknown argument $opt, choose one of $options"; return "Unknown argument $opt, choose one of $options";

View File

@ -4,7 +4,7 @@
# #
# 89_AndroidDBHost # 89_AndroidDBHost
# #
# Version 0.1 # Version 0.2
# #
# FHEM Integration for Android Debug Bridge # FHEM Integration for Android Debug Bridge
# #
@ -199,7 +199,7 @@ sub Set ($@)
my $opt = shift @$a // return 'No set command specified'; my $opt = shift @$a // return 'No set command specified';
# Preprare list of available commands # Preprare list of available commands
my $options = 'start:noArg stop:noArg'; my $options = 'command start:noArg stop:noArg';
$opt = lc($opt); $opt = lc($opt);
@ -220,6 +220,11 @@ sub Set ($@)
return "ADB server still running. Please try again."; return "ADB server still running. Please try again.";
} }
} }
elsif ($opt eq 'command') {
my $command = shift @$a // return "Usage: set $name $opt Command [Args]";
my ($rc, $result, $error) = Execute ($hash, $command, '.*', @$a);
return $result.$error;
}
else { else {
return "Unknown argument $opt, choose one of $options"; return "Unknown argument $opt, choose one of $options";
} }
@ -324,8 +329,8 @@ sub IsConnected ($)
my ($rc, $result, $error) = Execute ($ioHash, 'devices', 'list'); my ($rc, $result, $error) = Execute ($ioHash, 'devices', 'list');
return -1 if ($rc == 0); return -1 if ($rc == 0);
my @devices = $result =~ /device$/g; my @devices = $result =~ /([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:[0-9]+)/g;
if (scalar(@devices) == 1 && $result =~ /$clHash->{ADBDevice}/) { if (scalar(@devices) == 1 && $devices[0] eq $clHash->{ADBDevice}) {
return 1; return 1;
} }
elsif (scalar(@devices) > 1) { elsif (scalar(@devices) > 1) {
@ -466,6 +471,9 @@ sub TCPConnect ($$$)
<a name="AndroidDBHostset"></a> <a name="AndroidDBHostset"></a>
<b>Set</b><br/><br/> <b>Set</b><br/><br/>
<ul> <ul>
<li><b>set &lt;name&gt; command &lt;Command&gt; [&lt;Args&gt;]</b><br/>
Execute ADB command.
</li><br/>
<li><b>set &lt;name&gt; start</b><br/> <li><b>set &lt;name&gt; start</b><br/>
Start ADB server. Start ADB server.
</li><br/> </li><br/>