安卓4.4.4摩托摹蓝牙LE重新连接问题 [英] Android 4.4.4 Moto G Bluetooth LE reconnect issue

查看:491
本文介绍了安卓4.4.4摩托摹蓝牙LE重新连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,在三星S3的伟大工程上的摩托摹运行的是Android 4.3,但是我一直有问题,运行4.4.4

我的BLE在应用程序外设连接和断开连接几次使用。这工作正常,但有时也有那么一刻,应用程序/手机不再重新连接到外围。

所有关贸总协定命令在主线程,例如上运行。

 最后BluetoothGatt GAT =关贸总协定;
处理程序处理程序=新的处理程序(Looper.getMainLooper());
handler.post(新的Runnable(){
@覆盖
公共无效的run(){
  //这个code将在主线程上执行
  如果(Looper.myLooper()== Looper.getMainLooper()){
    Log.e(TAG,mGattCallback disconnect2:现在主线程:));
  }
  gat.disconnect();
  }
});
 

和外围断开罚款。当发生这种情况,我无法重新连接到外设更多,我得到日志的负荷是这样的:

  04-07 16:57:56.798:I / BT-HCI(2127):BLE HCI(n = 62)事件= 0×02)
04-07 16:57:56.798:I / BT-HCI(2127):btu_ble_process_adv_pkt
04-07 16:57:56.833:I / BT-HCI(2127):BLE HCI(n = 62)事件= 0×02)
04-07 16:57:56.833:I / BT-HCI(2127):btu_ble_process_adv_pkt
04-07 16:57:56.871:I / BT-HCI(2127):BLE HCI(n = 62)事件= 0×02)
04-07 16:57:56.871:I / BT-HCI(2127):btu_ble_process_adv_pkt
04-07 16:57:56.906:I / BT-HCI(2127):BLE HCI(n = 62)事件= 0×02)
04-07 16:57:56.906:I / BT-HCI(2127):btu_ble_process_adv_pkt
04-07 16:57:56.941:I / BT-HCI(2127):BLE HCI(n = 62)事件= 0×02)
04-07 16:57:56.941:I / BT-HCI(2127):btu_ble_process_adv_pkt
04-07 16:57:56.977:I / BT-HCI(2127):BLE HCI(n = 62)事件= 0×02)
04-07 16:57:56.977:I / BT-HCI(2127):btu_ble_process_adv_pkt
04-07 16:57:57.016:I / BT-HCI(2127):BLE HCI(n = 62)事件= 0×02)
04-07 16:57:57.016:I / BT-HCI(2127):btu_ble_process_adv_pkt
 

和我需要退出程序,关闭蓝牙关闭并再次为它开始正常工作了。

任何已知的问题,提示或建议?

感谢

编辑----------- 经过一些测试,似乎离开了应用程序的运行,最终我得到了以下日志,然后我的周围可以再次重新连接:

  04-13 19:11:53.973:I / BT-HCI(2034):BLE HCI(n = 62)事件= 0×02)
