×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Aug 2008
    Location
    Sri Lanka, Colombo
    Posts
    204

    Thumbs down J2ME bluetooth Connection

    hi guys,
    i have search a relevant post in the forum but couldn't find. if i have miss a post sorry about it.


    i have successfully created a application to discover the bluetooth devices. now i want to connect with a selected device.
    but i cant see any output.

    is there a way to findout whether the application connected to the device or not. (like httpConnection.getResponseCode())

    the url looks like this

    btspp://111111111111:8

    this is how i try to connect with the device



    public class Connect extends Thread {

    StreamConnectionNotifier no;
    StreamConnection streamConnection;
    String url = "btspp://" + deviceAddress + ":" + "8";

    public void run() {
    try {
    form.append(url);
    no = (StreamConnectionNotifier) Connector.open(url);
    streamConnection = no.acceptAndOpen();
    DataInputStream is = streamConnection.openDataInputStream();
    StringBuffer sb = new StringBuffer();
    form.append("\n");
    form.append("About to connect");
    int ch;
    while ((ch = is.read()) != -1) {
    sb.append((char) ch);
    }
    form.append("\n");
    form.append("connected");
    form.append("\n");
    form.append(sb.toString());
    display.setCurrent(form);
    } catch (IOException ex) {
    ex.printStackTrace();
    }
    }
    }

    regards,
    Randika

  2. #2
    Regular Contributor
    Join Date
    Aug 2008
    Location
    Sri Lanka, Colombo
    Posts
    204

    Smile Re: J2ME bluetooth Connection

    hi guys,

    thanks for ur replies. u guys are sooo helpfull. at last i have to find it by my own. which is good but i would really appreciate if someone send a reply.

    any how this is how you shoud do it.

    when you are discovering the devises add them to a vector.
    after that when you are selecting the devise


    RemoteDevice remoteDevice = (RemoteDevice) deviceList.elementAt(deviceChoiceGroup.getSelectedIndex());
    String s1 = remoteDevice.getBluetoothAddress();
    String url = "btspp://" + s1 + ":" + "1";


    thats it....

    once again
    thank u guys

    best regards,
    Randika.
    cheers

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    If you are new to J2ME, MIDlets and Bluetooth, I recommend to start with a book like this one for JSR-82 (perhaps your library has its previous edition) or read at least the PDF coming with the specification. If you like to start with tutorials, continue here…

  4. #4
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: J2ME bluetooth Connection

    Hi,
    What is basic requirement?
    What is your application requirement?
    thanks,
    jitu_goldie..

    KEEP TRYING..

Similar Threads

  1. J2ME Bluetooth Problem (JSR82)
    By azman4243 in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2008-10-07, 19:15
  2. problem in establishing connection between devices in j2me using bluetooth
    By vibrating_minds in forum Mobile Java General
    Replies: 3
    Last Post: 2008-01-03, 10:47
  3. unable to reconnect the server bluetooth connection
    By yappy02 in forum Mobile Java General
    Replies: 4
    Last Post: 2006-10-09, 10:09
  4. 6310 bluetooth connection with PCsuite fails
    By Nokia_Archive in forum Bluetooth Technology
    Replies: 1
    Last Post: 2002-05-28, 15:14

Posting Permissions

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