I disconnected the messages to the Vera/OpenLuup and it made no difference. This is the line that causes the pause:
bt_sock.connect(addr)
but we might have guessed that since that is the real work. I searched for bluetooth issues with the Raspberry Pi but most people are having installation problems, not this sort of issue. And I think most people connect once (as in an audio device or keyboard) so a pause probably doesn’t bother them. They’re happy enough that it connected. When I get a moment I’ll post a question in one of the Pi forums.
Can you give me a simple example of how to observe the pause. For example, if I open a terminal session in Jessie’s GUI and run top -d 1, does the time in upper right freeze and for how long. Keep in mind I have Jessie with ssh and VNC and the Vera scanner. That is all. I’m looking to duplicate this so I can help debug. Right now I can’t see it.
Also, want is your BT device? Android? Apple? Does this happen when device is present? Not present? Both?
Same versions that you mention. I’m using several Android phones. I’ll get answers to your further questions although it make take a couple of days. I have some other checks to try: what happens at the console? I.e., is this somehow affecting the network only, or is the processor/OS truly stuck? Also, try a different power source; perhaps there is a bit of surge when this turns on. I doubt this is the case, but want to rule it out.
I’m also curious to know if I can get the Pi connected to a standard bluetooth speaker and see if it functions properly - make sure that the bluetooth hardware actually functions although I know that it does see the phones, so I suspect it can work. Good to double check though. And I want to shut down as much else as I can on the Pi to see if there is any obscure interaction. If none of this shows anything, then I believe there are some other bluetooth python libraries to try as with Python3, so I could go there. Lots to try, just need some time…
Okay, some progress on this. Turns out the console is fine when this is running - no pauses. By chance I noticed that I could not get to any web page with the scanner running while I’m on the console. This is all with the Wifi enabled. So I disabled the Wifi and hooked up a LAN cable. It works! No problem at all with the scanner, no pauses. So somehow the bluetooth is interfering with the Wifi. I have no idea why, but I’ll leave that for another day. For the moment it means that I must have the RPI near a LAN port.
After a bit of research I discovered that there is frequently interference between bluetooth and the 2.4G wireless band. So a switch to the 5G band wireless N might solve it.
@jswim788:
Good work!!! That explains why I don’t see the same problem. Pretty sure you will see 5GHz work fine.
Perhaps we should put a note in the README about troubleshooting.
@jswim788 and @jsingle:
Now, if you are on UI7 (I know @jsingle is), are you able to try to add the static text in the .js file? I’m looking forward to fixing that and adding couple of features to the Vera files, including handling restart of Lua a bit better.
Yes, I would recommend adding a note in the README that mentions possible incompatibility with 2.4G Wifi and Bluetooth. What bugs me is that the phone itself doesn’t have this problem; it’s on the other end of this interface using both Bluetooth and Wifi. So it seems like this is a limitation of the RPI3 and not an inherent limitation of the standards. On the other hand it’s probably time for me to upgrade my router anyway…
No, I’m not using UI7, so can’t provide feedback on it. Sorry.
[quote=“joer., post:87, topic:192938”]I’ve been using the original for a few months now. I’d say it’s about 80% accurate. Occasionally needs a pi reboot.
I look forward to your improvements. As soon as the on git.[/quote]
Updated mine tonight. Will let you know if I experience anything unusual. Thanks for the hard work.
[quote=“GeekGoneOld, post:109, topic:192938”]Was the update reasonably painless?. if so, let others know. If not, disregard the question!
I really hope you’re on UI7 and have the capability of editing the .js so I can issue the minor update. Let me know.[/quote]
Hey GeekGoneOld… Yes the update wasnt bad at all. Took less then 30 minutes and thats a very non linux guy working in the Pi. I am on UI5 so no UI7 testing for me, sorry!
edit: I have noticed RSSI field doesnt populate on my Android device very quickly. I will take a note on that soon. I dont/wont use it but for others.
Great about the install. I had hoped the instructions were good for others, especially non-Linux people!
Keep in mind the following:
When the device transitions from not present to present or from present to not present, the RSSI and scanner should update at the same time as present.
When present, a beacon will update the RSSI and scanner at the same time, but no faster than BEACON_LISTEN_PERIOD (default 10s)
When present, a Bluetooth will update the RSSI and scanner at the same time, but no faster than POLLPERIOD_LIVE (default 60s)
I say “no faster than” for two reasons. First, a scan could be delayed by other activity (e.g. a beacon scan could be delayed by a Bluetooth scan in progress). Second, a scan could time out and would have to wait until the next successful scan to cause an update.
No matter what, the RSSI, scanner and present should all be written at the same time. Please check your android and see if it fits this behaviour. If not, we will have to investigate.
Guess we will have to wait for jsingle for UI7! @jsingle: if you are adept at js, go ahead yourself and try to edit the UI7 .js! Otherwise, attached is my best guess.
Insert the following immediately above line 31 (api.setCpanelContent(html)
html = html +
'<p><p>Address is MAC for bluetooth<br>' +
'MAC or <UUID>,<major>,<minor> for iBeacon<br>' +
'(note: UUID is without dashes)' +
'<p><p>To set up scanners, <a href="https://github.com/daemondazz/vera-presence-scanner.git" target="_blank">click here</a>';
back to the Bluetooth / Wifi interference: I upgraded my router (it was about time anyway), but quickly discovered that the Raspberry Pi 3 only runs in the 2.4GHz band, not the 5GHz. So I’m stuck with a hardwired connection for now. I suppose I could add yet another USB dongle to it for 5G Wifi.
@GeekGoneOld: are you using a USB Wifi on your Raspberry Pi? Or does your Pi support 5G?
I use a Pi 2, so I can’t help you on that one. I wired my whole house when I renovated 5 years ago. I still believe in good old copper!
Pretty soon I might upgrade to a shared Pi 3. I might be using one as a Plex client and to add this simple function (vera scanner) to it would be trivial. That’s why I was grateful for your experience with the cpu usage.
Now if I can only get @jsingle or someone else to test out UI7, this project get to release 1.0!!!
@jswim788: how well does the UI work with the AltUI? Do you recommend the AltUI?
Be interested to hear the results. It would be nice to confirm it works on other platforms.
The implementation on UI5 and UI7 are intended to be the same but I have no way to test UI7. I have proposed minor changes to the “Settings” tab but have no way to test. Please take the attached .txt file, change extension to .js and upload to Vera then reload and refresh the browser (should be sufficient to close the browser then reopen). Then check the Settings tab to see if it displays similar to UI5.
Also, if you could comment on the following, I would be very appreciative:
Do the two icons show properly (present shows like absent without the red line)
Do the tabbed pages of the device show properly
Are you able to set up notifications for change in [armed and] present status
Including the upload, should take less than 5 minutes to check, but I will be very grateful for your help!
@jsingle, @konradwalsh: Has either of you tried the patch from the above post on UI7?
@konradwalsh: Any further input on the quirks that you experienced?
All others: any feedback?
I’ve been running it for weeks now using one beacon and one Bluetooth (iPhone5) and one scanner directed to the front porch. RPi has been rock solid (no failure or reboots). I’ve been using the notifications to identify how often the signal drops and for how long. Now I’m very confident I can use a PLEG to detect and confirm my arrival (I’ve programmed in a few failsafes!!!) then unlock the front door and relock after 5 minutes. I’m so darned lazy, I hate having to use my hands (to get keys or enter a code).
Looks fine in AltUI - I’ve attached a couple of screenshots. I enjoy AltUI and amg0 is creating many enhancements. The workflows are good if you are used to thinking in state diagrams. And they are animated - you can see the state that is active and see the timers counting down. I can do what I need in UI5, but AltUI definitely makes life easier. The area to test lua code is very handy.
in run_scanner.py, BEACON_LISTEN_PERIOD, BEACON_LISTEN_TIMEOUT and BEACON_LISTEN_QTY only apply to beacons. PERIOD is the minimum idle time (technically, not actually the period) between checking for beacons. Note that if the Pi is busy scanning for bluetooth devices when beacon time comes it would have to wait until that is complete before scanning for beacons.
When it is time to listen, the BT device listens for up to TIMEOUT time for a beacon broadcast. If it hears one, it (yes, the BT device, not the program) stores it and listens for a second one for up to TIMEOUT time. When it hears the second one, it stores it and listens for a third one for up to TIMEOUT time etc. etc. until either a timeout occurs or QTY is reached. At that point it sends all stored beacon broadcasts back to run_scanner.py. I’m not sure (never sniffed it) but I don’t think the Pi BT device actually transmits!!
A few comments/questions about the Pi:
Are you only using beacons? Even though this is single tasking and there should be no balancing act required, if it is beacon only I don’t even think it transmits!
Are you sure you have the latest files off github AND the latest python-bluez?
What do you mean by “spiking”? CPU? Note that CPU spiking was a bug that is fixed but even that would not cause reboots (it consumed all IDLE time)
Is the Pi running anything else? If not, did you do a clean install following the readme?
Are you using a good 2.5A (not 1A, not 2A) power supply for the Pi?
As for the firewall, if the BT service dies, I’d have to say you’re onto something assuming incompatible BT device.
P.S. Any comments about the UI (re my post on Nov 24)? Still hoping to update the files for UI7.