繁体   English   中英

需要在Android ICS上使用Motorola GATT Profile API的蓝牙低功耗示例

[英]Need Bluetooth Low Energy example using Motorola GATT Profile API on Android ICS

截至今天,摩托罗拉开发者门户网站正在将问题重定向到Stack Overflow和Google Android论坛,所以希望摩托罗拉的某个人正在倾听。

我试图在ICS设备(我的情况下是Atrix HD)上提出一个简单的应用程序,可以查询和编写GATT配置文件(不仅仅是心率监测器)。

对于ICS, http://www.motorola.com/sites/motodev/library/bluetooth_gatt_apis.html上的说明/示例充其量是不完整的。 例如,MOT_BTLE_Stubs.jar不包含在ICS下载中。 相反,我们有BluetoothGatt.jar和BluetoothGattService.jar。 但是这些库没有教程中提到的BluetoothGatt.connectGatt(...)。

ICS附加组件包含一个示例,它引导我生成ACTION_GATT意图,但是当我获得以下NULL返回时失败:

String [] ObjectPathArray =(String [])intent.getStringArrayExtra(BluetoothDevice.EXTRA_GATT);

一个写得很好的ICS示例将为摩托罗拉和小而成长的Android BLE开发者社区提供出色的服务。

谢谢!

PVS

我偶然发现了同样的问题。

我有一个更新到Android ICS(4.0.4)的Razr XT910,我正在使用摩托罗拉手机SDK插件“ Motorola_ICS_R2 ”。

我现在正在讨论SDK Addon示例“Motorola_BLE_profile_sample”,我将其作为配置文件模板与TI运行SimplePeripheral示例的TI CC2540 Dev Kit的Keyfob进行通信。

创建配置文件服务时,请确保调用BluetoothGattService(...)包含您要连接的设备实施的有效GATT主服务声明UUID 这将解决您的空ObjectPathArray问题。

例如,我的Keyfob使用UUID 0x180A实现设备信息服务,您可以在BLE CC2540 Dev Kit用户指南中找到Keyfob的这些信息(http://www.ti.com/lit/ug/swru270b/swru270b 。在图20中的第14页上.pdf)你看到句柄0x01,0x0C,0x0F的类型0x2800,这些都是主要服务。 您可以在此处找到GATT配置文件属性类型。 现在您从中更改配置文件模板(Motorola_BLE_profile_sample)

    public static final ParcelUuid HRM = ParcelUuid
        .fromString("0000180D-0000-1000-8000-00805f9b34fb");

至:

    public static final ParcelUuid HRM = ParcelUuid
        .fromString("0000180A-0000-1000-8000-00805f9b34fb");

运行应用程序后,LogCat看起来像:

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

就这样 :-)

完全同意您关于Motorolas文档,示例和开发人员支持的糟糕程度。

我确实找到了这个: http//www.tekritisoftware.com/how-to-implement-ble-in-android ,这可能会有所帮助,但我还在等待我的btle设备,所以还没有尝试过。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM