Hi,
I have a Texas Instruments SensorTag (model CC2650) that acts as a BLE
device. I'm trying to interact with it from a PC running Bluez.
Specifically, I'm trying to read the IR temperature sensor.
Assumptions:
- The PC is running Bluez 5.50 on top of a recent Linux kernel
- There is a LE capable adapter (hci0) which is powered on
- Discovery has not yet been activated, so no devices are currently known
Here is what I *think* I need to do to make this work. Please correct
me if I'm wrong or if there is a better way to do the same thing.
- Register a handler for the "InterfacesAdded" signal on the Bluez
object manager
- Call the StartDiscovery() method on the Adapter1 interface of hci0
- In the "InterfaceAdded" handler, check if any of the interfaces being
added are org.bluez.Device1. If it is, then check that the path
contains "hci0" because we don't want to pick up objects on other adapters.
- For devices found, check if the "Name" property is set to "CC2650
SensorTag". Ideally, the device would advertise it's service UUIDs and
then you could register a profile object via org.bluez.GattManager1's
RegisterApplication(), but this is not possible because the SensorTag
doesn't seem to include the service UUIDs in it's advertising payload.
- When a matching device is found according to the search above, call
the Connect() method on the Device1 interface. This will cause all of
the services, characteristics and descriptors to be populated into the
object manager
- Wait for the IR temperature service UUID to appear in my
"InterfacesAdded" callback
- Wait for all of the relevant characteristics and descriptors to be
reported in my "InterfacesAdded" callback
- Use the ReadValue() method on the org.bluez.GattCharacteristic1
interface to read from the appropriate object
The above describes the steps that I think are necessary for a simple
read of the value. Once I want to enable notifications, I think it gets
slightly more complicated because there are multiple characteristics in
play.
Things that seem strange to me:
- I find it surprising that the way to watch for a newly scanned device
on a specific adapter is to monitor every interface that is added to
bluez and then manually filter to see if it's a device on hci0. Is
there no better way to do this?
- Do I need to track all of the characteristics and descriptors that
pass through the "InterfacesAdded" handler so that I ensure that I wait
long enough before trying to access the characteristics of a service?
Thanks,
David