×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    2

    Question My cellphone can't find a service in a bluetooth module

    Hello everybody!

    I have a Bluetooth Serial Converter Module that works with a microcontroler. When I connect with a PC (dongle) it works very well. But if I try to connect with a cell (using J2ME), the cellphone find the device but doesn't find the service. Someone knows why this happens?

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    Because your phone (your own code or used implementation) and your remote device has a bug.

    Which UUID are you looking for in your J2ME code and which UUID offers your phone?
    Which attribute(s) are you requesting in your code and why?
    Which platform (S60 or Series 40; which Edition and Feature Pack) do you use for testing?

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    2

    Re: My cellphone can't find a service in a bluetooth module

    traud,

    Here follows the code that I used to test the device search and the service search:

    Code:
    import javax.bluetooth.*;
    import java.io.*;
    import java.util.Vector;
    
    /**
     *
     * <p>Title: ServiceDiscoverer.java</p>
     *
     * <p>Description: A handly utility class used by BluetoothProbeMidlet used
     * to find the Bluetooth services availabe on the Bluetooth devices in the
     * area.</p>
     *
     * <p>Copyright: Copyright (c) 2005</p>
     *
     * <p>By: Bruce Hopkins</p>
     *
     * @version 1.0
     */
    
    
    public class ServiceDiscoverer extends Thread implements DiscoveryListener {
    
    
          UUID[] uuidSet = {new UUID(0x0003) };
    
    
    	int[] attrSet = {0x0100, 0x0003, 0x0004};
    
    	BluetoothProbeMidlet midlet = null;
    	ServiceRecord serviceRecord = null;
    	RemoteDevice remoteDevice = null;
    	String connectionURL = null;
    
            /**
             * A simple constructor
             * @param midlet BluetoothProbeMidlet
             * @param remoteDevice RemoteDevice
             */
            public ServiceDiscoverer(BluetoothProbeMidlet midlet, RemoteDevice remoteDevice) {
    
    		this.midlet = midlet;
    		this.remoteDevice = remoteDevice;
    
    	}
    
            /**
             * ServiceDiscoverer.java extends Thread, so the run method allows the
             * class to run in a separate thread.
             */
            public void run(){
    
    		try {
    			LocalDevice localDevice = LocalDevice.getLocalDevice();
    			DiscoveryAgent discoveryAgent = localDevice.getDiscoveryAgent();
    
    			midlet.updateStatus("\n+ "  + remoteDevice.getFriendlyName(true)  );
    			discoveryAgent.searchServices(attrSet, uuidSet, remoteDevice, this);
    
    		}
    		catch(Exception e) {
    			e.printStackTrace();
    		}
    
    
    	}
    
            /**
             * This method is called when a new service is discovered on a remote
             * Bluetooth device.
             * @param transID int
             * @param servRecord ServiceRecord[]
             */
    
    	public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
    
    		for(int i = 0; i < servRecord.length; i++) {
    
    	            DataElement serviceNameElement = servRecord[i].getAttributeValue(0x0100);
    			String temp_serviceName = (String)serviceNameElement.getValue();
    			String serviceName = temp_serviceName.trim();
    			midlet.updateStatus(" -" + serviceName );
    
    		}
    	}
    
    
            /**
             * This method is called when the service search process is completed for
             * a remote Bluetooth device.
             * @param transID int
             * @param respCode int
             */
    
    	public void serviceSearchCompleted(int transID, int respCode) {
    
    		String searchStatus = null;
    
    		if (respCode == DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE) {
    			midlet.updateStatus("Device not reachable");
    		}
    		else if (respCode == DiscoveryListener.SERVICE_SEARCH_NO_RECORDS) {
    			midlet.updateStatus("Service not available");
    		}
    		else if (respCode == DiscoveryListener.SERVICE_SEARCH_COMPLETED) {
    			//do nothing
    		}
    		else if (respCode == DiscoveryListener.SERVICE_SEARCH_TERMINATED) {
    			midlet.updateStatus("Service search terminated");
    		}
    		else if (respCode == DiscoveryListener.SERVICE_SEARCH_ERROR) {
    			midlet.updateStatus("Service search error");
    		}
    
    
    	}
    
            /**
             * This method is not used, but any implementation of DiscoveryListerer.java
             * must include these methods
             * @param transID int
             * @param servRecord ServiceRecord[]
             */
        public void inquiryCompleted(int discType){}
    
    
        /**
         * This method is not used, but any implementation of DiscoveryListerer.java
         * must include these methods
         * @param transID int
         * @param servRecord ServiceRecord[]
         */
    
        public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod){}
    
    }
    This is only the class that make the service search. I downloaded this program only to test.
    Further, when I run this code, it find the devices and the services from other bluetooth devices (like a dongle), but the module shows no services available.
    I have another doubt: how can I find which UUID offer my cellphone?

Similar Threads

  1. Replies: 4
    Last Post: 2009-07-07, 10:07
  2. How to create a sis using ensymble and Python 1.9.4 ?
    By marcelobarrosalmeida in forum Symbian
    Replies: 10
    Last Post: 2009-05-27, 10:16
  3. Bluetooth device service discovery and "Pairing"
    By blundell in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2008-05-31, 21:47
  4. Carbide.j 1.5 and Netbeans 5.5 beta 2
    By ovjo12 in forum Mobile Java Tools & SDKs
    Replies: 5
    Last Post: 2007-06-11, 05:43
  5. If you cannot find BT service on your phone
    By krampuls in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2007-03-22, 11:42

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×