Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error reading tags from Daemon tcp://127.0.0.1:12345 Connection refused #2

Closed
mdettki opened this issue Sep 18, 2016 · 20 comments
Closed
Assignees
Labels

Comments

@mdettki
Copy link

mdettki commented Sep 18, 2016

When searching for bluetooth tags the error message is shown: Error reading tags from Daemon tcp://127.0.0.1:12345 Connection refused

When using the link: http://loxberry/plugins/ble_scanner/?mode=normal
the following error message is shown:
{"error":"Error reading tags from Daemon tcp://127.0.0.1:12345","result":"Connection refused"}

In the boot screen I can see that the bluetooth stick is recognized. I´m using a rasperry 2.

@Woersty
Copy link
Owner

Woersty commented Sep 18, 2016

The Plugin has a daemon which ist delivered together with the plugin.
The daemon should be started when the LoxBerry is started.
The deamon itself starts the daemon.php with root rights.
/usr/bin/php -f /opt/loxberry/webfrontend/cgi/plugins/ble_scanner/bin/daemon.php
(This is still a workaround / todo - but I have not yet found a way to get it work w/o root privileges)

What happens of you start this command line by hand?

(Usually you should have no prompt and the Port 12345 should be LISTEN.)
See

root@loxberry:~# netstat -ntpaul|grep 12345
tcp        0      0 127.0.0.1:12345         0.0.0.0:*               LISTEN 

@Woersty
Copy link
Owner

Woersty commented Sep 18, 2016

Ab Version 0.7 ist es möglich, den Dämon mit der folgenden Kommandozeile zu testen.
From version 0.7 is it possible to test the daemon using the following commandline.
(echo "KEEPALIVE";sleep 1)|telnet localhost 12345

@Woersty
Copy link
Owner

Woersty commented Sep 18, 2016

Please send me the output of hciconfigif it is still not working after a reboot.

root@loxberry:~# hciconfig
hci0:   Type: BR/EDR  Bus: USB
        BD Address: 00:xx:xx:xx:xx:xx  ACL MTU: 310:10  SCO MTU: 64:8
        UP RUNNING PSCAN
        RX bytes:624 acl:0 sco:0 events:39 errors:0
        TX bytes:1466 acl:0 sco:0 commands:39 errors:0

@Woersty Woersty self-assigned this Sep 18, 2016
@mdettki
Copy link
Author

mdettki commented Sep 18, 2016

Thanks for the fast response.
I entered the command, but got no response on the command line. Bothe the
Plug-in and the webservice show the error: {"error":"Bluetooth Device
'hci0' seems not 'UP and RUNNING'","result":"State: DOWN"}

I guess the device is not supported. Here is what I tried on the command
line:
loxberry@loxberry:~ $ lsusb Bus 001 Device 004: ID 0400:080a National
Semiconductor Corp. Bluetooth Device Bus 001 Device 003: ID 0424:ec00
Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001
Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10
/100 Adapter / SMSC9512/9514 Hub Bus 001 Device 001: ID 1d6b:0002 Linux
Foundation 2.0 root hub
loxberry@loxberry:~ $ hciconfig hci0 up Can't init device hci0: Operation
not permitted (1)
loxberry@loxberry:~ $ hciconfig -a hci0: Type: BR/EDR Bus: USB BD Address:
00:0C:78:31:E4:E4 ACL MTU: 339:4 SCO MTU: 60:9 DOWN RX bytes:908 acl:0
sco:0 events:33 errors:0 TX bytes:112 acl:0 sco:0 commands:30 errors:0
Features: 0xff 0xff 0x81 0x00 0x18 0x18 0x00 0x00 Packet type: DM1 DM3 DM5
DH1 DH3 DH5 HV1 HV2 HV3 Link policy: Link mode: SLAVE ACCEPT
loxberry@loxberry:~ $ hciconfig dev hci0: Type: BR/EDR Bus: USB BD Address:
00:0C:78:31:E4:E4 ACL MTU: 339:4 SCO MTU: 60:9 DOWN RX bytes:908 acl:0
sco:0 events:33 errors:0 TX bytes:112 acl:0 sco:0 commands:30 errors:0
loxberry@loxberry:~ $ hcitool scan Device is not available: No such device
loxberry@loxberry:~ $ hciconfig hci0 piscan Can't set scan mode on hci0:
Operation not permitted (1)
loxberry@loxberry:~ $ hciconfig hci0 reset Can't down device hci0:
Operation not permitted (1)

Do you have any Idea? May an old libary?

Br
Marcus

2016-09-18 20:59 GMT+02:00 Wörsty notifications@github.com:

The Plugin has a daemon which ist delivered together with the plugin.
The daemon should be started when the LoxBerry is started.
The deamon itself starts the daemon.php with root rights.
/usr/bin/php -f /opt/loxberry/webfrontend/cgi/plugins/ble_scanner/bin/
daemon.php
(This is still a workaround / todo - but I have not yet found a way to get
it work w/o root privileges)

What happens of you start this command line by hand?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVPxAlWhrKCoZuf_LZYw2jZdUkNmX39Qks5qrYoagaJpZM4J_8lR
.

@mdettki
Copy link
Author

mdettki commented Sep 18, 2016

loxberry@loxberry:~ $ (echo "KEEPALIVE";sleep 1)|telnet localhost 12345
-bash: telnet: command not found

2016-09-18 21:19 GMT+02:00 Wörsty notifications@github.com:

Ab Version 0.7 ist es möglich, den Dämon mit der folgenden Kommandozeile
zu testen.
From version 0.7 is it possible to test the daemon using the following
commandline.
(echo "KEEPALIVE";sleep 1)|telnet localhost 12345


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVPxApNIjgxFYv-DbiI91sJR5n2sMwKaks5qrY61gaJpZM4J_8lR
.

@Woersty
Copy link
Owner

Woersty commented Sep 18, 2016

What version of the LoxBerry is used? (because telnet is not installed)
You can add it using apt-get install telnet but it is not mandatory.
Just for troubleshooting...

By the way you must be root to use hciconfig.
Furthermore it's shown that your device is currently DOWN .
Try hciconfig hci0 up - but as root.

I'm tired 😴 - cu tomorrow...

@mdettki
Copy link
Author

mdettki commented Sep 18, 2016

I´m using the newest Version, downloaded today.
hciconfig as root:
root@loxberry:~# hciconfig
hci0: Type: BR/EDR Bus: USB
BD Address: 00:0C:78:31:E4:E4 ACL MTU: 339:4 SCO MTU: 60:9
DOWN
RX bytes:908 acl:0 sco:0 events:33 errors:0
TX bytes:112 acl:0 sco:0 commands:30 errors:0

root@loxberry:~# hciconfig hci0 up
Can't init device hci0: Invalid argument (22)

2016-09-18 21:32 GMT+02:00 Wörsty notifications@github.com:

What version of the LoxBerry is used?
By the way you must be root to use hciconfig.
Furthermore it's shown that your device is currently DOWN .
Try hciconfig hci0 up - but as root.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVPxAoc0rswpe2Dcg3ZoYp-4DYBCNd2mks5qrZHVgaJpZM4J_8lR
.

@Woersty
Copy link
Owner

Woersty commented Sep 19, 2016

Mmmh. Seems incompatible. Can not yet tell you how to fix this.
What does lsusb -vvvshows?

@mdettki
Copy link
Author

mdettki commented Sep 22, 2016

With the LogiLink BT0015 adapter it worked, but the service needs to be started manually after each boot. Nevertheless great job!

@mdettki
Copy link
Author

mdettki commented Sep 23, 2016

nohup /usr/bin/php -f /opt/loxberry/webfrontend/cgi/plugins/ble_scanner/bin/daemon.php &

Starts the script in background so it isn´t killed when the ssh session is closed!

@Woersty
Copy link
Owner

Woersty commented Sep 23, 2016

Usually the script is automatically started by the loxberry initscript.
Had you pluged the dongle before rebooting the LoxBerry?

@mdettki
Copy link
Author

mdettki commented Sep 23, 2016

Yes, it was plugged in. Should I try to reinstall the plug-in?
Can you please give me a hint how to setup the tags and the trigger in
Loxone?

This is how I setup the Tag as virtual input

[image: Inline-Bild 1]

The scan is a virtual output triggered by a switch

[image: Inline-Bild 2]

[image: Inline-Bild 3]

2016-09-23 18:37 GMT+02:00 Wörsty notifications@github.com:

Usually the script is automatically started by the loxberry initscript.
Had you pluged the dongle before rebooting the LoxBerry?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVPxAtExeW_gKyumNdhIVOOX6pDyg-YDks5qtABZgaJpZM4J_8lR
.

@Woersty
Copy link
Owner

Woersty commented Sep 23, 2016

You are right, I had not yet time to describe the settings in the Loxone Config.
I try to complete the Wiki asap.

You have to create a Virtual Input with BLE and the MAC.
Select digital input.
It has value 1 or 2 depending on the Tag signal.

vi

To trigger the sending, create an Virtual Output
Address http://your-loxberry
Check "Disconnect after close"
Create Virtual Output Command
Command for "on" = /plugins/cam-connect/

I trigger this Virtual Output using my motion detectors and the door contact.

@Woersty
Copy link
Owner

Woersty commented Sep 23, 2016

Yes, it was plugged in. Should I try to reinstall the plug-in?

Not sure. Give it a try.

@mdettki
Copy link
Author

mdettki commented Sep 23, 2016

Ok. The reinstallation fixed the issue with the automatic start. I´m on
version 0.7 now.

But my TAGs are still not updated in Loxone. I guess the command should
be /plugins/ble_scanner/?mode=scan
and not /plugins/cam-connect/
In the logfile I can see that the Virtual Output call is received by
Loxberry:
2016-09-24 00:36:28 [OK] Scan: 2 Tag(s) found [direct]

Most likely the problem is caused by the two if-statements that are both
triggered by mode==scan (see line 107 and 238)
if ($_REQUEST["mode"] == "scan")

Somehow only the last if-statement is executed, which just writes to the
logfile and doesn´t trigger the update of the Loxone variables.

Where do I find the index.php in the filesystem?

2016-09-23 23:54 GMT+02:00 Wörsty notifications@github.com:

Yes, it was plugged in. Should I try to reinstall the plug-in?

Not sure. You could give it a try.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVPxAjQH0417E7oVYEDqYRJ5TSMiLuMBks5qtEqTgaJpZM4J_8lR
.

@Woersty
Copy link
Owner

Woersty commented Sep 24, 2016

LoL sure ble_scanner of course.
The command is without a Mode.
Just the path.
You can try it using a web browser.
I will Check later and keep you posted.
I have changed many things in the code.
Maybe I have caused a regression.

@mdettki
Copy link
Author

mdettki commented Sep 24, 2016

Ok, for debug reasons I added an output of the $LoxURL string (line 218) to
the logging.
Even when the webpage shows that a tag is present the string is NULL for
the TAG:

192.168.XXX.XXX:80/dev/sps/io/BLE_01_AC_78_E6_XX_XX/0

Probably the error is in line 166
if (isset($tag_data_array[0])) { $tags_known["TAG$current_tag"]['found'] =
intval(in_array($tag_data_array[0],$tags_found)); } else { $tags_known["TAG
$current_tag"]['found'] = 0; }

2016-09-24 9:41 GMT+02:00 Wörsty notifications@github.com:

LoL sure ble_scanner of course.
The command is without a Mode.
Just the path.
You can try it using a web browser.
I will Check later and keep you posted.
I have changed many things in the code.
Maybe I have caused a regression.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVPxAsfr7Ul_aTty1xfgzYKV5f-6xRghks5qtNQ8gaJpZM4J_8lR
.

@Woersty
Copy link
Owner

Woersty commented Sep 24, 2016

Have found the problem. Will release v0.8 with a fix soon.

@Woersty
Copy link
Owner

Woersty commented Sep 24, 2016

Solved with v0.8 6347e69
Recursive search needed since use of RSSI level...

@mdettki
Copy link
Author

mdettki commented Sep 24, 2016

Thanks a lot, now it works! Great job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants