2016-03-14 245 views
1

我有一个Xperia Z3C,Android 5.1.1,我试图通过蓝牙将它连接到Nexus 4 Android 6.0.1。配对它们是可以的,但是当我尝试连接它们时,它表示“连接”不到一秒钟,并自动断开连接。蓝牙在连接到另一个Android设备一段时间后保持断开连接

这是一个已知的问题?我还没有发现任何关于这个。

这里是logcat的说:

03-14 17:25:55.308: E/bt-btif(14245): bte_scan_filt_param_cfg_evt, 1 
03-14 17:25:55.308: E/bt-btif(14245): bte_scan_filt_param_cfg_evt, 1 
03-14 17:25:55.990: E/bt-btm(14245): new address: xx:xx:xx:xx:xx:xx 
03-14 17:25:55.990: E/bt-btm(14245): new address: xx:xx:xx:xx:xx:xx 
03-14 17:25:56.712: E/bt-btm(14245): new address: xx:xx:xx:xx:xx:xx 
03-14 17:25:57.464: E/bt-btif(14245): bte_scan_filt_param_cfg_evt, 1 
03-14 17:25:57.814: E/bt-btm(14245): Ignoring RNR as the state is not BTM_SEC_STATE_GETTING_NAME 
03-14 17:25:57.933: E/NetlinkEvent(318): Unknown ifindex 41 in RTM_DELADDR 
03-14 17:25:57.963: E/dhcpcd(15974): bt-pan: interface not found or invalid 
03-14 17:25:57.986: E/BluetoothPanServiceJni(14245): ## ERROR : disconnectPanNative(L224): Failed disconnect pan channel, status: 1## 
03-14 17:25:58.139: E/BluetoothTetheringNetworkFactory(14245): DHCP request error:DHCP result was failed 
03-14 17:26:01.382: E/bt-btm(14245): btm_sec_disconnected - Clearing Pending flag 
+0

关于蓝牙问题和Android 5.x有一个相当冗长和多变的错误。它让很多人对事物进行报告,但没有获得关于它有什么问题的很多有用的信息。 https://code.google.com/p/android/issues/detail?id=79488 –

+0

我发布了所有的信息,我无法找到发生了什么。我正在开发一个蓝牙打印应用程序,并试图用模拟Nexus上的BT打印机的应用程序进行测试。我甚至没有尝试向它发送数据,因为蓝牙连接失败,但是当我提出这个问题后,数据发送成功,尽管这两个设备没有连接。我不知道这里发生了什么。 @RobertNekic –

回答

1

所以两件事情可以在这里继续。您尝试维持连接的第二台设备存在维护连接的问题,或者两者之间存在干扰,导致连接中断,但时间不够,无法完全终止连接。

+0

干扰是什么意思? –

+1

蓝牙干扰可能是由以下几种情况引起的:https://support.apple.com/en-us/HT201542 – Ethan

2

我在尝试扫描Android应用程序中的蓝牙设备时遇到了同样的问题。有趣的是,它不会抛出任何异常(被捕获或未被捕获)并且默默地失败!对于API级别> = 23(Android 6.0)的设备会发生此问题。这里是我的logcat日志的摘录:

