3rd Party Bluetooth Binding. Beta testers needed

Tags: #<Tag:0x00007fd317761dc0> #<Tag:0x00007fd317761c30>

(Thomas Bail) #544

Just want to inform about my promised tutorial on connecting remote Bluegiga Adapters. Its now online.

(Vlad Kolotov) #545

Hi @orzechszek, NUT mini is OK to get nearly 100% accuracy with BlueGiga adapter even if you set the “online timeout” to 15-25s.

TinyB transport is very unstable. The online timeout should be set to around 200s in order to make it working properly, but this will introduce 200s of latency to detect when your devices go offline (out of range). This is due to a large number of middle tiers between the binding and actual adapter, e.g. Adapter -> USB -> Bluez -> DBus -> TinyB -> OH

Good news!

@xrucka has implemented a new dbus transport for generic USB adapters that does not use TinyB at all and talk to adapters directly via DBus interface! Tons of kudos to him! I was dreaming to get rid of TinyB… We will try to release the dbus binding asap.

Lukáš has also contributed quite a bit into the Gatt parser library and TinyB as well.

He is also currently working on adding support for a bluetooth thermostat: here.

(orzech) #546

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

(Oleg) #547

After reboot openHAB

Need reinstall Bluetooth Binding BlueGiga Transport and Bluetooth Binding

(mcqwerty) #548

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] 

(Chris) #549

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).

(Vlad Kolotov) #550

Hi @giblet37, please see these tickets:

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

(Curlyel) #551

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:


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

My adapter regex is:

... 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?

Zigbee binding
(Vlad Kolotov) #552

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.

(Curlyel) #553

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.


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

(Chris Jackson) #554

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.

(Markus S.) #555

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.

(Vlad Kolotov) #556

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.

(Vlad Kolotov) #557

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.

(Markus S.) #558

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


(Vlad Kolotov) #559

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.

(Markus S.) #560

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.

(Vlad Kolotov) #561

@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.

(Vlad Kolotov) #562

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.

(Markus S.) #563

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.