3rd Party Bluetooth Binding. Beta testers needed

Hi @vkolotov,
Thanks for info! Unfortunately I have TinyB adapter… so I’m waiting for your BT binding upgrades :slight_smile:

Hi.
After reboot openHAB


Need reinstall Bluetooth Binding BlueGiga Transport and Bluetooth Binding

I prefer to define my things using .things files but I can’t get my Bluegiga adaptor to show in PaperUI when I define it in a .things file. (It appears fine when adding via PaperUI directly).

Does anyone have an example of defining a blootooth:adapter in a .things file?

I tried the below and a few variations on that theme:

Thing bluetooth:adapter:886B0F6xxxxx "Bluegiga01" [signalPropagationExponent=4.0] 

I just tried this for the first time, and it… worked, but I think something must have gone wrong since it didn’t seem to work reasonably. Hopefully I just did something silly and someone can steer me in the right direction. I’m just using a standard Pi 3B+ with BlueZ 5.43 etc.

Upon adding everything, it very rapidly discovered over 285 things. The older/other BT binding only finds around 20 or so if I run it, and it takes considerably longer to find most of those. After a while, the inbox cleaned itself up a bit, but remained between 25-65 items for as long as I left discovery enabled. I only know what about 5 of the devices actually are, but I don’t live in a sea of bluetooth-enabled everything so I’m not sure the hundreds of items is valid :wink:

I added my phone (Android Pixel, older model, not the 2), but it seems like the binding only reports the phone as being online as long as the phone remains in active discovery mode. Once I closed that, but left BT enabled, it went offline and never seemed to be found again. There was no option to setup pairing etc that I could find.

So I guess I am confused about how this is intended to be used. I don’t want hundreds of spam devices being processed constantly, but I can’t disable discovery if I want to use this for anything. But then I also can’t seem to use it reliably, at least for my phone, unless I keep it in permanent discovery mode, which isn’t possible (or wanted).

Hi @giblet37, please see these tickets:

These are all planned, but I can’t guarantee when it is going to be done.

Hi @vkolotov,
I’m currently playing with a couple of Bluegiga dongles connected to your binding:

216 │ Active   │  80 │ 1.2.2                  │ org.sputnikdev:org.eclipse.smarthome.binding.bluetooth.transport.bluegiga
220 │ Active   │  80 │ 1.1.5                  │ org.sputnikdev:org.eclipse.smarthome.binding.bluetooth

I’ve just discovered some odd behaviour at startup which seems to block other serial ports (a Zigbee dongle in my case). I’ve already asked the maintainer of the Zigbee binding:

But after a some more tests it looks like the bluetooth binding somehow catches/open other serial port even if not matching the adapter regex. I currently have symlinked the Bluegiga’s to something unique, so that some unintended match should have been avoided:

/etc/udev/rules.d//50-usb-serial.rules:

SUBSYSTEM=="tty",ATTRS{idVendor}=="2458",ATTRS{idProduct}=="0001", SYMLINK+="bluegiga%k", GROUP="dialout", MODE="0666"

My adapter regex is:

(/dev/bluegigattyACM[1,2])
... also tried (/dev/bluegigattyACM*) and (/dev/bluegigattyACM[1-2]) as well as some other ;-) 

If I start the Bluetooth binding before the Zigbee binding, then the Zigbee binding can not open it’s serial dongle. Therefore I need to

216 │ Active   │  80 │ 1.2.2                  │ org.sputnikdev:org.eclipse.smarthome.binding.bluetooth.transport.bluegiga
220 │ Active   │  80 │ 1.1.5                  │ org.sputnikdev:org.eclipse.smarthome.binding.bluetooth
openhab> bundle:stop 220

… then restart openHAB and after the Zigbee dongle has been opened by the other binding:

openhab> bundle:start 220

… to get both bindings working at the same time with their serial adaptors.

Is there something wrong with my Bluegiga-regex? Are you checking other serial ports than mentioned in the regex somehow?

Hi @curlyel, the binding (bluegiga transport) does not attempt to open/lock any other unmatched ports. Here is that code that filters them out.

nrjavaserial library is used to do port discovery, I’m guessing that the zigbee binding is using it as well… Maybe they somehow get confused (what could possibly go wrong?!).

What happens if you start zigbee binding first, does bt binding find any serial ports?

Your regex look ok. I’ve got several unittests covering port matching, so it must be something with that nrjavaserial library… I’ll have a look soon.

Hi Vlad, thanks for looking into it.

Yes, this works as it should. When I start the Zigbee binding, let it open it’s serial port and initialize the Zigbee coordinator dongle and the start the Bluetooth binding both are working and can talk to their serial ports.

EDIT:
@chris:

Can you confirm it is the case? If so, do you have some thoughts what may go wrong with the serial port discovery?

What does this mean? It’s not my understanding of the port discovery. I thought that the discovery only looked at the system info to check the PIDs - it shouldn’t involve the serial port library (or so I thought). I’m not overly familiar with the discovery though, so I could be wrong.

Hi Vlad.
After installing 2 new BlueGiga Adapters i get this Warning every 10 Minutes:

