We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,055 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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

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:

public void startSearching() throws BluetoothStateException{
     System.out.println("before inquiry");
      LocalDevice localD = LocalDevice.getLocalDevice();
      try
      {
      DiscoveryAgent discoveryA = localD.getDiscoveryAgent();
      discoveryA.startInquiry(DiscoveryAgent.GIAC,this);//////
      }catch(BluetoothStateException bse){         
           }
      isSearching = true;
      System.out.println("dupa inquiry -- waiting");
    }

This is the function that restarts the inquiry after 4 seconds:

public void serviceSearchCompleted(int transID, int respCode) {////////////////////////////////////////
        pendingSearches--;
        if(!isSearching && pendingSearches==0)
            refreshServList();
       

         try { Thread.sleep(4000); }
         catch (InterruptedException ie) {}

         if (isRunning == true)
                  try {
                      System.out.println("CONTINUAM CU CAUTAREA");
                        startSearching();//////
                       } catch (BluetoothStateException ex) {
                       ex.printStackTrace();
                      }
    }

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.

2
Contributors
2
Replies
13 Hours
Discussion Span
3 Years Ago
Last Updated
3
Views
Clawsy
Posting Whiz in Training
225 posts since Feb 2008
Reputation Points: 11
Solved Threads: 7
Skill Endorsements: 0

Switch of all devices and switch on again.

ithelp
Nearly a Posting Maven
Banned
2,230 posts since May 2006
Reputation Points: 769
Solved Threads: 128
Skill Endorsements: 0

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.

Clawsy
Posting Whiz in Training
225 posts since Feb 2008
Reputation Points: 11
Solved Threads: 7
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0997 seconds using 2.69MB