04-13 19:11:53.973:I / BT-HCI(2034):btu_ble_process_adv_pkt
04-13 19:11:54.076:I / BT-HCI(2034):BLE HCI(n = 62)事件= 0×02)
04-13 19:11:54.076:I / BT-HCI(2034):btu_ble_process_adv_pkt
04-13 19:11:55.986:I / BT-HCI(2034):BLE HCI(n = 62)事件= 0×02)
04-13 19:11:55.986:I / BT-HCI(2034):btu_ble_process_adv_pkt
04-13 19:11:56.087:I / BT-HCI(2034):BLE HCI(n = 62)事件= 0×02)
04-13 19:11:56.087:I / BT-HCI(2034):btu_ble_process_adv_pkt
04-13 19:11:56.629:I / BT-HCI(2034):BLE HCI(n = 62)事件= 0×02)
04-13 19:11:56.629:I / BT-HCI(2034):btu_ble_process_adv_pkt
04-13 19:11:56.734:I / BT-HCI(2034):BLE HCI(n = 62)事件= 0×02)
04-13 19:11:56.734:I / BT-HCI(2034):btu_ble_process_adv_pkt
04-13 19:11:58.925:D / MDMCTBK(275):reply_len:40回复是= IFNAME =为wlan0 3;> CTRL-EVENT-SCAN-结果
04-13 19:11:58.925:D / MDMCTBK(275):事件收到= CTRL-EVENT-SCAN-结果
04-13 19:11:58.926:D / WifiStateMachine(1010):的handleMessage:电子msg.what = 147461
04-13 19:11:58.926:D / WifiStateMachine(1010):processMsg:DisconnectedState
04-13 19:11:58.926:D / WifiStateMachine(1010):processMsg:ConnectModeState
04-13 19:11:58.926:D / WifiStateMachine(1010):processMsg:DriverStartedState
04-13 19:11:58.927:D / WifiStateMachine(1010):processMsg:SupplicantStartedState
04-13 19:11:58.928:D / TCMD(4253):NL  - 阅读从更新插座56个字节。
04-13 19:11:58.928:D / TCMD(4253):NL  - 消息类型是RTM_NEWLINK
04-13 19:11:58.928:D / TCMD(4253):监听传入的客户端的连接请求
04-13 19:35:18.787:V / AlarmManager(1010):发送报警报警{42b84cc0 2型com.google.android.gms}
04-13 19:35:18.787:V / AlarmManager(1010):发送报警报警{42b83a00 0型机器人}
04-13 19:11:58.941:D / WifiStateMachine(1010):的handleMessage:X
04-13 19:12:00.615:D / WifiStateMachine(1010):的handleMessage:电子msg.what = 131143
04-13 19:12:00.615:D / WifiStateMachine(1010):processMsg:DisconnectedState
04-13 19:12:00.616:D / WifiStateMachine(1010):processMsg:ConnectModeState
04-13 19:12:00.617:D / WifiStateMachine(1010):processMsg:DriverStartedState
04-13 19:12:00.628:D / WifiStateMachine(1010):的handleMessage:X
04-13 19:12:01.425:D / MDMCTBK(275):reply_len:40回复= IFNAME =为wlan0 3;> CTRL-EVENT-BSS除去1
04-13 19:12:01.425:D / MDMCTBK(275):事件收到= CTRL-EVENT-BSS除去1
04-13 19:12:01.425:D / MDMCTBK(275):reply_len:40回复是= IFNAME =为wlan0 3;> CTRL-EVENT-SCAN-结果
04-13 19:12:01.425:D / MDMCTBK(275):事件收到= CTRL-EVENT-SCAN-结果
04-13 19:12:01.425:D / WifiStateMachine(1010):的handleMessage:电子msg.what = 147461
04-13 19:12:01.426:D / WifiStateMachine(1010):processMsg:DisconnectedState
04-13 19:12:01.426:D / WifiStateMachine(1010):processMsg:ConnectModeState
04-13 19:12:01.426:D / WifiStateMachine(1010):processMsg:DriverStartedState
04-13 19:12:01.426:D / WifiStateMachine(1010):processMsg:SupplicantStartedState
04-13 19:12:01.428:D / MDMCTBK(275):reply_len:40回复= IFNAME = p2p0 3;> CTRL-EVENT-BSS除去1
04-13 19:12:01.428:D / MDMCTBK(275):事件收到= CTRL-EVENT-BSS除去1
04-13 19:12:01.428:D / TCMD(4253):NL  - 阅读从更新插座56个字节。
04-13 19:12:01.428:D / TCMD(4253):NL  - 消息类型是RTM_NEWLINK
04-13 19:12:01.428:D / TCMD(4253):监听传入的客户端的连接请求
04-13 19:12:01.444:D / WifiStateMachine(1010):的handleMessage:X
 

它看起来像它的东西做了WiFi?!

解决方案

我觉得不会有像使用主线程一个简单的答案,一切都OK。但是,我可以给你一些提示我收集工作时与蹩脚的Andr​​oid BLE:

  • BT协议栈将在不同的手机不同,不幸的是摩托G的最crappiest手机之一,如果我们谈论BLE ......有多么的差劲?瓷砖的应用程序,甚至各国的常见问题什么的Andr​​oid手机将与瓷砖的工作:
  

