×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    3

    Bluetooth and OBEX on Windows XP

    Hi all,

    I'm trying to develope a Application which can exchange Data through the OBEX Protocol with a Nokia 6230i.

    What is the best Way to do it?

    Is it possible to do it with the help of the Winsock and Bluetooth support from Microsoft?(It would be the solution I prefere)

    Does anybody know a Tutorial about this topic?

    I hope somebody can help me.

    Kind regards

    Andreas

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    England,UK
    Posts
    1,600

    Re: Bluetooth and OBEX on Windows XP

    The Microsoft website supports winsock and MSDN Channel 9 has a discussion on building code with bluetooth called the Code Room "the mall challenge " the software is "*free*" but its just code from the show developed to research bluetooth which IMHO is far behind Java J2ME.

    The code is the winsock RFCOMM and is supported in www.microsoft.com/msdn. Finally it cannot use the JSR82 support simply because MS points all output to WIN CE 5.0 and does not support Java
    Discovery of a device is 40 lines of code in VC++ in Java its 3 lines!.

    Java in J2ME is best! its built in your phone (6230i)

    see my post in another thread about cheating XP into using your bt as standard device then you can use Bluecove program to drive the BT USB driver to connect to phone.

    http://discussion.forum.nokia.com/fo...ad.php?t=69637

    Good Luck you will need it with winsock!.



    Jim
    Last edited by jimgilmour1; 2006-05-18 at 10:45.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    3

    Re: Bluetooth and OBEX on Windows XP

    Hi

    Thanks for your advise, i read your other article, too and I think I will try it with Java. I wrote the dokumentation on msdn and tryed it, but I had no success so far.

    King regards

    Andreas

  4. #4
    Super Contributor
    Join Date
    Dec 2005
    Location
    England,UK
    Posts
    1,600

    Re: Bluetooth and OBEX on Windows XP

    Hi,
    Yes its hard to convert from on library to another let alone another language!.
    so here is a start
    -------------------------------------------------------------------

    package phone;
    /*original imports */
    import java.io.*;
    import java.util.*;
    import javax.microedition.io.*;
    /* switch of J2se netbeans dev kit */

    import javax.bluetooth.*;
    import javax.obex.*; for nokia 6230i

    /* add the de.aventna obex for J2SE
    import de.avetana.bluetooth.obex.OBEXConnection;
    import de.avetana.bluetooth.obex.HeaderSetImpl;
    import de.avetana.bluetooth.obex.CommandHandler;
    import de.avetana.bluetooth.obex.MD5;
    import de.avetana.bluetooth.obex.OperationImpl;
    import de.avetana.bluetooth.obex.SessionNotifierImpl;

    import de.avetana.javax.obex.Authenticator;
    import de.avetana.javax.obex.ClientSession;
    import de.avetana.javax.obex.HeaderSet;
    import de.avetana.javax.obex.Operation;
    import de.avetana.javax.obex.PasswordAuthentication;
    import de.avetana.javax.obex.ResponseCodes;
    import de.avetana.javax.obex.ServerRequestHandler;
    import de.avetana.javax.obex.ServiceRegistrationException;
    import de.avetana.javax.obex.SessionNotifier;
    */

    public class FTClient implements DiscoveryListener {
    LocalDevice local = null;
    DiscoveryAgent agent = null;
    int[] attrSet = null;
    RemoteDevice btDev = null;
    String serviceURL = null;
    ClientSession con = null;
    HeaderSet hdr = null;

    public FTClient() throws BluetoothStateException{

    // initialize the stack, if needed
    local = LocalDevice.getLocalDevice();
    agent = local.getDiscoveryAgent();
    agent.startInquiry(DiscoveryAgent.GIAC, this);
    }

    public void deviceDiscovered(RemoteDevice btDevice,DeviceClass cod){
    btDev = btDevice;
    System.out.println("Device discovered " +
    btDevice.getBluetoothAddress());
    }

    public void servicesDiscovered(int transID, ServiceRecord[] servRecord){
    System.out.println("Discovered a service ....");
    for(int i =0; i < servRecord.length; i++){
    serviceURL =
    servRecord[i].getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT,
    true);
    System.out.println("The service URL is " + serviceURL);
    }
    }

    public void serviceSearchCompleted(int transID, int respCode){
    System.out.println("Service search completed ........... ");
    System.out.println("Opening a connection with the server ....");
    try{
    con = (ClientSession)Connector.open(serviceURL);
    hdr = con.connect(hdr);
    System.out.println("Response code of the server after connect..." +
    hdr.getResponseCode());


    //Sending a request to server for file Hello.txt
    hdr = con.createHeaderSet();
    hdr.setHeader(HeaderSet.TYPE,"text/vCard");
    hdr.setHeader(HeaderSet.NAME,"Hello.txt");
    Operation op = con.get(hdr);

    //The server is now sending the file
    InputStream in = op.openInputStream();


    // Writing the file from server to local file system.
    StreamConnection filestream =
    (StreamConnection)Connector.open("file://name=HelloFile.txt;mode=w");
    OutputStream out = filestream.openOutputStream();

    //read and write the data
    int data = in.read();
    while(data != -1){
    out.write((byte)data);
    data = in.read();
    }

    // send the DISCONNECT Operation
    con.disconnect();

    // cleanup
    op.close();
    in.close();
    out.close();
    }
    catch(IOException e){
    System.out.println(e.getMessage());
    }
    }
    public void inquiryCompleted(int discType){
    System.out.println("Inquiry completed ... ");
    UUID[] uuids = new UUID[1];
    uuids[0] = new UUID("1106",true); // OBEX Filetransfer UUID value is hexadecimal 0x1106
    // OBEX Object PUSH UUID value is hexadecimal 0x1105
    try{
    if(btDev == null){
    System.out.println("No device has been discovered, " +
    "hence not worth proceeding exiting .... ");
    System.exit(1);
    }
    System.out.println("Now searching for services ........ ");
    agent.searchServices(attrSet, uuids, btDev, this);
    }
    catch(BluetoothStateException e) {System.out.println(e.getMessage());}
    }
    public static void main(String args[]) throws IOException {
    FTClient client = new FTClient();
    }
    }

    -------------------------------------------------------------------
    This is the client to link to a remote server. The inquiry and search is done an then the check
    To transfer data strings refer to the thread
    http://discussion.forum.nokia.com/forum/showthread.php?t=80618

    The transfer must run in a new thread to stop the phone from freezing, but it will run without a new thread but it will be sluggish as the control panel will be asleep
    Jim
    Last edited by jimgilmour1; 2006-05-19 at 17:12.

  5. #5
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    61

    Re: Bluetooth and OBEX on Windows XP

    Hi

    I am trying to receive a file from bluetooth enabled device

    Assume that file is present at a default lockation on device 1

    I have another device 2 which is blutooth enabled device.

    Now device 2 is trying to get from device1 over OBEX GET


    I am able to PUT the file to device 2 but how abt OBEX get
    why is it not working??

    I am unable to understand the cause
    public void obexGet() throws IOException
    {
    try
    {

    System.out.println("Connecting to " + serverURL);

    ClientSession clientSession = (ClientSession) Connector.open(serverURL);
    HeaderSet hsConnectReply = clientSession.connect(null);
    if (hsConnectReply.getResponseCode() != ResponseCodes.OBEX_HTTP_OK) {
    System.out.println("Failed to connect");
    return;
    }
    String StringMessage = "Response received ";
    Alert oAlert = CompatibilityUtil.showProgress(StringMessage,
    Alert.FOREVER);
    CompatibilityChecker.moDisplay.setCurrent(oAlert);


    HeaderSet hsOperation = clientSession.createHeaderSet();
    hsOperation.setHeader(HeaderSet.NAME, "file:///C:/Data/Images/abc.jpg");
    hsOperation.setHeader(HeaderSet.TYPE, "image/jpeg");
    hsOperation.setHeader(HeaderSet.LENGTH,new Long(5));
    StringMessage = "Before getting the data";
    oAlert = CompatibilityUtil.showProgress(StringMessage,
    Alert.FOREVER);
    CompatibilityChecker.moDisplay.setCurrent(oAlert);
    //Create GET Operation
    Operation putOperation = clientSession.get(hsOperation);
    System.out.println("After Get " );
    // Send some text to server
    InputStream oStream = putOperation.openInputStream();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    int data = oStream.read();
    System.out.println("data read is " +data);
    while(data != -1)
    {
    System.out.println("### "+data);
    out.write((byte)data);
    data = oStream.read();
    }
    // End the transaction
    oStream.close();
    out.flush();
    byte[] obj = out.toByteArray();
    out.close();
    StringMessage = "Done yeahhh"+obj.length;
    oAlert = CompatibilityUtil.showProgress(StringMessage,
    Alert.FOREVER);
    CompatibilityChecker.moDisplay.setCurrent(oAlert);

    putOperation.close();

    clientSession.disconnect(null);

    clientSession.close();
    }catch (Exception e) {
    e.printStackTrace();
    System.out.println("Error occured "+e.getMessage() );
    }}
    This is th method


    Device discovery and serach service part is done...but how do i get the file using OBEX?

    Regards
    Geetanjali

  6. #6
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,105

Similar Threads

  1. SyncML , OBEX over Bluetooth
    By pvsasidhar in forum OMA DM/DS/CP
    Replies: 185
    Last Post: 2011-04-04, 14:05
  2. Bluetooth Profiles over Symbian OBEX
    By jimdeal in forum Symbian
    Replies: 2
    Last Post: 2006-09-15, 08:30
  3. SyncML over OBEX and Bluetooth
    By HWM in forum OMA DM/DS/CP
    Replies: 13
    Last Post: 2006-05-19, 18:47
  4. Bluetooth and OBEX example
    By TD-A in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-06-29, 17:51
  5. SyncML, OBEX and Bluetooth
    By odefield in forum OMA DM/DS/CP
    Replies: 2
    Last Post: 2004-11-21, 13:02

Posting Permissions

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