×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    3

    Transferring files using Bluetooth

    Hi All,

    Is it possible to transfer files from PC to Mobile(BT faciliated Mobile) vice versa without using Bluetooth Dongles/adapter?

    Is it possible through Programming?

    Is any programming needed, While using Bluetooth adapter?

    Thanks

    Banupriya

  2. #2
    Registered User
    Join Date
    Mar 2007
    Posts
    27

    Re: Transferring files using Bluetooth

    hi,
    if u want to send file b/w two devices they should ve bluetooth enabled.
    A pc may ve bluetooth usb adapter or some other bluetooth device.
    And every bluetooth device has some profiles(services) like file transfer,obex(object exchange) etc..
    so u need not write any code for sending the files.the manufacturers ll provide those with driver.

    --shiva

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    3

    Re: Transferring files using Bluetooth

    I have seen some Programming in some site for Client-server model.

    Then can any one temme Why this program is for?


    /* FTclient.jar */
    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.*;

    /* add the de.aventna obex */
    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);
    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();
    }
    }

  4. #4
    Registered User
    Join Date
    Aug 2008
    Posts
    23

    Re: Transferring files using Bluetooth

    Can anyone provide the same code in C++ using serial port communication.because socket programming i already tried .please help me. I want the programm for windows platform

  5. #5
    Registered User
    Join Date
    Oct 2009
    Posts
    1

    Re: Transferring files using Bluetooth

    Hi Banupriya

    i have seen your post in 2007. Have you found the solution. I need codes for the same problem

    please Help

    ragesh

  6. #6
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,104
    ragesh, could you ask your question in more detail? Which programming language and device do you want to use?

Similar Threads

  1. Sending jar files from mobile phone using bluetooth.
    By denil_shah in forum Mobile Java Networking & Messaging & Security
    Replies: 7
    Last Post: 2007-09-21, 19:40
  2. Canyon Bluetooth adapter not working with PC Suite?
    By sNNooPY in forum Bluetooth Technology
    Replies: 6
    Last Post: 2006-08-10, 08:43
  3. what kind of files can the nokia 6310i recive via Bluetooth
    By zikman9 in forum General Development Questions
    Replies: 0
    Last Post: 2003-08-12, 07:22
  4. Can not send large files through Bluetooth
    By sami_masad in forum Bluetooth Technology
    Replies: 0
    Last Post: 2003-08-04, 13:51
  5. Replies: 5
    Last Post: 2003-02-07, 11:25

Posting Permissions

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