mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
lepresenced: V0.92: Restart hcitool on HCI Command (forum #75559).
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@21704 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
7831b8fc26
commit
121c17086e
BIN
contrib/PRESENCE/deb/lepresenced-0.92-1.deb
Normal file
BIN
contrib/PRESENCE/deb/lepresenced-0.92-1.deb
Normal file
Binary file not shown.
@ -58,7 +58,7 @@ use constant DEFAULT_RSSI_THRESHOLD => 10;
|
|||||||
use constant RSSI_WINDOW => 10;
|
use constant RSSI_WINDOW => 10;
|
||||||
|
|
||||||
use constant ME => 'lepresenced';
|
use constant ME => 'lepresenced';
|
||||||
use constant VERSION => '0.9';
|
use constant VERSION => '0.92';
|
||||||
|
|
||||||
use constant PIDFILE => '/var/run/' . ME . '.pid';
|
use constant PIDFILE => '/var/run/' . ME . '.pid';
|
||||||
|
|
||||||
@ -75,6 +75,7 @@ my @clients = ();
|
|||||||
my ($log_level, $log_target);
|
my ($log_level, $log_target);
|
||||||
my $debug;
|
my $debug;
|
||||||
my ($beacons_hcitool, $beacons_hcidump) : shared = (0, 0);
|
my ($beacons_hcitool, $beacons_hcidump) : shared = (0, 0);
|
||||||
|
my $restart_hcitool :shared;
|
||||||
|
|
||||||
sub syslogw {
|
sub syslogw {
|
||||||
return if (scalar(@_) < 2);
|
return if (scalar(@_) < 2);
|
||||||
@ -207,9 +208,15 @@ sub update_device($$$) {
|
|||||||
sub bluetooth_scan_thread($$) {
|
sub bluetooth_scan_thread($$) {
|
||||||
my ($device, $legacy_mode) = @_;
|
my ($device, $legacy_mode) = @_;
|
||||||
my $hcitool;
|
my $hcitool;
|
||||||
|
$restart_hcitool = 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
($beacons_hcitool, $beacons_hcidump) = (0, 0);
|
||||||
my $pid = open($hcitool, "-|", "stdbuf -oL hcitool -i " . $device . " lescan --duplicates 2>&1") || die('Unable to start scanning. Please make sure hcitool and stdbuf are installed!');
|
my $pid = open($hcitool, "-|", "stdbuf -oL hcitool -i " . $device . " lescan --duplicates 2>&1") || die('Unable to start scanning. Please make sure hcitool and stdbuf are installed!');
|
||||||
while (<$hcitool>) {
|
while (<$hcitool>) {
|
||||||
|
if ($restart_hcitool) {
|
||||||
|
$restart_hcitool = 0;
|
||||||
|
last();
|
||||||
|
}
|
||||||
chomp($_);
|
chomp($_);
|
||||||
if ($_ eq 'LE Scan ...') {
|
if ($_ eq 'LE Scan ...') {
|
||||||
syslogw(LOG_INFO, "Received '%s'.", $_);
|
syslogw(LOG_INFO, "Received '%s'.", $_);
|
||||||
@ -249,7 +256,12 @@ sub bluetooth_dump_thread($) {
|
|||||||
|
|
||||||
while (<$hcidump>) {
|
while (<$hcidump>) {
|
||||||
chomp($_);
|
chomp($_);
|
||||||
if ($_ =~ m/^>/) {
|
if ($_ =~ m/^< HCI Command: / && $beacons_hcitool > 0) { # Ignore initial settings, i. e. before first beacon
|
||||||
|
# https://forum.fhem.de/index.php/topic,75559.msg1007719.html#msg1007719
|
||||||
|
syslogw(LOG_WARNING, "Received '%s', telling hcidump to restart...", $_);
|
||||||
|
$state = HCIDUMP_STATE_NONE;
|
||||||
|
$restart_hcitool = 1;
|
||||||
|
} elsif ($_ =~ m/^>/) {
|
||||||
if ($current_mac) {
|
if ($current_mac) {
|
||||||
#printf("DEBUG: mac: %s, name: '%s', rssi: %s\n", $current_mac, $current_name, $current_rssi);
|
#printf("DEBUG: mac: %s, name: '%s', rssi: %s\n", $current_mac, $current_name, $current_rssi);
|
||||||
|
|
||||||
@ -449,7 +461,6 @@ for(;;) {
|
|||||||
syslogw(LOG_INFO, "Connection from %s:%s. Connected clients: %i.", $client_socket->peerhost(), $client_socket->peerport(), $select->count()-1);
|
syslogw(LOG_INFO, "Connection from %s:%s. Connected clients: %i.", $client_socket->peerhost(), $client_socket->peerport(), $select->count()-1);
|
||||||
} else {
|
} else {
|
||||||
sysread ($current_client, my $buf, INET_RECV_BUFFER);
|
sysread ($current_client, my $buf, INET_RECV_BUFFER);
|
||||||
|
|
||||||
my $disconnect;
|
my $disconnect;
|
||||||
if ($buf) {
|
if ($buf) {
|
||||||
chomp($buf);
|
chomp($buf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user