03-30 14:07:52.099 192-211/? I/BufferQueueProducer: [org.manios.testbt/org.manios.testbt.printing.BluetoothPrinterDiscovery](this:0x7fa16de400,id:1467,api:1,p:26262,c:192) queueBuffer: fps=0.19 dur=5154.29 max=5154.29 min=5154.29 
03-30 14:07:52.114 192-192/? I/SurfaceFlinger: [Built-in Screen (type:0)] fps:1.091767,dur:1831.89,max:999.66,min:832.23 
03-30 14:07:52.137 774-1001/? D/InputReader: AP_PROF:AppLaunch_dispatchPtr:Up:89556864, ID:0, Index:2056797440 
03-30 14:07:52.137 774-1001/? I/PerfService: PerfServiceNative_boostEnableTimeoutMsAsync:3, 100 
03-30 14:07:52.138 26262-26262/org.manios.testbt D/SettingsInterface: from settings cache , name = sound_effects_enabled , value = 0 
03-30 14:07:52.138 26262-26262/org.manios.testbt D/BluetoothAdapter: isEnabled 
03-30 14:07:52.140 26262-26262/org.manios.testbt D/BluetoothAdapter: getName 
03-30 14:07:52.141 774-1636/? D/BluetoothManagerService: checkIfCallerIsForegroundUser: valid=true callingUser=0 parentUser=-10000 foregroundUser=0 
03-30 14:07:52.142 21807-21818/? D/BluetoothAdapterProperties: getName: mName = Lenovo TAB3 8 
03-30 14:07:52.144 26262-666/org.manios.testbt D/BluetoothAdapter: isEnabled 
03-30 14:07:52.146 26262-666/org.manios.testbt D/BluetoothAdapter: isDiscovering 
03-30 14:07:52.148 26262-666/org.manios.testbt D/BluetoothAdapter: 109507751: getState(). Returning 12 
03-30 14:07:52.152 21807-21817/? D/BluetoothAdapterProperties: isDiscovering: mDiscovering = false 
03-30 14:07:52.156 26262-666/org.manios.testbt D/BluetoothAdapter: startDiscovery 
03-30 14:07:52.158 26262-666/org.manios.testbt D/BluetoothAdapter: 109507751: getState(). Returning 12 
03-30 14:07:52.160 21807-21830/? W/bt_btif: bta_dm_check_av:0 
03-30 14:07:52.172 21807-21830/? E/bt_btif: bte_scan_filt_param_cfg_evt, 1 
03-30 14:07:52.181 21807-21823/? I/BluetoothAdapterProperties: Callback:discoveryStateChangeCallback with state:1 
03-30 14:07:52.182 774-2924/? V/ActivityManager: Broadcast: Intent { act=android.bluetooth.adapter.action.DISCOVERY_STARTED flg=0x10 } ordered=false userid=0 callerApp=ProcessRecord{c376192 21807:com.android.bluetooth/1002} 
03-30 14:07:52.184 1057-1265/? V/BluetoothEventManager: Received android.bluetooth.adapter.action.DISCOVERY_STARTED 
03-30 14:07:52.185 1057-1265/? D/BluetoothEventManager: scanning state change to true 
03-30 14:07:52.186 21983-21983/? D/ActivityThread: BDC-Calling onReceive: intent=Intent { act=android.bluetooth.adapter.action.DISCOVERY_STARTED flg=0x10 cmp=com.android.settings/.bluetooth.BluetoothDiscoveryReceiver }, rec[email protected]b02fe63 
03-30 14:07:52.186 21983-21983/? V/BluetoothDiscoveryReceiver: Received: android.bluetooth.adapter.action.DISCOVERY_STARTED 
03-30 14:07:52.187 21983-21983/? D/ActivityThread: BDC-RECEIVER handled : 0/ReceiverData{intent=Intent { act=android.bluetooth.adapter.action.DISCOVERY_STARTED flg=0x10 cmp=com.android.settings/.bluetooth.BluetoothDiscoveryReceiver } packageName=com.android.settings resultCode=-1 resultData=null resultExtras=null} 
03-30 14:07:52.218 774-1001/? D/InputReader: AP_PROF:AppLaunch_dispatchPtr:Down:89556946, ID:0, Index:2056794048 
03-30 14:07:52.219 774-1001/? I/PerfService: PerfServiceNative_boostEnableAsync:3 

我以后用这个issue一些搜索发现,在API等级> = 23(在Android 6.0),我们有以下权限添加到AndroidManifext.xml

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 

使扫描和其他蓝牙操作正常工作。

在Android文档中,它在BluetoothAdapter.startDiscovery()中声明它需要BLUETOOTH_ADMIN权限,但没有进一步的细节。但是如果我们看一下BluetoothLeScanner.startScan(),它明确指出:

需要BLUETOOTH_ADMIN权限。应用必须拥有ACCESS_COARSE_LOCATIONACCESS_FINE_LOCATION权限才能获得结果。

希望这会有所帮助!

+1

@IgorGanapolsky我通过指向官方Android文档的链接更新了我的答案。 –