I've got a small BLE device (an iTag) which I'm able to communicate with
using a GATT class I found here:
It works fine, but for one thing: Whenever I get outof range (which is
rather easy to do) I have to re-run the python program to reconnect.
Question: Is there a setting somewhere that causes my my RPi's BLE to
automatically reconnect to the device when it comes in range again ?
I can either wrap a never-ending loop around the whole program and perhaps
add some code that will go into discovery mode until the devices
advertisdement is receieved again, but as the need for reconnection isn't
something that seldom happens (especially not with short-ranged BLE devices)
I could imagine its already build into the BLE stack. But if so, where/how
to enable it ...
It is SDK and it shows you the way to write the code you need in following
Discovering nearby Bluetooth Low Energy devices
Connecting to a Bluetooth Low Energy device and ...
So you better write a small python program that fits your needs
if you were using section "Running the GATT control script", it clearly
So I assume this "GATT control script" can be used as a starting point
Also have a look at the dbus API
I've been googeling for a couple of hours to find stuff related to the RPi's
BLE, but have not found anything like that. Could you provide a link to
that SDK ?
Nothing like that. I took that Github code that I mentioned and just
altered it a bit, using the included example scripts as well as the main
gatt_linux one as a lead. Going thru those scripts I did not see any
auto-reconnection possibility. Hence my question.
The link you pasted is a link to SDK
getsenic/gatt-python: Bluetooth GATT SDK for Python - GitHub
I assume (because I have no time or need at the moment to look into the
detail) the SDK offers implementation of the GATT API.
In the examples you have the code for discovery and also the code to connect
and read values etc. It looks like you have to put the puzzle in the right
From my experience with dbus and bluez5, you would register a listener that
will reconnect as soon as the device appears, but I am unfortunately
neither GATT nor python expert. I have done some work on synchronization
Though if you look at the GATT API spec under GATT Manager hierarchy, you
"To make service registration simple, BlueZ requires that all objects that
belong to a GATT service be grouped under a D-Bus Object Manager that
solely manages the objects of that service."
Check also the ObjectManager API .
And also under GATT Profile hierarchy
"Local profile (GATT client) instance. By registering this type of object
an application effectively indicates support for a specific GATT profile
and requests automatic connections to be established to devices
supporting it." 
For me this one looks promising. Perhaps you need to register this type of
object and the magic will work. I'm telling you (jokingly) BT is magic.
After spending few weeks may be 7y ago and was probably more frustrated than
you are ATM, I laughed for an hour or so after reading this blog article.
(it was written in the time of bluez4 I think) .
I must admit now the bluez5 is a blessing to work with, so take it from the
I hope it helps
Whoops. For some reason I assumed that an SDK is something bulky, much
bigger than that. At least, the last time I downloaded an SDK it was
hundreds of MBs.
Yep. Which is what my post is all about. I can go make a number of
assumptions and hit my shins on every rock on the road, or I could check if
anyone already knows - which looked like a good idea to me. :-)
Knowing that it most likely exists makes my job a /lot/ easier.
I've seen some talk about profiles, but nothing (code) specific (what it is
for, looks like and/or how to handle it). It certainly gives me something
to throw into Google and see what it comes up with.
And thanks for the links. Both the D-Bus spec as well as that "best kept
secret" one. :-)
Apart from the other comments I focus on this one. As mentioned I am not an
expert in GATT, but it tells me that your device can match the offered
profile and auto connect to it.
For the sync or audio services I use the defined UUIDs. When they are
registered properly the other part knows that the device supports them and
You did not mention or I missed what your device is, but you could look for
specification of the service and the profile expected.
In any way when the device is connected you could find out on the dbus what
are the specifics.
Another option is this here:
Its a basic pear-shaped "iTag" device. It can be told to "sound the
alarm", and it has a single button to ask for attention. It also "sounds
the alarm" when it loses connection.
I've displayed all services (just found that the last one is an "Over The
Air Download Service"), characteristics and descriptors, but nothing seems
to be obviously related to a profile. Doesn't matter though, I just have
to google a bit more.
The biggest problem was not having anything to start with. Now I have
Alas. Although the page displays, clicking any "downloaddoc.ashx" related
link times out. Might be related to trying that on an XP machine though.
Thanks for the help. :-)