2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 23:06:37 +00:00

Implemented UNIX:SEQPACKET, as the FB Labor removed the TCP socket.

git-svn-id: https://svn.fhem.de/fhem/trunk@2851 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2013-03-04 19:17:17 +00:00
parent f5592d4419
commit 1368ff239e
2 changed files with 41 additions and 4 deletions

View File

@ -328,15 +328,20 @@ FBAHA_Ready($)
<a name="FBAHAdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; FBAHA &lt;host&gt;:&lt;port&gt;</code>
<code>define &lt;name&gt; FBAHA &lt;device&gt;</code>
<br>
<br>
&lt;device&gt; is either a &lt;host&gt;:&lt;port&gt; combination, where
&lt;host&gt; is normally the address of the FRITZ!Box running the AHA server
(fritz.box or localhost), and :&lt;port&gt; is 2002.
(fritz.box or localhost), and &lt;port&gt; 2002, or
UNIX:SEQPACKET:/var/tmp/me_avm_home_external.ctl, the latter only works on
the fritz.box. With FRITZ!OS 5.50 the network port is available, on some
Labor variants only the UNIX socket is available.
<br>
Example:
<ul>
<code>define fb1 FBAHA fritz.box:2002</code><br>
<code>define fb1 FBAHA UNIX:SEQPACKET:/var/tmp/me_avm_home_external.ctl</code><br>
</ul>
</ul>
<br>
@ -395,15 +400,23 @@ FBAHA_Ready($)
<a name="FBAHAdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; FBAHA &lt;host&gt;:&lt;port&gt;</code>
<code>define &lt;name&gt; FBAHA &lt;device&gt;</code>
<br>
<br>
&lt;host&gt; ist normalerweise die Adresse der FRITZ!Box, wo das AHA Server
l&auml;uft (fritz.box oder localhost), &lt;port&gt; ist 2002.
&lt;device&gt; is entweder a eine Kombianation aus &lt;host&gt;:&lt;port&gt;,
wobei &lt;host&gt; die Adresse der FRITZ!Box ist (localhost AUF dem
FRITZ.BOX) und &lt;port&gt; 2002 ist, oder
UNIX:SEQPACKET:/var/tmp/me_avm_home_external.ctl, wobei das nur fuer
FHEM@FRITZ!BOX zur Verfügung steht. Mit FRITZ!OS 5.50 steht auch der
Netzwerkport zur Verfügung, auf manchen Laborvarianten nur das UNIX socket.
<br>
Beispiel:
<ul>
<code>define fb1 FBAHA fritz.box:2002</code><br>
<code>define fb1 FBAHA UNIX:SEQPACKET:/var/tmp/me_avm_home_external.ctl</code><br>
</ul>
</ul>
<br>

View File

@ -108,7 +108,31 @@ DevIo_OpenDev($$$)
Log 3, "Opening $name device $dev"
if(!$reopen);
if($dev =~ m/^(.+):([0-9]+)$/) { # host:port
if($dev =~ m/^UNIX:(SEQPACKET|STREAM):(.*)$/) { # FBAHA
my ($type, $fname) = ($1, $2);
my $conn;
eval {
require IO::Socket::UNIX;
$conn = IO::Socket::UNIX->new(
Type=>($type eq "STREAM" ? SOCK_STREAM:SOCK_SEQPACKET), Peer=>$fname);
};
if($@) {
Log 1, $@;
return $@;
}
if(!$conn) {
Log(3, "Can't connect to $dev: $!") if(!$reopen);
$readyfnlist{"$name.$dev"} = $hash;
$hash->{STATE} = "disconnected";
return "";
}
$hash->{TCPDev} = $conn;
$hash->{FD} = $conn->fileno();
delete($readyfnlist{"$name.$dev"});
$selectlist{"$name.$dev"} = $hash;
} elsif($dev =~ m/^(.+):([0-9]+)$/) { # host:port
# This part is called every time the timeout (5sec) is expired _OR_
# somebody is communicating over another TCP connection. As the connect