2018-07-11 16:36:16.369 [WARN ] [tooth.bluegiga.BlueGigaSerialHandler] - Ignoring BlueGigaPassKeyResponse response which has not been requested.
2018-07-11 16:36:26.265 [WARN ] [r.transport.bluegiga.BluegigaHandler] - Timeout has happened while sending a transaction, retry one more time: BlueGigaHelloCommand

and this

2018-07-11 16:44:26.714 [WARN ] [er.transport.bluegiga.BluegigaDevice] - Unexpected exception occurred while handling bluegiga event: bluegiga://88:6B:0F:A2:BA:8A/3F:BF:1F:27:6D:2B : BlueGigaScanResponseEvent [rssi=-71, packetType=NON_CONNECTABLE_ADVERTISEMENT, sender=3F:BF:1F:27:6D:2B, addressType=GAP_ADDRESS_TYPE_RANDOM, bond=255, data=FF 06 00 01 09 20 02 54 E3 32 F9 DF FC EA E0 A8 FF 0E 1C 00 CE B1 E5 F9 ED 3D 71 50 51 7C] : 255

sender is a not installed device. Only seen it in Inbox.

Is there a problem or it’s okay.
Greetings,
Markus

Hi @chris, there is nothing special in the port discovery. The binding calls NRSerialPort.getAvailableSerialPorts() (which returns a set of available port names, e.g. a set of strings) and then filters by using a regex that is user defined (in the binding config). That’s it. The binding does not attempt to open any unmatched ports. So not sure what’s happening there.

Hi @Master79,

thanks for reporting this. Those errors can be ignored. The blugiga protocol does not have any error correction so we have to look after some anomalies and try to recover from serial communication errors.

BTW, that bluegiga library we use in the binding (bluegiga transport) here is written by @chris, all kudos to him! Excellent work.

Hi Vlad.
I have changed my adapters to extern bluegiga adapters. What i have seen, is that the refresh rate of the RSSI is much faster. So every 5 seconds i get a new value. The CPU rate is higher too. :slight_smile: 1-2%.
But the value jumps. For example from, -82 to -74 without move of the device. How can i set the devices or adapter that the value is not jumping so much?

2018-07-16 18:05:01.194 [vent.ItemStateChangedEvent] - GearS3_RSSI changed from -73 to -80
2018-07-16 18:05:06.214 [vent.ItemStateChangedEvent] - GearS3_RSSI changed from -80 to -82
2018-07-16 18:05:11.231 [vent.ItemStateChangedEvent] - GearS3_RSSI changed from -82 to -74

Greetings,
Markus

Hi @Master79, thanks for reporting. It is simple as selecting a stronger filtering values here:

That filtering parameter sets/enables some constants for Kalman filter. This should reduce RSSI noise quite drastically. However, as all filters do, this will introduce some latency which is actually is quite neglectable for our applications.
Let me know how it works for you.

BTW, if you CPU is high, just remove RSSI channel (or any other channels that change too often). This will not affect neither presence detection nor indoor positioning.

Hi Vlad.
I just use the Moderate mode. Can i use the Slow mode or is it to slow?
I don’t understand how i should use the indoor presence without the RSSI channel. This value, I use to recognize the room, where the person is by signal strange. But if the signal jumps so much it could be the next room or floor.
Greetings,
Markus

@Master79, just try it.

It is not necessary to do indoor positioning yourself. The binding supports it. Just set location of each adapter, then add the “Location” channel for your devices. The binding will do all calculation for you and change the “Location” channel when your device moves from one room to another. I’ve put so much of my effort to make it working, it seems to me it is not very obvious that the binding supports it.

It thought it is obvious… Ok, I’ll try to improve documentation.

Just so you know, there are some other settings for indoor positioning that can be used to improve accuracy:

  1. “Signal propagation exponent” for adapters (read description how to use that)
  2. “Received signal strength indication (RSSI) filter” and “Measured transmit power (Tx Power)”

Just because this is wireless technology, all adapters and devices have different radio characteristics:

  1. Some adapters report stronger RSSI signal than others
  2. Some devices transmit weaker signal than others.
  3. Some walls in your house has weaker/stronger radio signal penetration characteristics etc

You don’t have to play with these settings. You may use them if the indoor positioning is not accurate enough. The default values should work fine.

I’ve tried to implement some algorithms/settings that could mitigate differences between radio characteristics. Please try that and let me know how it goes.

Sorry Vlad,
but i don’t understand what i have to do with the Tx Power.
The channel shows 0dBm. So i have to set it to -60?
And the location channel is no option because the adapters are on other slave servers and send the value of RSSI over mqtt.
Greetings and sorry for my unkown.

No worries. It is my fault not to make the documentation up to standard.

For the initial set up, you probably should not touch the settings I mentioned above. Just set locations for your adapters in OH and add “Location” channel for your devices.

I suggest you to play with the calibration parameters once everything is working but you are not satisfied with accuracy.

Not sure I understand this:

And the location channel is no option because the adapters are on other slave servers and send the value of RSSI over mqtt.

Have you added adapters in the binding? If so, go to their settings and set location parameter accordingly to where they located. As per this:

I have one adapter on my master openhab server per usb. The second adapter is on another slave server with openhab per USB. Can’t find both adapters on the same server. So i send the values from the slave to the master server and compares it. If master adapter is online and RSSI under -76 and slave adapter is online i am in the living room. :slight_smile: