2012-09-12 5 views
0

Note: également posté sur https://groups.google.com/forum/?fromgroups=#!topic/android-scripting/UsPy3x4jvG0Android Bluetooth IOException: Connexion refusée

Je suis en train de se connecter à un périphérique RFCOMM Bluetooth. J'utilise sl4a et me connecte à partir d'un script Python. J'ai deux appareils Android exécutant la même version Android 2.3.4.

Sur un périphérique (Galaxy S2 avec un noyau très proche du stock, enraciné), le script fonctionne correctement et se connecte au périphérique RFCOMM. Sur l'autre appareil, un exotique Winmate E430T (téléphone Android spécialisé robuste avec un volume assez faible je soupçonne), je reçois un java.io.IOException: Connection refused.

J'ai essayé d'exécuter l'exemple de code bluetooth_chat.py sans succès, celui-ci est destiné à la connexion Android à Android. Je reçois le même message d'erreur, ce qui indiquerait que le problème ne se trouve pas dans mon code mais plutôt dans l'état du téléphone Winmate (rooté ou non, installé sur SW, configuration).

Quelqu'un a déjà vu quelque chose de similaire? J'ai vu les messages sur la réparation de l'échec, j'ai essayé ça deux fois mais cela n'a pas aidé. J'ai également essayé de redémarrer le Winmate après avoir installé Python et tous les modules.

Le code:

import android 
droid = android.Android() 
address = '00:12:F3:11:DC:D5' 
uuid = '00001101-0000-1000-8000-00805F9B34FB' 
droid.toggleBluetoothState(True) 
droid.bluetoothConnect(uuid, address) 

Extrait de logcat:

V/sl4a.JsonRpcServer:117(27913): Sent: {"error":null,"id":6,"result":{"which":"negative"}} 
V/sl4a.JsonRpcServer:74(27913): Received: {"params": [], "id": 7, "method": "bluetoothConnect"} 
I/ActivityManager(1304): Starting: Intent { flg=0x18000000 cmp=com.googlecode.android_scripting/.activity.FutureActivity (has extras) } from pid 27913 
I/HK/LatinKeyboardBaseView(1385): closing [email protected] 
D/sl4a.ConsoleActivity:761(27913): onResume called 
D/sl4a.ConsoleActivity:746(27913): onPause called 
V/sl4a.FutureActivity:50(27913): FutureActivity created. 
I/ActivityManager(1304): Starting: Intent { cmp=com.googlecode.android_scripting/.activity.BluetoothDeviceList } from pid 27913 
E/BluetoothEventLoop.cpp(1304): event_filter: Received signal org.bluez.Adapter:PropertyChanged from /org/bluez/23550/hci0 
V/BluetoothEventRedirector(1862): Received android.bluetooth.adapter.action.DISCOVERY_STARTED 
I/HK/LatinKeyboardBaseView(1385): closing [email protected] 
E/BluetoothEventLoop.cpp(1304): event_filter: Received signal org.bluez.Adapter:DeviceFound from /org/bluez/23550/hci0 
D/BluetoothService(1304): updateDeviceServiceChannelCache(00:12:F3:11:DC:D5) 
V/BluetoothEventRedirector(1862): Received android.bluetooth.device.action.FOUND 
E/BluetoothEventLoop.cpp(1304): event_filter: Received signal org.bluez.Adapter:DeviceFound from /org/bluez/23550/hci0 
D/BluetoothService(1304): updateDeviceServiceChannelCache(0C:DF:A4:78:99:50) 
I/ActivityManager(1304): Displayed com.googlecode.android_scripting/.activity.BluetoothDeviceList: +449ms (total +519ms) 
D/BluetoothService(1304): uuid(system): 00001105-0000-1000-8000-00805f9b34fb 3 
V/BluetoothEventRedirector(1862): Received android.bluetooth.device.action.FOUND 
D/wpa_supplicant(19159): CMD: DRIVER RSSI-APPROX 
D/wpa_supplicant(19159): wpa_driver_tista_driver_cmd RSSI-APPROX 
D/wpa_supplicant(19159): rssi-approx command 
D/wpa_supplicant(19159): CMD: DRIVER LINKSPEED 
D/wpa_supplicant(19159): wpa_driver_tista_driver_cmd LINKSPEED 
D/wpa_supplicant(19159): Link Speed command 
D/wpa_supplicant(19159): buf LinkSpeed 54 
E/BluetoothEventLoop.cpp(1304): event_filter: Received signal org.bluez.Adapter:PropertyChanged from /org/bluez/23550/hci0 
E/BluetoothService.cpp(1304): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) 
V/BluetoothEventRedirector(1862): Received android.bluetooth.adapter.action.DISCOVERY_FINISHED 
D/sl4a.ConsoleActivity$1:145(27913): Connected to TerminalManager and found bridges.size=1 
I/HK/LatinKeyboardBaseView(1385): closing [email protected] 
D/sl4a.ConsoleActivity:761(27913): onResume called 
E/BluetoothEventLoop.cpp(1304): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/23550/hci0/dev_0C_DF_A4_78_99_50 
D/BluetoothService(1304): updateDeviceServiceChannelCache(0C:DF:A4:78:99:50) 
D/BluetoothService(1304): uuid(system): 00001105-0000-1000-8000-00805f9b34fb 3 
D/BluetoothService(1304): uuid(application): 457807c0-4897-11df-9879-0800200c9a66 13 
D/BluetoothService(1304): Making callback for 457807c0-4897-11df-9879-0800200c9a66 with result 13 
V/BluetoothEventRedirector(1862): Received android.bleutooth.device.action.UUID 
E/sl4a.JsonRpcServer:101(27913): Invocation error. 
E/sl4a.JsonRpcServer:101(27913): java.io.IOException: Connection refused 
E/sl4a.JsonRpcServer:101(27913): at android.bluetooth.BluetoothSocket.connectNative(Native Method) 
E/sl4a.JsonRpcServer:101(27913): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:204) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.facade.BluetoothFacade.bluetoothConnect(BluetoothFacade.java:158) 
E/sl4a.JsonRpcServer:101(27913): at java.lang.reflect.Method.invokeNative(Native Method) 
E/sl4a.JsonRpcServer:101(27913): at java.lang.reflect.Method.invoke(Method.java:507) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.jsonrpc.RpcReceiverManager.invoke(RpcReceiverManager.java:87) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.facade.FacadeManager.invoke(FacadeManager.java:58) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.rpc.MethodDescriptor.invoke(MethodDescriptor.java:109) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.jsonrpc.JsonRpcServer.handleConnection(JsonRpcServer.java:99) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.SimpleServer$ConnectionThread.run(SimpleServer.java:91) 
V/sl4a.JsonRpcServer:117(27913): Sent: {"error":"java.io.IOException: Connection refused","id":7,"result":null} 
V/sl4a.JsonRpcServer:74(27913): Received: {"params": [], "id": 8, "method": "bluetoothReadLine"} 
E/sl4a.JsonRpcServer:101(27913): Invocation error. 
E/sl4a.JsonRpcServer:101(27913): java.io.IOException: Bluetooth not ready for this connID. 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.facade.BluetoothFacade.getConnection(BluetoothFacade.java:95) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.facade.BluetoothFacade.bluetoothReadLine(BluetoothFacade.java:231) 
E/sl4a.JsonRpcServer:101(27913): at java.lang.reflect.Method.invokeNative(Native Method) 
E/sl4a.JsonRpcServer:101(27913): at java.lang.reflect.Method.invoke(Method.java:507) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.jsonrpc.RpcReceiverManager.invoke(RpcReceiverManager.java:87) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.facade.FacadeManager.invoke(FacadeManager.java:58) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.rpc.MethodDescriptor.invoke(MethodDescriptor.java:109) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.jsonrpc.JsonRpcServer.handleConnection(JsonRpcServer.java:99) 
E/sl4a.JsonRpcServer:101(27913): at com.googlecode.android_scripting.SimpleServer$ConnectionThread.run(SimpleServer.java:91) 
V/sl4a.JsonRpcServer:117(27913): Sent: {"error":"java.io.IOException: Bluetooth not ready for this connID.","id":8,"result":null} 
V/sl4a.JsonRpcServer:74(27913): Received: {"params": ["Chat Received", null], "id": 9, "method": "dialogCreateAlert"} 
V/sl4a.JsonRpcServer:117(27913): Sent: {"error":null,"id":9,"result":null} 
V/sl4a.JsonRpcServer:74(27913): Received: {"params": ["Ok"], "id": 10, "method": "dialogSetPositiveButtonText"} 
V/sl4a.JsonRpcServer:117(27913): Sent: {"error":null,"id":10,"result":null} 
V/sl4a.JsonRpcServer:74(27913): Received: {"params": [], "id": 11, "method": "dialogShow"} 
I/ActivityManager(1304): Starting: Intent { flg=0x18000000 cmp=com.googlecode.android_scripting/.activity.FutureActivity (has extras) } from pid 27913 
D/sl4a.ConsoleActivity:746(27913): onPause called 

Modifier 13/09/2012 09:55: J'ai essayé Bluetooth Chat App (BILL RAY) du marché et permet mes deux téléphones pour discuter, je peux me connecter de chaque côté: le problème est possible de résoudre en Java au moins. L'exemple bluetooth_chat.py ne fonctionne toujours pas.

Modifier 10h45: J'ai essayé de BeanShell encore en SL4A avec lui même problème, fonctionne sur mon S2 et échoue sur mon Winmate:

Code

:

source("/sdcard/com.googlecode.bshforandroid/extras/bsh/android.bsh"); 
droid = Android(); 
droid.call("makeToast", "Hello, Android!"); 
address = "00:12:F3:11:DC:E5"; 
uuid = "00001101-0000-1000-8000-00805F9B34FB"; 
droid.call("toggleBluetoothState","True"); 
droid.call("bluetoothConnect",uuid, address); 
droid.call("makeToast", "Bye, Android!"); 

