Android bluetooth SDP does not recognize the service advertised in JAVAME

I am developing a bluetooth application for my MSc. Complete the project. It includes a server implemented in JAVA ME and a client written in Android.

The problem is that Android SDP does not seem to be able to recognize the ServiceRecord of my JAVA ME server.

If I use the techniques BluetoothDevice.getUuids()and BluetoothDevice.fetchUuidsWithSdp()to my client, they return set UUID, but my service UUID nowhere among them, so I can not connect to it.

This is the code for an example JAVAME server:

/*IMPORTS*/


public class StackOverFlowServer extends MIDlet {
    Display mDisplay;
    Form mForm;
    LocalDevice local;
    StreamConnectionNotifier server;
    ServiceRecord sr;
    String conURL;
    StreamConnection conn;
    public StackOverFlowServer() {
        mDisplay = Display.getDisplay(this);
        mDisplay.setCurrent(mForm);
        mForm = new Form(null);
        conURL = "btspp://localhost:68EE141812D211D78EED00B0D03D76EC;"
                + "authenticate=false;encrypt=false;name=MySampleApp";
    }

protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
    // TODO Auto-generated method stub

}

protected void pauseApp() {
    // TODO Auto-generated method stub

}

protected void startApp() throws MIDletStateChangeException {
    try {
        local = LocalDevice.getLocalDevice();
    } catch (BluetoothStateException e) {
        // Error handling code here
    }
    /*
    * When creating a StreamConnectionNotifier a service record
    * will automatically be created for us, describing the new
    * service. The service will have the Serial Port (0x1101)
    * value in the ServiceClassIDList (id 0x0001) attribute. The
    * service record will also have both the L2CAP (0x0100) and
    * RFCOMM (0x0003) values in the ProtocolDescriptorList (id
    * 0x0004) attribute. Other mandatory attributes will be set
    * automatically by the JABWT implementation. The optional
    * ServiceName (id 0x100) attribute will be set to the name
    * parameter, "BTDemoApp" in this case.
    */
    try {
        server = (StreamConnectionNotifier)
                Connector.open(conURL);
    } catch (IOException e1) {
        // Error handling code here
    }
    /*
    * The automatically created service record can be obtained
    * from the LocalDevice object, using the reference to the
    * StreamConnectionNotifier.
    */
    try {
        sr = local.getRecord(server);
    }
    catch (IllegalArgumentException iae){
        // Error handling code here
    }
    /*
    * We create a new DataElement and set its content correctly.
    */
    DataElement elm = null;
    /*
    * Setting public browse root in the browsegrouplist
    * attribute. The BrowseGroupList (id 0x0005) attribute
    * contains a DataElement sequence, which in turn contains
    * DataElements with UUIDs. The DataElement sequence must be
    * created before we can add DataElements to it.
    */
    elm = new DataElement(DataElement.DATSEQ);
    elm.addElement(new DataElement(
    DataElement.UUID,new UUID(0x1002)));
    /*
    * The DataElement is now prepared. It must be added to the
    * appropriate attribute ID, in this case the
    * BrowseGroupList.
    */
    sr.setAttributeValue(0x0005,elm);
    /*
    * Finally, the service record must be updated in our
    * LocalDevice.
    */
    try {
        local.updateRecord(sr);
    } catch (ServiceRegistrationException e3) {
        // Error handling code here
    }
    try {
    conn = server.acceptAndOpen();
    } catch (ServiceRegistrationException sre){
        // Error handling code here
    } catch (IOException e2) {
        // Error handling code here
    }
    /*
    * At this point a client is connected. input and output
    * streams can be obtained from the conn object,
    * communication can begin.
    */
}

}

And this is part of the Android client:

package com.exampleproyect.stackoverflowclient;

import java.lang.reflect.InvocationTargetException;
import java.util.UUID;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.ParcelUuid;
import android.os.Parcelable;

public class StackOverFlowClientActivity extends Activity {
BluetoothAdapter mBluetoothAdapter;
BluetoothDevice C702;
BroadcastReceiver mReceiver;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    C702 = mBluetoothAdapter.getRemoteDevice("00:23:F1:27:16:DA");
    C702.fetchUuidsWithSdp();
    mReceiver = new BroadcastReceiver() {
      @Override
      public void onReceive(Context arg0, Intent intent) {
          String action = intent.getAction();
          if (BluetoothDevice.ACTION_UUID.equals(action)){
              Parcelable[] uuidExtra =                    intent.getParcelableArrayExtra("android.bluetooth.device.extra.UUID");
              /*uuidExtra should contain my service UUID among his files, but it doesn't!!*/
          }
      }
  };
  // Register the BroadcastReceiver
  IntentFilter filter1 = new IntentFilter(BluetoothDevice.ACTION_UUID);
  registerReceiver(mReceiver, filter1); // Don't forget to unregister during onDestroy
}

}

What bothers me the most is that my computer can correctly expose my JAVAME server: enter image description here

?:( Bluetooth- Bluetooth , JAVAME, Android ? Android Bluetooth JAVAME?

, StackOverFlow, .: (

Sony Ericsson C702 (Java Platform 8) . Samsung Galaxy S (ICS 4.0.3, ICSSGS RC4.2)


EDIT1

OK.

, .

, JAVAME UUID (): "68EE1418-12D2-11D7-8EED-00B0D03D76EC", , :

        conURL = "btspp://localhost:68EE141812D211D78EED00B0D03D76EC;"
                + "authenticate=false;encrypt=false;name=MySampleApp";
        server = (StreamConnectionNotifier)
                Connector.open(conURL);

ServiceClassIDList UUID "00001101-0000-1000-8000-00805F9B34FB" :

enter image description here

, Android BluetoothDevice.fetchUuidsWithSdp(); , UUID "00001101-0000-1000-8000-00805F9B34FB" , UUID "68EE1418-12D2-11D7-8EED-00B0D03D76EC", Serial Port .

Medieval Bluetooth Network Scanner, , "00001101-0000-1000-8000-00805F9B34FB" :

enter image description here

, UUID, JAVAME ?

, , !

EDIT2

, Sony Ericcson. -, UUID {0x1101} UUID, Samsung Nokia, , UUID . Android, , 0x001 , , , .

, :

- API Android servicerecord ServiceClassID (0x001)?

servicerecord, Discovery Services (SDDB) "acceptAndOpen" -JAVAME-? - LocalDevice.updateRecord , SDDB, , .

+5

All Articles