Bluetooth SPP, Error send Msg from soft key ( commandAction )

Discussion in 'Java' started by Boki, Mar 21, 2005.

  1. Boki

    Boki Guest

    Hi All,
    I try a bluelet demo, I change some code here, I want to move
    these codes of run()
    ========================================================
    out.writeUTF( "Boki Back Msg" );
    out.flush();
    ========================================================

    to a soft key event, but it never work ( exception error is 0 / null )

    public void commandAction(Command c, Displayable s) {
    ========================================================
    out.writeUTF( "Boki Back Msg" );
    out.flush();
    ========================================================
    }

    My original thread:

    =============================================
    public void run()
    {

    StreamConnection c = null;
    try
    {
    localDevice = LocalDevice.getLocalDevice(); // obtain reference to
    singleton
    localDevice.setDiscoverable(DiscoveryAgent.GIAC); // set Discover mode
    to LIAC

    String uuidString = "102030405060708090A0B0C0D0E0F010";
    UUID uuid = new UUID(uuidString, false);

    String url = "btspp://localhost:" + uuid.toString()
    +";name=Boki_SPP";

    server = (StreamConnectionNotifier)Connector.open( url );
    localDevice.setDiscoverable(DiscoveryAgent.GIAC);

    ServiceRecord rec = localDevice.getRecord( server );

    rec.setAttributeValue( 0x0008, new DataElement(
    DataElement.U_INT_1, 0xFF ) );


    } catch (Exception e)
    {

    System.out.println("try1 fail"+e.getMessage());
    System.out.println(e);
    }

    while( !done)
    {
    try {
    System.out.println("try2");

    c = server.acceptAndOpen();
    RemoteDevice rdev = RemoteDevice.getRemoteDevice( c );

    DataInputStream in = c.openDataInputStream();
    String s = in.readUTF();

    DataOutputStream out = c.openDataOutputStream();
    ========================================================
    out.writeUTF( "Boki Back Msg" );
    out.flush();
    ========================================================
    // close current connection, wait for the next one
    // c.close();


    } catch (Exception e)
    {
    System.out.println("try2 fail");
    }

    } // while

    }
     
    Boki, Mar 21, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Boki
    Replies:
    5
    Views:
    648
    Darryl Pierce
    Mar 26, 2005
  2. Boki
    Replies:
    1
    Views:
    1,131
  3. Boki

    J2ME,Bluetooth,JSR82, SPP

    Boki, Apr 21, 2005, in forum: Java
    Replies:
    1
    Views:
    2,905
  4. RJH
    Replies:
    10
    Views:
    804
  5. ade0
    Replies:
    1
    Views:
    315
    Gunnar Hjalmarsson
    Apr 6, 2005
Loading...

Share This Page