2015-09-09 112 views
1

我試圖檢測綁定的藍牙設備是否支持GATT如何可靠地檢測綁定設備是否支持GATT?

掃描時,撥打BluetoothDevice.getType()會將我的設備識別爲類型3(雙模式 - BR/EDR/LE)。但是,設備綁定並致電BluetoothAdapter.getBondedDevices()後,同樣的方法會將我的設備作爲類型1返回(經典)。

@Override 
public void onScanResult(int callbackType, android.bluetooth.le.ScanResult result) { 
    result.getDevice().getType();// value is 3 
} 
... 
// this will show pairing request to user 
device.connectGatt(context, false, callback); 
... 
// once the device is paired, I query for the new set of bonded devices. 
Set<BluetoothDevice> set = BluetoothAdapter.getDefaultAdapter().getBondedDevices(); 
for (BluetoothDevice device : set) 
{ 
    device.getType();// value is 1 
} 

如何可以可靠地檢測,如果一個接合的裝置支撐GATT(類型3或2)?

我也試圖交叉檢查,以綁定設備:

int[] ALL_STATES = { BluetoohtProfile.STATE_DISCONNECTED, BluetoohtProfile.STATE_CONNECTING, BluetoohtProfile.STATE_CONNECTED, BluetoohtProfile.STATE_DISCONNECTING }; 
List<BluetoothDevice> list = BluetoothManager.getDevicesMatchingConnectionState(BluetoothProfile.GATT, ALL_STATES); 

但結果始終是一個空列表。

感謝任何幫助!

回答

0

您可以仔細檢查掃描結果和綁定設備中的設備是否是同一設備。

我想保稅設備是與您的Android設備綁定的其他BT設備。

相關問題