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

Reply

Join Date: Feb 2008
Posts: 91
Reputation: Clawsy is an unknown quantity at this point 
Solved Threads: 4
Clawsy Clawsy is offline Offline
Junior Poster in Training

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

 
0
  #1
34 Days Ago
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:
  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:
  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.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,826
Reputation: ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all 
Solved Threads: 117
ithelp's Avatar
ithelp ithelp is offline Offline
Posting Virtuoso
Join Date: Feb 2008
Posts: 91
Reputation: Clawsy is an unknown quantity at this point 
Solved Threads: 4
Clawsy Clawsy is offline Offline
Junior Poster in Training
 
0
  #3
34 Days Ago
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.
Reply With Quote Quick reply to this message  
Reply

Tags
bluetooth, exception, javame

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC