Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jan 2005

    RFCOMM, Serial Port Profile connection to PC with JAVA

    pls let us develop sample code and a basic design to understand RFCOMM, Serial Port Profile.

    The target is to get a connection to a USB-Bluetooth dongle wich is connectet with a PC.
    Windows: In the Hardwareprofile you have set a COM Port on my computer it is COM7.
    I have to decide that
    a) device will initiate the connection
    b) the computer initiate the connection
    What shoudl I use. I have set first to (a).
    I open the HyperTerminal and set it to COM7.

    The target is now to build a sample class, the class shows incoming text from the nokia phone, and the phone shows text wich I typed into the HyperTermina.

    In Linux you can use bluez and hciconfig
    hciconfig hci0 up
    and rfcomm
    rfcomm bind hci0 1 or something like that. Can you give a example what you have to do that we can make a easy connection?
    cat /dev/rfcomm0
    should show the characters which will you send with your phone.

    Step by Step, what have we to do?
    There is a lot of stuff .
    I found no code which will do the simple thing to transport bytes to computer and from computer to phone. Do you have some sample code?

  2. #2
    Registered User
    Join Date
    Jan 2005
    Gerneric Bluetooth architecture of the device Series 60/ Series 80 from top do down
    RFCOMM serial emulation API
    L2CAP Logical Link Control and Adaption Protocol
    HCI-Driver Controller Interface

    What we need:
    javax.microedition.io The core CLDC Gerneric Connection Framework
    javax.bluetooth The core Bluetooth API

    For serial connection we have to use the following URL scheme
    If we have a Client so we use StreamConnection.
    If we have a Server so we have to use StreamConnectionNotifer, StreamConnection.

    StreamConnection con = (StreamConnection) Connector.open("btspp://XXX:N");
    What should I use for XXX and N? Where do I get the right Information about that.
    Remember I will connect me to a Bluetooth dongle with Hyperterminal on Windows
    or with /dev/rfcomm0 with bluez under Linux.
    But what do I have to do that I get the right information?

  3. #3
    Registered User
    Join Date
    Jan 2005

    Linux, bluez, btsppEcho.jar Example

    Yesterday I spend a lot of time into bluetooth but nothing will run.
    I red the btsoppEcho demo sources, but something I could not understood.
    I got the bluez-libs-2.14 and bluz-utils-2.14 I installed that.
    insmod hci_usb // I have a USB Dongle
    insmod bluez

    root@Box:~# hciconfig 
    hci0:   Type: USB
            BD Address: 00:00:00:00:00:00 ACL MTU: 0:0 SCO MTU: 0:0
            RX bytes:0 acl:0 sco:0 events:0 errors:0
            TX bytes:0 acl:0 sco:0 commands:0 errors:0
    the bluetooth dongel is down I will bring it up
    I will set in this text my dongle hardeware adress to "11:22:33:44:55:66"
    and the nokia phone hardware adress to 66:55:44:33:22:11

    root@Box:~# hciconfig hci0 up
    root@Box:~# hciconfig
    hci0:   Type: USB
            BD Address: 11:22:33:44:55:66 ACL MTU: 192:8 SCO MTU: 64:8
            RX bytes:69 acl:0 sco:0 events:8 errors:0
            TX bytes:27 acl:0 sco:0 commands:7 errors:0
    ok the bluetooth dongle should work now
    I try to seach the phone
    root@Box:~# hcitool scan
    Scanning ...
            66:55:44:33:22:11       Nokia6630
    "66:55:44:33:22:11" is a example of hardware adress from the phone

    On the phone is the btsppEcho.jar installed. I start this and choose "Client" and run.
    It ask that it want make a connection I allowed that.
    The "Log" of the example shows:
    looks like it runs
    on Linux I use the sdptool
    root@Box:~# sdptool browse
    Inquiring ...
    Browsing 66:55:44:33:22:11 ...
    Service Name: Hands-Free Audio Gateway
    Service RecHandle: 0x1001a
    Service Class ID List:
      "Handfree Audio Gateway" (0x111f)
      "Generic Audio" (0x1203)
    Protocol Descriptor List:
      "L2CAP" (0x0100)
      "RFCOMM" (0x0003)
        Channel: 1
    there is more as this but no "Service Name:bsppEcho", what is the Problem?
    Some of them like the SyncMLClient shows a error
    Service Name: SyncMLClient
    Service RecHandle: 0x1001d
    Service Class ID List:
      "Error: This is UUID-128" (0x00000002-0000-1000-8000-0002ee000002)
    is that a problem?

    root@Box:~# rfcomm bind 0 66:55:44:33:22:11 1
    root@Box:~# rfcomm show
    rfcomm0: 66:55:44:33:22:11:11 channel 1 clean 
    root@Box:~# rfcomm connect 0 66:55:44:33:22:11 1
    Phone shows "Bluetooth" Password for Bluez "________"
    cat /etc/bluetooth/pin
    I type 1234 into the phone

    Can't connect RFCOMM socket: Resource temporarily unavailable
    ok it was not the channel from the application, maybe that is the reason

    root@Box:~# lsmod
    Module                  Size  Used by    Not tainted
    rfcomm                 31008   0  (autoclean)
    l2cap                  17516   1  (autoclean) [rfcomm]
    hci_usb                 8892   0 
    bluez                  31396   0  [rfcomm l2cap hci_usb]
    ok all modules running and I should do rfcomm.

    and then I would send ASCII to the computer and get ASCII back to phone.
    echo "Hallo Phone" >/dev/rfcomm0

    Anyone has a sample java code to do that?
    Or see my mistakes. I think I dont got at the moment the problem with password and security.
    What did I forgot to do?

  4. #4
    Registered User
    Join Date
    Jan 2005


    hi, i have discoverd som BT devices,
    now I have to search for the RFCOMM Service.

    Method: searchService()
    UUID[] searchList = new UUID[1];
    searchList[0] = new UUID(0x0003);//0x0003 RFCOMM 
    int find_int=-1;
    try{	find_int =discoveryAgent.searchServices(null, searchList, remotedevList[i], this);
    log("searchServices() find_int="+find_int);
    }//end try 
    catch (BluetoothStateException e) 
    in the log:
    find_int =0
    and serviceSearchCompleted give the Response Code SERVICE_SEARCH_NO_RECORD.

    What is wrond?
    I am shure there is a BT device wich hav e run L2CAP and RFCOMM.
    I am interessted to finde the channel where it is running so that I can me connect in my next step.
    Last edited by SonixGer; 2005-02-09 at 19:40.

  5. #5
    Registered User
    Join Date
    Jan 2005

    10.02.2005 Linux, sdpd, hcid

    ok you want have a connection beetween the mobile phone and your linux pc,
    so you should use 2 tools.
    hcid and sdpd. This two demons are important.
    The hcid deamon you have to use for for password.
    And the sdpd for organize the services. ( I have not understood all the things but you should share my basics)
    For sdp maybe follow this link: http://www.palowireless.com/infotooth/tutorial/sdp.asp

    use a simple script "pin"
    root@Box:~#cat /etc/bluetooh/pin
    echo "PIN:12345678"
    root@Box:~#chmod u+x pin
    root@Box:~#vi +26 /etc/bluetooth/hcid.conf
    Set the pin_helper to your pin script.
    pin_helper /etc/bluetooth/pin

    That is simple, i had to go this way, because something was with my python wrong.
    Normaly there is a program which will ask you and gernerate some pins, I think so sorry it will not run.
    But this work around should help.

    The sdptool and sdpd do you need to set up services.
    Who can tell my what I have to do for RFCOMM?
    I tryed:
    1) start sdpd -n
    2) sdptool add --channel=1 SP

    But my phone does not discover RFCOMM
    Maybe my java code is wrong have a look to it pls.

  6. #6
    Registered User
    Join Date
    Jul 2005

    Re: RFCOMM, Serial Port Profile connection to PC with JAVA

    Try setting the UUID of the btspecho example to 0x1101, that's the UUID of the serial port profile, maybe that way your linux machine will be able to discover the service.


  7. #7
    Registered User
    Join Date
    Jan 2005

    Exclamation Re: RFCOMM, Serial Port Profile connection to PC with JAVA

    Sample Code to connect to a Serial Device:

Posting Permissions

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