×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    43

    Question Service Registration question

    Hello

    I'm creating a service (serial port) in a Nokia 6600 phone.

    When I start the applet that starts the service, I can't see the service if I explore the surrounding devices with my PC and search for services in it.

    Using BTbrowser I can see that the service appears to be up.

    However the PC cant see it. The problem is that a external device that must connect (a RFID) with the service seems unable to see it neither, maybe because of the same reason.

    Here is some code

    --------------------------------

    import javax.bluetooth.UUID;
    import javax.microedition.io.*;
    import javax.bluetooth.*;
    import java.io.*;
    import java.util.Enumeration;
    /**
    * @author Sergio
    *
    * Gestor de Servidores Bluetooth
    */
    public class GestorBTServer extends GestorBT implements Runnable {

    private StreamConnectionNotifier conexiones = null;
    private UUID serverUUID = null; //new UUID("102030405060708090A0B0C0D0E0F010", false); just uing this UUID for testing purposes
    private String srvName = "";
    private RFIDParser parser = null;
    private StringBuffer url = null;
    private String data = null;

    private boolean parar = false;

    /**
    * @param name String (service name)
    * @param uuid String con el UUID of service
    * @param a MIDLET that implements the draw() method
    */
    public GestorBTServer(String name,String uuid,Actualizable a) {
    super(a);
    this.srvName = name;
    this.serverUUID = new UUID(uuid,false);
    setVisibilidadOn(); // permitir a otros dispositivos encontrarme si me buscan

    this.url = new StringBuffer("btspp://localhost:"); // construimos la Url
    this.url.append(this.serverUUID.toString());
    this.url.append(";authenticate=true;encrypt=true");
    this.url.append(";name=");
    this.url.append(this.srvName);
    this.parar = false;
    }

    /**
    * Arranca el servicio servidor y lo deja listo para recibir conexiones de clientes
    *
    */
    public void runServer()
    {
    try {
    this.conexiones = (StreamConnectionNotifier) Connector.open(this.url.toString());
    ServiceRecord rec = this.Dispositivo.getRecord( this.conexiones );


    DataElement de1 = new DataElement(DataElement.DATSEQ);
    de1.addElement(new DataElement(DataElement.UUID,new UUID(0x1101)));

    // Attribute 0x0008 -> ServiceAvailability
    // 0xFF -> Disponible
    rec.setAttributeValue(0x0008, new DataElement(DataElement.U_INT_1, 0xFF));

    // BrowseGroupList
    // PublicBrowseGroup
    rec.setAttributeValue(0x0005, new DataElement(DataElement.UUID,new UUID(0x1002)));
    //rec.setAttributeValue(0x0005, new DataElement(DataElement.UUID,new UUID("100200001000800000805F9B34FB",false)));


    // BluetoothProfileDescriptorList (Secuencia: SerialPort, 1)
    de1 = new DataElement(DataElement.DATSEQ);
    de1.addElement(new DataElement(DataElement.UUID,new UUID(0x1101)));
    de1.addElement(new DataElement(DataElement.U_INT_2,0x0004)); //deberia ser 4, como el canal????
    rec.setAttributeValue(0x0009,de1);

    // int SERVICE_TELEPHONY = 0x400000;
    rec.setDeviceServiceClasses(0x400000);

    // Pone en marcha el servidor
    Thread t = new Thread( this );
    t.start();

    } catch(Exception e)
    {
    // de momento no hacer nada
    }
    }

    public void run()
    {
    StreamConnection con = null;
    DataInputStream in;
    DataOutputStream out;
    while (!this.parar)
    {
    try {
    con = this.conexiones.acceptAndOpen(); // esperar y aceptamos una conexión del cliente (bloqueante)
    //RemoteDevice rdev = RemoteDevice.getRemoteDevice(con); // obtener info del cliente

    in = con.openDataInputStream(); // obtenemos el input Stream
    out = con.openDataOutputStream(); // obtenems el output Stream

    this.data = in.readUTF(); // leemos el codigo del RFID
    out.write("[ACK]".getBytes()); // enviamos Acknowledge
    out.flush();
    this.midlet.draw(); // forzar actualizacion de la pantalla del midlet
    con.close();

    } catch(Exception e)
    {
    this.parar = true;
    this.data = e.toString();
    this.midlet.draw();
    }
    }
    }

    /**
    *
    * @return ultima cadena leida o null si no se la recibido nada de los clientes
    */
    public String getData()
    {
    return this.data;
    }
    /**
    *
    */
    public void stop()
    {
    this.parar = true;
    try {
    this.conexiones.close();
    }catch(Exception e)
    {
    //
    }
    }
    }
    --------------------------

    //... main midlet code
    public RFID()
    {
    this.BT = new GestorBTServer("Bluetooth Serial Port\n","102030405060708090A0B0C0D0E0F010",this);
    this.pantalla = Display.getDisplay(this);
    this.mainFrm = new Form("Esperando conexion con RFID");

    this.mainFrm.setCommandListener(this);
    this.infoAlert = new Alert("Información:","",null,AlertType.INFO);
    }

    protected void startApp() throws MIDletStateChangeException {
    this.pantalla.setCurrent(this.mainFrm);
    this.BT.runServer(); // inicia servidor
    }
    //...
    ---------------------------------

    maybe I'm doing something wrong.

    All the attributes that I enable on the service record are to mimic the attributes that i can find on the serial port service of my USB dongle (the RFID connects suscesfully to my PC)

    Thank you

  2. #2
    Registered User
    Join Date
    Jul 2005
    Posts
    43
    Another question:

    When I create the service with master=true in the URL the app creates an exception with symbian error code -5. (The operation requested is not supported)

    maybe the 6600 can't create services as a master?

    thanks
    Last edited by asmatic; 2005-07-21 at 10:22.

Posting Permissions

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