944,082 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1400
  • Java RSS
Oct 24th, 2009
0

JavaME bluetooth:javax.bluetooth.BluetoothStateException: too mach concurent requests

Expand Post »
I'm developing a bluetooth messaging application which sends text messages between devices.
My problem is when I connect more than 2 devices. After sending some data between them (let us say 3 devices) I get this exception:

javax.bluetooth.BluetoothStateException: too mach concurent requests
at com.sun.kvem.jsr082.bluetooth.ServiceSearcher.start(ServiceSearcher.java:67)
at com.sun.kvem.jsr082.bluetooth.DiscoveryAgentImpl.searchServices(DiscoveryAgentImpl.java:226)
at javax.bluetooth.DiscoveryAgent.searchServices(DiscoveryAgent.java:259)
at BSearch.deviceDiscovered(BSearch.java:78)
at com.sun.kvem.jsr082.impl.bluetooth.BTDeviceDiscoverer.run(+268)
requests.

I get it at device inquiry... this means when the application tries to detect other devices.
This is the function that starts the inquiry:
Java Syntax (Toggle Plain Text)
  1. public void startSearching() throws BluetoothStateException{
  2. System.out.println("before inquiry");
  3. LocalDevice localD = LocalDevice.getLocalDevice();
  4. try
  5. {
  6. DiscoveryAgent discoveryA = localD.getDiscoveryAgent();
  7. discoveryA.startInquiry(DiscoveryAgent.GIAC,this);//////
  8. }catch(BluetoothStateException bse){
  9. }
  10. isSearching = true;
  11. System.out.println("dupa inquiry -- waiting");
  12. }
This is the function that restarts the inquiry after 4 seconds:
Java Syntax (Toggle Plain Text)
  1. public void serviceSearchCompleted(int transID, int respCode) {////////////////////////////////////////
  2. pendingSearches--;
  3. if(!isSearching && pendingSearches==0)
  4. refreshServList();
  5.  
  6.  
  7. try { Thread.sleep(4000); }
  8. catch (InterruptedException ie) {}
  9.  
  10. if (isRunning == true)
  11. try {
  12. System.out.println("CONTINUAM CU CAUTAREA");
  13. startSearching();//////
  14. } catch (BluetoothStateException ex) {
  15. ex.printStackTrace();
  16. }
  17. }
The class implemets a DiscoveryListener and when I call 'startSearching()' the thread is stoped then started again.

My application searches for devices every 4 seconds (in a separate thread) and after that updates a List with the names of available devices in the area.

Please someone help on this exception... at least give me a good hint because I couldn't find the solution anywhere. Thanks.
Similar Threads
Reputation Points: 11
Solved Threads: 7
Posting Whiz in Training
Clawsy is offline Offline
225 posts
since Feb 2008
Oct 25th, 2009
-1
Re: JavaME bluetooth:javax.bluetooth.BluetoothStateException: too mach concurent requests
Switch of all devices and switch on again.
Reputation Points: 769
Solved Threads: 128
Banned
ithelp is offline Offline
1,910 posts
since May 2006
Oct 25th, 2009
0
Re: JavaME bluetooth:javax.bluetooth.BluetoothStateException: too mach concurent requests
No I cannot because that means I interrupt all users and when they join again.... the same thing, that exception. Users must stay connected. I use a refresh function for connection which works nice and I didn't got any exception but it's not detecting devices continously, it's only when I click refresh button.
Reputation Points: 11
Solved Threads: 7
Posting Whiz in Training
Clawsy is offline Offline
225 posts
since Feb 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Credit Card
Next Thread in Java Forum Timeline: Help with java program please!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC