2011-09-12 72 views
3

我有一個應用程序通過藍牙與beagle板上的服務器通話。我在C++中使用bluez和平板電腦上的Android應用程序創建了服務器代碼。藍牙重新連接崩潰平板電腦蜂窩3.2

我看到的問題是服務器應用程序未啓動時,我希望平板電腦繼續嘗試連接。儘管在隨機數次的嘗試後,平板電腦將會崩潰並且實際上會重新啓動。服務器應用程序可能沒有運行,但操作系統正在運行並且藍牙技術上處於開啓狀態。它只是監聽端口沒有監聽,因爲服務器應用程序沒有運行。

2臺設備已連接,並且在一切正常運行時都不會出現問題。用例是當服務器沒有運行並且平板電腦試圖通過通信環路連接時。它顯然不會連接,因爲服務器應用程序沒有運行,這很好。我只是不明白爲什麼在重試一段時間後它鎖定了平板電腦。

平板電腦凍結前,重試次數從40次到300次到1000次不等。這不是內存泄漏,正如我在logcat中可以看到的那樣,在它崩潰之前有10%的空閒空間。我正在關閉所有套接字和流,並在每次重試連接嘗試時打開新鮮事物,因此我沒有看到任何問題。

就在我連接之前,我檢查以確保發現沒有運行,因爲我正在連接到綁定設備。

所以我認爲我在連接上的錯誤是因爲服務器沒有運行,因此沒有偵聽端口打開。這是有效的,因爲我正在測試一個錯誤情況。我只是需要幫助,爲什麼失敗的連接會多次強制重新啓動平板電腦。

D UI_BT: stateMachineCurrent: Connecting

E BluetoothEventLoop.cpp: onDiscoverServicesResult: D-Bus error: org.bluez.Error.InProgress (Discover in progress)

D BluetoothService: Cleaning up failed UUID channel lookup: 00:02:76:24:C2:8F 00001101-0000-1000-8000-00805f9b34fb

D UI_BT: FAILED Connection (95) - java.io.IOException: Service discovery failed

有人有一個想法可能是什麼錯?謝謝。

編輯:

這是一些更多的信息。我決定看看它是否與藍牙打開有關,beagle電路板上沒有應用程序運行,藍牙關閉。我整晚試了一次,重試了650萬次,平板電腦沒有崩潰,這很棒。

現在我打開藍牙並啓動我的應用程序,我希望一切都開始進行通信。我覺得這是一個通信鏈接的標準用例。一旦一切都開始像以前一樣談論平板電腦崩潰。

下面是一些logcat的輸出...

09-13 09:23:28.600 7581 7590 D UI_BT : stateMachineCurrent: Connecting

09-13 09:23:28.600 5419 5670 D BluetoothService: updateDeviceServiceChannelCache(00:02:76:24:C2:8F)

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.620 5875 5875 V BluetoothEventManager: Received android.bleutooth.device.action.UUID

09-13 09:23:28.680 5875 5878 D dalvikvm: GC_CONCURRENT freed 467K, 14% free 6435K/7431K, paused 2ms+24ms

所以我不知道爲什麼我收到這麼多的UUID的行動意圖。雖然我認爲我的問題的根本原因可能與updateDeviceServiceChannelCache()調用有關?我不確定答案是什麼,但是經過長時間的重新啓動後,內部電話會不知何故地搞砸了?我知道這個方法是由於我的代碼調用connect例程而執行的。所以我不直接調用它。

希望這些增加的信息將有助於有人指向我的決議。

謝謝!

回答

0

看起來問題是因爲某些原因,使用createRfcommSocketToServiceRecord()時,這個方法不喜歡在沒有連接時反覆故障轉移。

相反,我使用了反射和createRfcommSocket()來解決我的問題。

+0

你可以請解釋一下這個createRfcommSocket()?我在XOOM平板電腦上遇到了同樣的問題,但找不到device.createRfcommSocket()方法,只是device.createRfcommSockettoServiceRecord()。謝謝 –

+0

發現它在這裏:http://stackoverflow.com/questions/2660968/how-to-prevent-android-bluetooth-rfcomm-connection-from-dying-immediately-after –

相關問題