iOS和Android蓝牙低功耗连接的区别

时间:2016-07-21 18:27:49

标签: android bluetooth bluetooth-lowenergy

我有一个BLE外围设备。我无法使用BluetoothLeGatt示例Android应用程序与Android Market中没有其他BLE应用程序连接。但iOS BLE应用程序可以连接到它。这是BluetoothLeGatt连接日志:

07-21 21:06:37.506 27402-27420/bluetoothlegatt D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=xx:xx:xx:xx:xx:xx, mScanRecord=ScanRecord [mAdvertiseFlags=2, mServiceUuids=null, mManufacturerSpecificData={}, mServiceData={}, mTxPowerLevel=-2147483648, mDeviceName=TestBLE], mRssi=-82, mTimestampNanos=12459248011929}
07-21 21:06:37.506 27402-27402/bluetoothlegatt D/BluetoothDevice: mAddress: xx:xx:xx:xx:xx:xx
07-21 21:06:37.516 27402-27402/bluetoothlegatt D/BluetoothDevice: mAddress: xx:xx:xx:xx:xx:xx
07-21 21:06:40.930 27402-27402/bluetoothlegatt D/BluetoothAdapter: stopLeScan()
07-21 21:07:50.754 27402-27402/bluetoothlegatt D/BluetoothDevice: mAddress: xx:xx:xx:xx:xx:xx
07-21 21:07:50.764 27402-27402/bluetoothlegatt D/BluetoothAdapter: stopLeScan()
07-21 21:07:50.764 27402-27402/bluetoothlegatt D/BluetoothAdapter: scan not started yet
07-21 21:07:50.924 27402-27402/bluetoothlegatt D/BluetoothDevice: mAddress: xx:xx:xx:xx:xx:xx
07-21 21:07:50.924 27402-27402/bluetoothlegatt D/BluetoothGatt: connect() - device: xx:xx:xx:xx:xx:xx, auto: false
07-21 21:07:50.924 27402-27402/bluetoothlegatt D/BluetoothGatt: registerApp()
07-21 21:07:50.924 27402-27402/bluetoothlegatt D/BluetoothGatt: registerApp() - UUID=xxxxxxxx-xxxx-xxxxxxxxx-xxxxxxxxxxxx
07-21 21:07:50.924 27402-27420/bluetoothlegatt D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
07-21 21:07:50.924 27402-27420/bluetoothlegatt D/BluetoothDevice: mAddress: xx:xx:xx:xx:xx:xx
07-21 21:07:50.934 27402-27402/bluetoothlegatt D/BluetoothLeService: Trying to create a new connection.
07-21 21:07:56.060 27402-27421/bluetoothlegatt D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=5 device=xx:xx:xx:xx:xx:xx
07-21 21:07:56.060 27402-27421/bluetoothlegatt D/BluetoothDevice: mAddress: xx:xx:xx:xx:xx:xx
07-21 21:07:56.060 27402-27421/bluetoothlegatt I/BluetoothLeService: Disconnected from GATT server. 

如何连接此设备? Android和iOS BLE连接到BLE外围设备有什么区别?

更新 我的Android设备:

HTC One M7。 Android版本:5.0.2

LG Nexus 5X。 Android版本:6.0.1

2 个答案:

答案 0 :(得分:0)

07-21 21:07:50.934 27402-27402/bluetoothlegatt D/BluetoothLeService: Trying to create a new connection.
07-21 21:07:56.060 27402-27421/bluetoothlegatt D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=5 device=xx:xx:xx:xx:xx:xx
07-21 21:07:56.060 27402-27421/bluetoothlegatt D/BluetoothDevice: mAddress: xx:xx:xx:xx:xx:xx
07-21 21:07:56.060 27402-27421/bluetoothlegatt I/BluetoothLeService: Disconnected from GATT server. 

发送连接请求后,直到onClientConnectionState,大约有5秒的寻呼时间,我认为可能是寻呼超时。

查询很少: 1)此问题是否也发生在其他Android手机或仅测试手机上? 2)您设备的广告时间间隔是多少?

您可以搜索设备但无法连接,这很奇怪;或者它应该是手机和设备之间的RF问题。

答案 1 :(得分:0)

看起来我找到了答案。 我们使用CC2564德州仪器芯片。对于使用BluetoothLeGatt Android示例应用程序的BLE连接到此芯片需要替换此命令:

mBluetoothGatt = device.connectGatt(this, false, mGattCallback);

到这个命令:

mBluetoothGatt = device.connectGatt(this, false, mGattCallback,BluetoothDevice.TRANSPORT_LE);