Open CristinaMarc opened 14 years ago
Hi, before starting the client you have to start the server :) The demo application (actually, as any other bluetooth app that you want to test with the bt-emulator) requires (at least) 2 emulators running, one for the server and the other for the client.
The demo app is very shitty, and if I remember well, it doesn't even check if you have selected a "server" device, so my guess is that it crashes because of a null pointer exception.
Anyway, the "right" sequence of actions to take to run the example is: 1) file the bt-emulator server 2) fire 2 emulators (this requires 2 android virtual devices!) 3) on one of the devices, click on "start server" 4) on the other, click on "discovery", the "server" device should appear, click on it and then click "start client"
As for the BluetoothChat, I guess it's the same issue, but please feel free to post the stack trace (as saying "there is an exception" is not really helping that much ;) ) And that's it, I hope this will help!
hi again, first of all thank you for trying to help.
Server started on port 8199 ADB command: C:\android-sdk-windows\tools\adb.exe press any key to exit accepting a new connection from /127.0.0.1 new string is : '3' new string is : '3]' creating command MODIFYSERVICE read parameter: type=added read parameter: tcp.port=8127 read parameter: service.uuid=419bbc68-c365-4c5e-8793-5ebff85b908c read parameter: bt.address=37:60:39:FE:DD:ED java.lang.NullPointerException at dk.itu.btemu.cmd.ModifyService.work(ModifyService.java:28) at dk.itu.btemu.cmd.BaseCommand.run(BaseCommand.java:47) at java.lang.Thread.run(Unknown Source) accepting a new connection from /127.0.0.1 new string is : '2' new string is : '2]' creating command DISCOVERY read parameter: bt.address=39:81:50:EE:BF:CE
this is the stack trace I got from the following operations: start server start emulator 1 start emulator 2 press start server on emulator 1 press discovery on emulator 2
when I press start server it gives the exceptions and when I press discovery it doesn't show anything.
Uops, I forgot to push the updated apk :) should be fixed now, so please remove the installed one and install the new version!
hi again,
yesterday I tried to do all what you have said to me and if I use only your application it works.I am able to start an emulator to be the server and the other to be the client. But in case I want to use your application with the BluetoothChat it doesn't work. I run that and if I try to find some devices,I can wait forever because is not finding anything and finally the application shows an "Applications not responding" dialog. maybe you have some ideas or something.
Thanks a lot for your help!
Hi, can you post the stacktrace of the emulator? Sincerely, I haven't tested the BTChat application (and until next week I'll be quite busy), but maybe I'll be able to understand the issue a little bit better! Thank you!
hi here is the stacktrace
08-06 09:13:57.077: ERROR/BTEMULATOR(282): cannot join
08-06 09:13:57.077: ERROR/BTEMULATOR(282): java.net.SocketException: The operation timed out
08-06 09:13:57.077: ERROR/BTEMULATOR(282): at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(Native Method)
08-06 09:13:57.077: ERROR/BTEMULATOR(282): at org.apache.harmony.luni.platform.OSNetworkSystem.connect(OSNetworkSystem.java:115)
08-06 09:13:57.077: ERROR/BTEMULATOR(282): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:244)
08-06 09:13:57.077: ERROR/BTEMULATOR(282): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:219)
08-06 09:13:57.077: ERROR/BTEMULATOR(282): at java.net.Socket.startupSocket(Socket.java:781)
08-06 09:13:57.077: ERROR/BTEMULATOR(282): at java.net.Socket.tryAllAddresses(Socket.java:194)
08-06 09:13:57.077: ERROR/BTEMULATOR(282): at java.net.Socket.
I hope it helps. I will wait for your answer,when you have time.
Thanks
Well, basically its telling that it couldn't join the BT emulator server, maybe the problem is there: when you start the server, it sends in the standard output some logs, can you post them also? --it might be that there is an exception also there :D
hi the server does not throw any exception,but I will put here the output for the server. I hope it helps.
Server started on port 8199 ADB command: adb.exe press any key to exit accepting a new connection from /127.0.0.1 new string is : '0' new string is : '0]' creating command JOIN read parameter: tcp.address=10.0.2.2 read parameter: device.name=local read parameter: bt.address=79:37:73:BF:CC:ED running checker... getting device list... trying to parse: List of devices attached trying to parse: emulator-5554 device added device running on port: 5554 trying to parse: search for bt addresses... got bluetooth address: 79:37:73:BF:CC:ED accepting a new connection from /127.0.0.1 new string is : '3' new string is : '3]' creating command MODIFYSERVICE read parameter: type=added read parameter: tcp.port=8124 read parameter: service.uuid=fa87c0d0-afac-11de-8a39-0800200c9a66 read parameter: bt.address=79:37:73:BF:CC:ED creating network forwarding from 8124 to 8124 forward process exit value: 0 accepting a new connection from /127.0.0.1 new string is : '0' new string is : '0]' creating command JOIN read parameter: tcp.address=10.0.2.2 read parameter: device.name=local read parameter: bt.address=57:84:38:AC:EE:FE running checker... getting device list... trying to parse: List of devices attached trying to parse: emulator-5554 device added device running on port: 5554 trying to parse: emulator-5556 device added device running on port: 5556 trying to parse: search for bt addresses... got bluetooth address: 79:37:73:BF:CC:ED got bluetooth address: 57:84:38:AC:EE:FE accepting a new connection from /127.0.0.1 new string is : '3' new string is : '3]' creating command MODIFYSERVICE read parameter: type=added read parameter: tcp.port=8124 read parameter: service.uuid=fa87c0d0-afac-11de-8a39-0800200c9a66 read parameter: bt.address=57:84:38:AC:EE:FE creating network forwarding from 8124 to 8125 forward process exit value: 0 accepting a new connection from /127.0.0.1 new string is : '2' new string is : '2]' creating command DISCOVERY read parameter: bt.address=79:37:73:BF:CC:ED writing: 57:84:38:AC:EE:FE--10.0.2.2--emulator-5556--fa87c0d0-afac-11de-8a39-0800200c9a66<>8125
accepting a new connection from /127.0.0.1 new string is : '2' new string is : '2]' creating command DISCOVERY read parameter: bt.address=57:84:38:AC:EE:FE writing: 79:37:73:BF:CC:ED--10.0.2.2--emulator-5554--fa87c0d0-afac-11de-8a39-0800200c9a66<>8124
accepting a new connection from /127.0.0.1 new string is : '0' new string is : '0]' creating command JOIN read parameter: tcp.address=10.0.2.2 read parameter: device.name=emulator-5554 read parameter: bt.address=79:37:73:BF:CC:ED running checker... getting device list... trying to parse: List of devices attached trying to parse: emulator-5554 device added device running on port: 5554 trying to parse: emulator-5556 device added device running on port: 5556 trying to parse: search for bt addresses... accepting a new connection from /127.0.0.1 new string is : '0' new string is : '0]' creating command JOIN got bluetooth address: 79:37:73:BF:CC:ED read parameter: tcp.address=10.0.2.2 read parameter: device.name=emulator-5556 read parameter: bt.address=57:84:38:AC:EE:FE running checker... getting device list... trying to parse: List of devices attached trying to parse: emulator-5554 device added device running on port: 5554 trying to parse: emulator-5556 device added device running on port: 5556 trying to parse: search for bt addresses... got bluetooth address: 57:84:38:AC:EE:FE got bluetooth address: 79:37:73:BF:CC:ED got bluetooth address: 57:84:38:AC:EE:FE accepting a new connection from /127.0.0.1 new string is : '3' new string is : '3]' creating command MODIFYSERVICE read parameter: type=added read parameter: tcp.port=8124 read parameter: service.uuid=fa87c0d0-afac-11de-8a39-0800200c9a66 read parameter: bt.address=79:37:73:BF:CC:ED creating network forwarding from 8124 to 8126 forward process exit value: 0 accepting a new connection from /127.0.0.1 new string is : '3' new string is : '3]' creating command MODIFYSERVICE read parameter: type=added read parameter: tcp.port=8124 read parameter: service.uuid=fa87c0d0-afac-11de-8a39-0800200c9a66 read parameter: bt.address=57:84:38:AC:EE:FE creating network forwarding from 8124 to 8127 forward process exit value: 0 accepting a new connection from /127.0.0.1 new string is : '2' new string is : '2]' creating command DISCOVERY read parameter: bt.address=57:84:38:AC:EE:FE writing: 79:37:73:BF:CC:ED--10.0.2.2--emulator-5554--fa87c0d0-afac-11de-8a39-0800200c9a66<>8126
Thanks
hi
it's me again.have you tried to test your application using BluetoothChat or another application?because when I tested it,it's didn't worked.And if is working I wanna know what I have done wrong,because I can't make the communications between the 2 emulators. If you have some free time,please help me with this,because I really need a way to test some applications which are based on bluetooth communication. Thank's a lot. Have a nice day!
I haven't ported the BluetoothChat, I indeed used the same code for a simpler application (the test application that comes with the emulator application). In these days I'm afraid that I've no time left for trying this, I'll try to port it, but my best guess is at least the next week :/
hy I tried again to test the bluetooth chat application,to see if it works on the emulator,but I had no success. First I run the server,then I changed in the bluetooth chat the imports with the one from your project. Next I run the bluetooth chat on two emulators but they can't find the other emulator,when I press search,it searches forever.
and another question.which test application did you used to test it?beacause the bluetooth chat comes with the emulator,did you used another one??
thanks,I hope you will have time to answer me
Does anyone got the BluetoothChat working on the emulator ? It seems that it can find other working copy but can't pair with it...
Hi everybody, sorry for the late reply, I've been quite busy until now. Anyway, I realized that the jar file (the btsim.jar one) was out of sync with the server version. I then ported the BluetoothChat sample application and verified that it is working, and it did. The "forever discovery" behavior was due to an arrayoutoufboundexception in the discovery-message parsing code. Updating the jar library basically did the trick, and now there are no exceptions there
hy I tried to see if it's the bluetooth it's working.I changed in the BluetoothChat application the imports,then I added that call in onCreate method and added internet permission in the manifest file.And I added the btsim.jat to the path of the project. when I run it, I start the server application,then I start 2 instances of the emulator.And it's ok,is working. But then,I make one of the emulator discovarable and on the other one, I press "connect a device","search for devices" and then I choose the device that was found.Next on the top right of the screen it appears "connecting...",but it doesn't connect to the other emulator,it remains like this a few minutes and then the applications is closing. Please tell me if I done something wrong,because I really need to make this applications working. Thank's a lot.
That seems quite a lot like what I did to test the bluetooth chat. Can you check in the logcat if there are exceptions of any kind?
10-21 09:57:29.228: ERROR/BluetoothChatService(419): accept() failed 10-21 09:57:29.228: ERROR/BluetoothChatService(419): java.net.SocketException: Interrupted system call 10-21 09:57:29.228: ERROR/BluetoothChatService(419): at org.apache.harmony.luni.platform.OSNetworkSystem.acceptSocketImpl(Native Method) 10-21 09:57:29.228: ERROR/BluetoothChatService(419): at org.apache.harmony.luni.platform.OSNetworkSystem.accept(OSNetworkSystem.java:69) 10-21 09:57:29.228: ERROR/BluetoothChatService(419): at org.apache.harmony.luni.net.PlainSocketImpl.accept(PlainSocketImpl.java:126) 10-21 09:57:29.228: ERROR/BluetoothChatService(419): at java.net.ServerSocket.implAccept(ServerSocket.java:281) 10-21 09:57:29.228: ERROR/BluetoothChatService(419): at java.net.ServerSocket.accept(ServerSocket.java:165) 10-21 09:57:29.228: ERROR/BluetoothChatService(419): at dk.itu.android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:65) 10-21 09:57:29.228: ERROR/BluetoothChatService(419): at com.example.android.BluetoothChat.BluetoothChatService$AcceptThread.run(BluetoothChatService.java:257)
this is what is says in logat.And it seems that it can't accept the connection.
pretty weird, can you tell me which platform are you using (windows,linux,mac) ? and the logs of the server? actually, you could do one more test: fire up just one emulator with the bluetooth chat application, then enable the bluetooth or whatever is required on the emulator to start the bluetooth service. Check the logs of the bluetooth server, it should displays that the device has joined and that a service has been added to that device; search for something like "creating network forwarding from
Another possibility is that the port forwarding simply doesn't work, in that case mmhh..I guess I'll have to put some more log in that code, what it does is simply to construct a call to the "adb" command to perform the forward, but I'm not taking the output of that process.
Hi Cheng..I am an engineering student and I am developing a bluetooth based multiplayer Tic-Tac-Toe game for android...I have to run the application on emulator...can u help me with it??
Hi , I'm Android beginner and faced problems while executing that simulator , and my project based on bluetoothChat . I tried many time to run the simulator but not success. Can any one run Bluetooth chat sample with that simulator post detailed steps plz :( thanks.
Hello everybody, I have got the same problem as ChristinaMarc. I 'd like to use the Android bluetooth Simulator. I 'd like to install and run the application.
First, I installed the apk ( for in both Android emulators. When I started the server, I got this message
Server started on port 8199 ADB command: adb press any key to exit
Then, When I started the first device emulator, I got this error message (null pointeur exception): accepting a new connection from /127.0.0.1 new string is : '3' new string is : '3]' creating command MODIFYSERVICE read parameter: type=added read parameter: tcp.port=8124 read parameter: service.uuid=419bbc68-c365-4c5e-8793-5ebff85b908c read parameter: bt.address=32:52:93:EA:EA:AE java.lang.NullPointerException at dk.itu.btemu.cmd.ModifyService.work(ModifyService.java:28) at dk.itu.btemu.cmd.BaseCommand.run(BaseCommand.java:47) at java.lang.Thread.run(Thread.java:636)
I saw cheng81 told that the updated apk must be used instead. So, I uninstalled the old apk, I compiled the last source code, but I got compilation error (the compilator do not accept the TestCase class in a file so I imported Junit package , which is proposed by eclipse) then I installed the apk in both device emulator, then when I ran the application, I got the error message "the application has stopped unexpectedly".
What should I do ?
Thanks for your help.
The error is the same as the other? What is the stack trace in the logcat?
Issues go stale after 60d of inactivity.
hi, I am a beginner in android and I tried to use your bluetooth simulator. If I run only your application on the emulator, when I press Start Client it crahes(says that the application has stopped unexpectedly) I also tried to run the sample application BluetoothChat and made all the required changes. If I try to scan for another device, it doesn't find anything and freezes there. If I click on "No Devices have been paired" the application crashes and I get the same message like when I clicked on Start Client. Please reply with advices and suggestions ASAP!!
Thanks a lot !!!