logcat est similaire:

I/ActivityManager(1305): Starting: Intent { act=android.bluetooth.adapter.action.REQUEST_ENABLE cmp=com.android.settings/.bluetooth.RequestPermissionActivity } from pid 7364 
D/dalvikvm(7364): GC_CONCURRENT freed 1075K, 49% free 3716K/7239K, external 4198K/5242K, paused 2ms+14ms 
V/sl4a.JsonRpcServer:117(7364): Sent: {"error":null,"id":0,"result":true} 
I/HK/LatinKeyboardBaseView(1385): closing [email protected] 
V/sl4a.JsonRpcServer:74(7364): Received: {"id":0,"method":"bluetoothConnect","params":["00001101-0000-1000-8000-00805F9B34FB","00:12:F3:11:DC:E5"]} 
E/BluetoothService.cpp(1305): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) 
I/ActivityManager(1305): Displayed com.googlecode.android_scripting/.activity.FutureActivity: +223ms 
I/HK/LatinKeyboardBaseView(1385): closing [email protected] 
D/sl4a.ConsoleActivity:761(7364): onResume called 
E/BluetoothEventLoop.cpp(1305): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/1804/hci0/dev_00_12_F3_11_DC_E5 
I/ActivityManager(1305): Start proc com.google.android.carhome for broadcast com.google.android.carhome/.receiver.BluetoothLaunchReceiver: pid=7876 uid=10020 gids={3002, 3001} 
I/HK/LatinKeyboardBaseView(1385): closing [email protected] 
I/ActivityThread(7876): Pub com.google.android.carhome.config: com.google.android.carhome.CarHomeProvider 
D/BluetoothService(1305): updateDeviceServiceChannelCache(00:12:F3:11:DC:E5) 
D/BluetoothService(1305): uuid(application): 00001101-0000-1000-8000-00805f9b34fb 1 
D/BluetoothService(1305): Making callback for 00001101-0000-1000-8000-00805f9b34fb with result 1 
D/dalvikvm(7364): GC_EXTERNAL_ALLOC freed 50K, 49% free 3698K/7239K, external 4198K/5242K, paused 131ms 
V/BluetoothEventRedirector(7681): Received android.bleutooth.device.action.UUID 
I/BluetoothEventLoop.cpp(1305): agent_event_filter: Received method org.bluez.Agent:OutOfBandAvailable 
I/sl4a.TerminalBridge:540(7364): parentChanged() now width=133, height=34 
E/sl4a.JsonRpcServer:101(7364): Invocation error. 
E/sl4a.JsonRpcServer:101(7364): java.io.IOException: Connection refused 
E/sl4a.JsonRpcServer:101(7364): at android.bluetooth.BluetoothSocket.connectNative(Native Method) 
E/sl4a.JsonRpcServer:101(7364): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:204) 
E/sl4a.JsonRpcServer:101(7364): at com.googlecode.android_scripting.facade.BluetoothFacade.bluetoothConnect(BluetoothFacade.java:158) 
E/sl4a.JsonRpcServer:101(7364): at java.lang.reflect.Method.invokeNative(Native Method) 
E/sl4a.JsonRpcServer:101(7364): at java.lang.reflect.Method.invoke(Method.java:507) 
E/sl4a.JsonRpcServer:101(7364): at com.googlecode.android_scripting.jsonrpc.RpcReceiverManager.invoke(RpcReceiverManager.java:87) 
E/sl4a.JsonRpcServer:101(7364): at com.googlecode.android_scripting.facade.FacadeManager.invoke(FacadeManager.java:58) 
E/sl4a.JsonRpcServer:101(7364): at com.googlecode.android_scripting.rpc.MethodDescriptor.invoke(MethodDescriptor.java:109) 
E/sl4a.JsonRpcServer:101(7364): at com.googlecode.android_scripting.jsonrpc.JsonRpcServer.handleConnection(JsonRpcServer.java:99) 
E/sl4a.JsonRpcServer:101(7364): at com.googlecode.android_scripting.SimpleServer$ConnectionThread.run(SimpleServer.java:91) 
V/sl4a.JsonRpcServer:117(7364): Sent: {"error":"java.io.IOException: Connection refused","id":0,"result":null} 
+0

Le WinMate défectueux qui exécute Android ICS par hasard? 4.0.x je pense. – Radu

+0

@Cyrill Holweck Des mises à jour? – Radu

Répondre

1

Les Python4Android project ont une copie de PyBluez compilée pour ARM, ce qui peut être utile ici.

Ce n'est pas pur Python, mais c'est trivial à installer; il vous suffit de télécharger une copie du fichier oeuf à votre droïde, ouvrez l'application Python4Android, appuyez sur Importer des modules et sélectionnez le fichier oeuf.

J'ai déjà utilisé ce logiciel sans problème.

  • pybluez projet [visit]
  • projet Python4Android [visit]
  • PY4A précompilés Forfaits Liste, y compris pybluez [visit]
  • pybluez-0,19-py2.6-linux-armv.egg [download ]
Questions connexes