×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    61

    FTP using blutooth (OBEX)

    Hi


    I want to write an application using Blutooth which sends file from server to mobile device.

    can any one send me the sample application for using OBEX FTP using blutooth ?

    Regards
    Geetanjali

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

    Re: FTP using blutooth (OBEX)

    Hi

    My requirement is server sends a file (say jar file)
    client receives a file and stores it on mobile phone.

    i have tried few applications ..but unable to create an application

    Regards
    Geetanjali

  3. #3
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: FTP using blutooth (OBEX)

    You want to use a Java application, to install another Java application, by Bluetooth?

    That's not likely to happen. Of course, on most Nokias, you can simply send the JAR file by Bluetooth anyway, and let the device's Application Manager install it...

    Cheers,
    Graham.

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

    Re: FTP using blutooth (OBEX)

    No

    If there's one device FTP (bluttoth) enabled and another device which communicates over FTP to that device and pulls the data from the directory and save it inside the phone...

    Following is the code snippet which i have written

    Let me know why its not fetching a file

    public static void Connect(String connectionURL) throws IOException
    {
    try
    {
    Connection oConnection = Connector.open(connectionURL,
    Connector.READ_WRITE);
    System.out.println("Done extablishing conn");
    oSession = (ClientSession)oConnection;
    System.out.println("Opened client session...");
    HeaderSet oHeaderSet = oSession.createHeaderSet();
    System.out.println("created header set..");
    HeaderSet response = oSession.connect(oHeaderSet);
    oHeaderSet.setHeader(HeaderSet.NAME,
    "file:///E:/abc.jpg");
    oHeaderSet.setHeader(HeaderSet.TYPE, "image/jpeg");
    System.out.println("opened connection with header set.");
    System.out.println("header set values filled");
    int responseCode = response.getResponseCode();
    System.out.println("Response Code is" + responseCode);
    if(responseCode != ResponseCodes.OBEX_HTTP_OK)
    {
    System.out.println("Response code is not okay");
    throw new IOException();
    }
    System.out.println("Before calling get method");
    System.out.println("Header sets are.........." + response);
    Operation oOperation = oSession.get(oHeaderSet);
    byte[] abyData = getObjectViaOBEX(oOperation);
    String StriszMessage = "Data received of size "+abyData.length;
    Alert oAlert = CompatibilityUtil.showProgress(StriszMessage,
    Alert.FOREVER);
    CompatibilityChecker.moDisplay.setCurrent(oAlert);

    }
    catch(Exception e)
    {
    e.printStackTrace();
    System.out.println("exception ocurredddddddddd...."
    + e.getMessage());
    }
    }

    private static byte[] getObjectViaOBEX(Operation oOperation)
    throws IOException
    {

    System.out.println("BBefore open stream");
    InputStream in = oOperation.openInputStream();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    int data = in.read();
    while(data != -1)
    {
    System.out.println("### "+data);
    out.write((byte)data);
    data = in.read();
    }
    // End the transaction
    in.close();
    oOperation.close();
    byte[] obj = out.toByteArray();
    out.close();
    return obj;
    }

    Its not reading any data neither it is giving any exception


    Regards
    Geetanjali

  5. #5
    Super Contributor
    Join Date
    Mar 2008
    Posts
    1,481

    Re: FTP using blutooth (OBEX)

    Does your code connect to the server, can you see that client device is connected with Server?

    If you want to get folder you have to do these:

    1. Connect to FTP server.
    2. Call Obex Get method

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

    Re: FTP using blutooth (OBEX)

    Do u have a code snippet which will get the FTP data or rather pull the data using obex get from specified location?

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

    Re: FTP using blutooth (OBEX)

    Hi

    I am able to successfully send file from BT mobile to another BT enabled device using OBEX FTP(JSR82)

    Pleas find the following code which works fine in case of PUT operation
    public void obexPut() throws IOException
    {

    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, "Hello.txt");
    hsOperation.setHeader(HeaderSet.TYPE, "text");
    StringMessage = "Before putting the data";
    oAlert = CompatibilityUtil.showProgress(StringMessage,
    Alert.FOREVER);
    CompatibilityChecker.moDisplay.setCurrent(oAlert);

    //Create PUT Operation
    Operation putOperation = clientSession.put(hsOperation);
    // Send some text to server
    byte data[] = "Hello world!".getBytes("iso-8859-1");
    OutputStream os = putOperation.openOutputStream();
    os.write(data);
    os.close();
    StringMessage = "Done yeahhh";
    oAlert = CompatibilityUtil.showProgress(StringMessage,
    Alert.FOREVER);
    CompatibilityChecker.moDisplay.setCurrent(oAlert);

    putOperation.close();

    clientSession.disconnect(null);

    clientSession.close();
    }


    If i use the same technique for OBEX GET operation using following code ...it doenst give me any error but also it is unable to read/get the file which i want to

    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() );
    }
    }
    It esatblishesh the connection well ...but doesnt even throw error if connection is not found.

    Please reply.

    Regards,
    Geetanjali

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

    Re: FTP using blutooth (OBEX)

    can any one tell me the answer of this?

  9. #9
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    gittu, which UUID (in Bluetooth service search) and target (in OBEX connect header) do you use? Does this help?

Similar Threads

  1. how can i set a blutooth obex
    By 1symbian1 in forum Symbian
    Replies: 5
    Last Post: 2008-10-20, 13:25
  2. OBEX FTP whitout pin request?
    By fabio.bond in forum Bluetooth Technology
    Replies: 0
    Last Post: 2006-10-30, 11:33
  3. OBEX ftp on 6680
    By ceruault in forum Bluetooth Technology
    Replies: 1
    Last Post: 2005-11-05, 09:54
  4. FTP Obex and Nokia 7650
    By tplinet in forum Bluetooth Technology
    Replies: 1
    Last Post: 2003-02-26, 12:08
  5. FTP Obex and Nokia 7650
    By tplinet in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2003-02-25, 12:49

Posting Permissions

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