I have a project that needs to connect to an array of Bluetooth LE sensors. I wrote the sensors myself and they are compliant with the Environmental Sensing and Battery Service profiles. I can use my Android BLE apps to connect to the sensors and utilize them just great. In fact they work better than expected. Now I'm trying to get my app to run on the Edison with all the latest software update/upgraded with opkg.
I am trying to run a modified version of the HelloTinyB example. When I run it I get the following output;
Listening for transport dt_socket at address: 8005
The discovery started: true
Address = E2:E4:BD:03:41:03 Name = DSLT-TMP Connected = false
Address = F0:79:59:2B:93:40 Name = Snarf Connected = false
Error: GDBus.Error:org.bluez.Error.InProgress: Operation already in progress
Found device: Address = E2:E4:BD:03:41:03 Name = DSLT-TMP Connected = false
Sensor with the provided address connected
Services exposed by device:
Device Addr: E2:E4:BD:03:41:03
Device: DSLT-TMP -> 00001530-1212-efde-1523-785feabcd123
Device: DSLT-TMP -> 00001800-0000-1000-8000-00805f9b34fb
Device: DSLT-TMP -> 00001801-0000-1000-8000-00805f9b34fb
Device: DSLT-TMP -> 0000180a-0000-1000-8000-00805f9b34fb
Device: DSLT-TMP -> 0000180f-0000-1000-8000-00805f9b34fb
Device: DSLT-TMP -> 0000181a-0000-1000-8000-00805f9b34fb
Device: DSLT-TMP -> 6e400001-b5a3-f393-e0a9-e50e24dcca9e
Device: DSLT-TMP -> ee0c2080-8786-40ba-ab96-99b91ac981d8
Services > ? 0
So the Device: DSTL-TMP show the UUIDs the devices is advertising BUT when the "bluetoothServices = device.getServices();" is executed it brings back a zero length list forever. Its in a loop with a 4 second sleep.
When you print the UUIDs you can clear see the UUIDs for the two services I want to connect to;
UUID: Battery Service (0000180f-0000-1000-8000-00805f9b34fb)
UUID: Environmental Sensing (0000181a-0000-1000-8000-00805f9b34fb)
In fact, the above UUIDs I got from the bluetoothctl tool so I'm at a loss now. If anyone could help it would be great. Thanks!
So I figured this much out, the Bluetooth service needs to be started in experimental mode before it will work in Java. A step I missed in the sparse documentation which makes all the more embarrassing that I missed it.
The /lib/systemd/system/bluetooth.service needs a -E added to the ExecStart line and restart the service.