Reputation: 1168
As of today Motorola Developer portal is redirecting questions to Stack Overflow and Google Android forums, so here goes in hope that someone from Motorola is listening.
I am trying to come up with a simple app on an ICS device (Atrix HD in my case) that could query and write GATT profiles (not just heart rate monitor).
The instructions/example at http://www.motorola.com/sites/motodev/library/bluetooth_gatt_apis.html are incomplete at best, for ICS. For instance MOT_BTLE_Stubs.jar is not included with the ICS downloads. Instead we have BluetoothGatt.jar and BluetoothGattService.jar. But these libraries do not have the BluetoothGatt.connectGatt(...) referred to in the tutorial.
The ICS add-on includes an example and it led me as far as generating the ACTION_GATT intent, but failed when I got a NULL return for the following:
String[] ObjectPathArray = (String[])intent.getStringArrayExtra(BluetoothDevice.EXTRA_GATT);
A well-written example for ICS would do great service to both Motorola and the small-but-growing Android BLE developer community.
Thanks!
PVS
Upvotes: 1
Views: 4029
Reputation: 126
I stumbled upon the exact same problem.
I have a Razr XT910 updated to Android ICS (4.0.4) and I'm using the Motorola Handset SDK Addon "Motorola_ICS_R2
".
I'm talking now about the SDK Addon sample "Motorola_BLE_profile_sample" which I'm using as a profile template to communicate with my Keyfob of TI's CC2540 Dev Kit which runs the SimplePeripheral Example.
When you create your profile services make sure the call BluetoothGattService(...) contains a valid GATT Primary Service Declaration UUID which your device you are connecting to implements. This will solve your problem with the empty ObjectPathArray.
As an example, my Keyfob implements the Device Information Service with the UUID 0x180A, you can find this information for the Keyfob in the BLE CC2540 Dev Kit User Guide (http://www.ti.com/lit/ug/swru270b/swru270b.pdf) at page 14 in figure 20. Do you see the type 0x2800 of the handles 0x01, 0x0C, 0x0F, these are all primary services. You can find the GATT profile attribute types here. Now you change your profile template (Motorola_BLE_profile_sample) from
public static final ParcelUuid HRM = ParcelUuid
.fromString("0000180D-0000-1000-8000-00805f9b34fb");
to:
public static final ParcelUuid HRM = ParcelUuid
.fromString("0000180A-0000-1000-8000-00805f9b34fb");
After running the application the LogCat looks like:
11-09 03:17:39.674: I/BluetoothLe(17462): onStop()
11-09 03:17:40.478: I/BluetoothLe(17462): onStart()
11-09 03:17:40.478: I/BluetoothLe(17462): onResume()
11-09 03:17:40.978: D/BluetoothLeREceiver(17462): Bluetooth LE receiver intnet action: android.bluetooth.devicepicker.action.DEVICE_SELECTED
11-09 03:17:40.986: I/BluetoothLe(17462): enter startConnection and value of devicePicker is true
11-09 03:17:40.986: D/BluetoothLe(17462): Calling btDevice.getGattServices
11-09 03:17:40.994: V/BluetoothLe(17462): primary service was successful
11-09 03:17:40.994: D/BluetoothLe(17462): GATT action
11-09 03:17:41.002: D/BluetoothLe(17462): GATT Service data list len : 1
11-09 03:17:41.002: V/BluetoothLe(17462): getBluetoothGattService()
11-09 03:17:41.002: D/BluetoothLe(17462): ++++++ Creating BluetoothGattService with device = 90:D7:EB:B2:4D:1D uuid 0000180a-0000-1000-8000-00805f9b34fb objPath = /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010
11-09 03:17:41.002: D/BluetoothGattService(17462): Discovery State 0 to 0
11-09 03:17:41.002: D/BluetoothGattService(17462): Bond state of remote device : 90:D7:EB:B2:4D:1D is 12
11-09 03:17:41.002: D/BluetoothGattService(17462): doDiscovery /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010
11-09 03:17:41.002: D/BluetoothGattService(17462): Discovery State 0 to 2
11-09 03:17:41.002: D/BluetoothLe(17462): getBluetoothGattService(): Adding gatt service to map for : 0000180a-0000-1000-8000-00805f9b34fbsize :1
11-09 03:17:41.002: D/BluetoothGattService(17462): readCharacteristicValue for /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010
11-09 03:17:55.463: D/BluetoothGattService(17462): onCharacteristicsDiscovered: [Ljava.lang.String;@41412ea0
11-09 03:17:55.471: D/BluetoothGattService(17462): Discovered 9 characteristics for service /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010 ( null )
11-09 03:17:55.510: D/BluetoothGattService(17462): Discovery State 2 to 1
11-09 03:17:55.510: D/BluetoothLe(17462): onDiscoverCharacteristicsResult : path : /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010 result : true
11-09 03:17:55.510: D/BluetoothLe(17462): gattService.getServiceUuid() ======= 0000180a-0000-1000-8000-00805f9b34fb
11-09 03:17:55.517: D/BluetoothGattService(17462): Characteristic UUID: 00002a23-0000-1000-8000-00805f9b34fb
11-09 03:17:55.517: D/BluetoothGattService(17462): Characteristic UUID: 00002a24-0000-1000-8000-00805f9b34fb
11-09 03:17:55.517: D/BluetoothGattService(17462): Characteristic UUID: 00002a25-0000-1000-8000-00805f9b34fb
11-09 03:17:55.517: D/BluetoothGattService(17462): Characteristic UUID: 00002a26-0000-1000-8000-00805f9b34fb
11-09 03:17:55.517: D/BluetoothGattService(17462): Characteristic UUID: 00002a27-0000-1000-8000-00805f9b34fb
11-09 03:17:55.517: D/BluetoothGattService(17462): Characteristic UUID: 00002a28-0000-1000-8000-00805f9b34fb
11-09 03:17:55.517: D/BluetoothGattService(17462): Characteristic UUID: 00002a29-0000-1000-8000-00805f9b34fb
11-09 03:17:55.517: D/BluetoothGattService(17462): Characteristic UUID: 00002a2a-0000-1000-8000-00805f9b34fb
11-09 03:17:55.525: D/BluetoothGattService(17462): Characteristic UUID: 00002a50-0000-1000-8000-00805f9b34fb
11-09 03:17:55.525: D/BluetoothGattService(17462): value is : /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0012,/org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0014,/org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0016,/org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0018,/org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic001a,/org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic001c,/org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic001e,/org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0020,/org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0022,
11-09 03:17:55.525: D/BluetoothGattService(17462): Characteristic UUID: 00002a23-0000-1000-8000-00805f9b34fb
11-09 03:17:55.525: D/BluetoothLe(17462): Map with key UUID : 00002a23-0000-1000-8000-00805f9b34fb value : /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0012
11-09 03:17:55.525: D/BluetoothGattService(17462): Characteristic UUID: 00002a24-0000-1000-8000-00805f9b34fb
11-09 03:17:55.525: D/BluetoothLe(17462): Map with key UUID : 00002a24-0000-1000-8000-00805f9b34fb value : /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0014
11-09 03:17:55.525: D/BluetoothGattService(17462): Characteristic UUID: 00002a25-0000-1000-8000-00805f9b34fb
11-09 03:17:55.525: D/BluetoothLe(17462): Map with key UUID : 00002a25-0000-1000-8000-00805f9b34fb value : /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0016
11-09 03:17:55.525: D/BluetoothGattService(17462): Characteristic UUID: 00002a26-0000-1000-8000-00805f9b34fb
11-09 03:17:55.525: D/BluetoothLe(17462): Map with key UUID : 00002a26-0000-1000-8000-00805f9b34fb value : /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0018
11-09 03:17:55.525: D/BluetoothGattService(17462): Characteristic UUID: 00002a27-0000-1000-8000-00805f9b34fb
11-09 03:17:55.533: D/BluetoothLe(17462): Map with key UUID : 00002a27-0000-1000-8000-00805f9b34fb value : /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic001a
11-09 03:17:55.533: D/BluetoothGattService(17462): Characteristic UUID: 00002a28-0000-1000-8000-00805f9b34fb
11-09 03:17:55.533: D/BluetoothLe(17462): Map with key UUID : 00002a28-0000-1000-8000-00805f9b34fb value : /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic001c
11-09 03:17:55.533: D/BluetoothGattService(17462): Characteristic UUID: 00002a29-0000-1000-8000-00805f9b34fb
11-09 03:17:55.533: D/BluetoothLe(17462): Map with key UUID : 00002a29-0000-1000-8000-00805f9b34fb value : /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic001e
11-09 03:17:55.533: D/BluetoothGattService(17462): Characteristic UUID: 00002a2a-0000-1000-8000-00805f9b34fb
11-09 03:17:55.533: D/BluetoothLe(17462): Map with key UUID : 00002a2a-0000-1000-8000-00805f9b34fb value : /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0020
11-09 03:17:55.533: D/BluetoothGattService(17462): Characteristic UUID: 00002a50-0000-1000-8000-00805f9b34fb
11-09 03:17:55.533: D/BluetoothLe(17462): Map with key UUID : 00002a50-0000-1000-8000-00805f9b34fb value : /org/bluez/358/hci0/dev_90_D7_EB_B2_4D_1D/service0010/characteristic0022
11-09 03:17:55.533: D/BluetoothLe(17462): Created map with size : 10
That's all :-)
Upvotes: 3
Reputation: 7935
Completely agree with you about how bad Motorolas documentation, examples and developer support is.
I did find this: http://www.tekritisoftware.com/how-to-implement-ble-in-android which might be helpful, but I'm still waiting on my btle device so havn't tried it out yet.
Upvotes: 0