将只使用三星Galaxy S5,的HTC One M8,HTC其中,LG的Nexus 4,LG的Nexus 5,LG的Nexus 6,三星注4,摩托罗拉极限摩托,当然不会与摩托摹

  Bluedroid的不断成熟和稳定;有565提交的孤独bluedroid项目从4.4  - > 5.0,从4.3 52比提交 - >从4.2 4.4,和47提交 - > 4.3。*这是在AOSP重活动的区域现在。
 

  • 另外还有最大数量进一步 - 环顾四周31'st分钟

I have an app that works great on a Samsung S3 running Android 4.3 however i've having issues on a Moto G running 4.4.4

My BLE peripheral connects and disconnects several times during the apps use. This works fine however sometimes there comes a point where the app/phone no longer reconnects to the peripheral.

All gatt commands are run on the main thread, eg.

final BluetoothGatt gat = gatt;
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
  // This code will be executed on the main thread
  if (Looper.myLooper() == Looper.getMainLooper()) {
    Log.e(TAG, "mGattCallback disconnect2: NOW ON MAIN THREAD :)");
  }
  gat.disconnect();
  }
});

and the peripheral disconnects fine. When this happens and I can't reconnect to the peripheral any more, I get loads of log's like this:

04-07 16:57:56.798: I/bt-hci(2127): BLE HCI(id=62) event = 0x02)
04-07 16:57:56.798: I/bt-hci(2127): btu_ble_process_adv_pkt
04-07 16:57:56.833: I/bt-hci(2127): BLE HCI(id=62) event = 0x02)
04-07 16:57:56.833: I/bt-hci(2127): btu_ble_process_adv_pkt
04-07 16:57:56.871: I/bt-hci(2127): BLE HCI(id=62) event = 0x02)
04-07 16:57:56.871: I/bt-hci(2127): btu_ble_process_adv_pkt
04-07 16:57:56.906: I/bt-hci(2127): BLE HCI(id=62) event = 0x02)
04-07 16:57:56.906: I/bt-hci(2127): btu_ble_process_adv_pkt
04-07 16:57:56.941: I/bt-hci(2127): BLE HCI(id=62) event = 0x02)
04-07 16:57:56.941: I/bt-hci(2127): btu_ble_process_adv_pkt
04-07 16:57:56.977: I/bt-hci(2127): BLE HCI(id=62) event = 0x02)
04-07 16:57:56.977: I/bt-hci(2127): btu_ble_process_adv_pkt
04-07 16:57:57.016: I/bt-hci(2127): BLE HCI(id=62) event = 0x02)
04-07 16:57:57.016: I/bt-hci(2127): btu_ble_process_adv_pkt

and I need to quit the app, turn bluetooth off and on again for it to start working properly again.

Any known issues, tips or advice?

Thanks

EDIT ----------- After some more testing, it seems that leaving the app running, eventually I get the following logs and then my peripheral can reconnect again:

