2016-07-21 92 views
0

我有一個BLE外圍設備。我無法使用BluetoothLeGatt示例android應用程序連接到它,並且Android Market中沒有其他BLE應用程序。但iOS BLE應用程序可以連接到它。這是BluetoothLeGatt連接日誌:iOS和Android之間的區別藍牙低功耗連接

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

回答

0

看起來像我找到答案。我們使用CC2564德州儀器芯片。對於這種芯片的Android BluetoothLeGatt示例應用程序BLE連接需要更換這個命令:

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

此命令:

mBluetoothGatt = device.connectGatt(this, false, mGattCallback,BluetoothDevice.TRANSPORT_LE); 
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問題。

+0

我更新我的職務。我的HTC One M7與Android 5.0.2和LG Nexus 5X與Android 6.0.1發生此問題。廣告間隔100 - 200毫秒。 Android設備延遲3到5秒後會出現連接錯誤。 iOS設備立即連接到BLE設備。 – BadEugene