04-13 19:11:53.973: I/bt-hci(2034): BLE HCI(id=62) event = 0x02)
04-13 19:11:53.973: I/bt-hci(2034): btu_ble_process_adv_pkt
04-13 19:11:54.076: I/bt-hci(2034): BLE HCI(id=62) event = 0x02)
04-13 19:11:54.076: I/bt-hci(2034): btu_ble_process_adv_pkt
04-13 19:11:55.986: I/bt-hci(2034): BLE HCI(id=62) event = 0x02)
04-13 19:11:55.986: I/bt-hci(2034): btu_ble_process_adv_pkt
04-13 19:11:56.087: I/bt-hci(2034): BLE HCI(id=62) event = 0x02)
04-13 19:11:56.087: I/bt-hci(2034): btu_ble_process_adv_pkt
04-13 19:11:56.629: I/bt-hci(2034): BLE HCI(id=62) event = 0x02)
04-13 19:11:56.629: I/bt-hci(2034): btu_ble_process_adv_pkt
04-13 19:11:56.734: I/bt-hci(2034): BLE HCI(id=62) event = 0x02)
04-13 19:11:56.734: I/bt-hci(2034): btu_ble_process_adv_pkt
04-13 19:11:58.925: D/MDMCTBK(275): reply_len: 40 reply is = IFNAME=wlan0 <3>CTRL-EVENT-SCAN-RESULTS 
04-13 19:11:58.925: D/MDMCTBK(275): Event received = CTRL-EVENT-SCAN-RESULTS 
04-13 19:11:58.926: D/WifiStateMachine(1010): handleMessage: E msg.what=147461
04-13 19:11:58.926: D/WifiStateMachine(1010): processMsg: DisconnectedState
04-13 19:11:58.926: D/WifiStateMachine(1010): processMsg: ConnectModeState
04-13 19:11:58.926: D/WifiStateMachine(1010): processMsg: DriverStartedState
04-13 19:11:58.927: D/WifiStateMachine(1010): processMsg: SupplicantStartedState
04-13 19:11:58.928: D/TCMD(4253): NL - Read 56 bytes from update socket.
04-13 19:11:58.928: D/TCMD(4253): NL - message type is RTM_NEWLINK
04-13 19:11:58.928: D/TCMD(4253): Listening for incoming client connection request
04-13 19:35:18.787: V/AlarmManager(1010): sending alarm Alarm{42b84cc0 type 2 com.google.android.gms}
04-13 19:35:18.787: V/AlarmManager(1010): sending alarm Alarm{42b83a00 type 0 android}
04-13 19:11:58.941: D/WifiStateMachine(1010): handleMessage: X
04-13 19:12:00.615: D/WifiStateMachine(1010): handleMessage: E msg.what=131143
04-13 19:12:00.615: D/WifiStateMachine(1010): processMsg: DisconnectedState
04-13 19:12:00.616: D/WifiStateMachine(1010): processMsg: ConnectModeState
04-13 19:12:00.617: D/WifiStateMachine(1010): processMsg: DriverStartedState
04-13 19:12:00.628: D/WifiStateMachine(1010): handleMessage: X
04-13 19:12:01.425: D/MDMCTBK(275): reply_len: 40 reply is = IFNAME=wlan0 <3>CTRL-EVENT-BSS-REMOVED 1
04-13 19:12:01.425: D/MDMCTBK(275): Event received = CTRL-EVENT-BSS-REMOVED 1
04-13 19:12:01.425: D/MDMCTBK(275): reply_len: 40 reply is = IFNAME=wlan0 <3>CTRL-EVENT-SCAN-RESULTS 
04-13 19:12:01.425: D/MDMCTBK(275): Event received = CTRL-EVENT-SCAN-RESULTS 
04-13 19:12:01.425: D/WifiStateMachine(1010): handleMessage: E msg.what=147461
04-13 19:12:01.426: D/WifiStateMachine(1010): processMsg: DisconnectedState
04-13 19:12:01.426: D/WifiStateMachine(1010): processMsg: ConnectModeState
04-13 19:12:01.426: D/WifiStateMachine(1010): processMsg: DriverStartedState
04-13 19:12:01.426: D/WifiStateMachine(1010): processMsg: SupplicantStartedState
04-13 19:12:01.428: D/MDMCTBK(275): reply_len: 40 reply is = IFNAME=p2p0 <3>CTRL-EVENT-BSS-REMOVED 1 
04-13 19:12:01.428: D/MDMCTBK(275): Event received = CTRL-EVENT-BSS-REMOVED 1 
04-13 19:12:01.428: D/TCMD(4253): NL - Read 56 bytes from update socket.
04-13 19:12:01.428: D/TCMD(4253): NL - message type is RTM_NEWLINK
04-13 19:12:01.428: D/TCMD(4253): Listening for incoming client connection request
04-13 19:12:01.444: D/WifiStateMachine(1010): handleMessage: X

It's looking like it's something to do with the WiFi?!

解决方案

I think there will not be an easy answer like "use Main Thread" and everything is OK. But I can give you some hints I gathered while working with crappy Android BLE:

will work only with Samsung Galaxy S5, HTC One M8, HTC One, LG Nexus 4, LG Nexus 5, LG Nexus 6, Samsung Note 4, Motorola Moto X and certainly will not work with Moto G

Bluedroid continues to mature and stabilize; there were 565 commits to the bluedroid project alone from 4.4 -> 5.0, compared with 52 commits from 4.3 -> 4.4, and 47 commits from 4.2 -> 4.3.* This is an area of heavy activity within AOSP right now.

这篇关于安卓4.4.4摩托摹蓝牙LE重新连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