Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    28

    Bluetooth OBEX ( image transfer using bluetooth ) problem

    Dear all,
    i am working on bluetooth file transfer in J2ME. but the problem which i am facing , i downloaded one code from Sun website for Image Exchange, via bluetooth,but that code is developed in NETBEANS Mobility Pack 5.0 , so i have got couple of queries regarding that.

    1) i tried to compile that code in NetBeans Mobility IDE 5.0 but when compile that code i received error,
    org.netbeans.microedition.util.*; Does not exist.

    let me show a little part of that code:
    ___________________________________________________________
    import javax.microedition.lcdui.*;
    import javax.bluetooth.*;
    import javax.obex.*;
    import org.netbeans.microedition.util.*;


    public class ImageSender extends MIDlet implements CommandListener {

    /** Creates a new instance of ImageSender */
    public ImageSender() {
    }

    // in article talk about jsr 82 and 75
    // also talk about running the system prperties to know more about
    // their implementation. Perhaps that needs to be a separate screen
    // or Midlet


    private Command exitCommand;//GEN-BEGIN:MVDFields
    private Command backCommand1;
    private Command okCommand1;
    private Image folder_closed;
    private Image folder_open;
    private org.netbeans.microedition.lcdui.TableItem tableItem1;
    private Image image1;
    private Image splashimage;
    private Image splash200;
    .
    .
    .
    .
    .

    private String btConnectionURL = null;

    // this is for debugging
    String info = null;
    //GEN-LINE:MVDMethods

    /** This method initializes UI of the application.//GEN-BEGIN:MVDInitBegin
    */
    private void initialize() {//GEN-END:MVDInitBegin
    // Insert pre-init code here
    getDisplay().setCurrent(get_homeForm());//GEN-LINE:MVDInitInit
    // Insert post-init code here
    }//GEN-LINE:MVDInitEnd
    ___________________________________________________________



    2) if i want to run the code which we develop in Netbeans Mobility IDE 5.0, is it posible we can compile and run that code in Wireless toolkit 2.5.


    3) What is the MVD file?


    Thanks in Advance

    Kami

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

    Re: Bluetooth OBEX ( image transfer using bluetooth ) problem

    Hi,
    There is an article on the wiki which might help

    http://wiki.forum.nokia.com/index.ph...EX%29_protocol

    Good Luck
    Jim

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Posts
    4,110
    atiqkamran, please, let us continue in your original thread …
    Last edited by traud; 2011-09-28 at 14:32.

  4. #4
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    78

    Re: Bluetooth OBEX ( image transfer using bluetooth ) problem

    i am try to run FTClient, but always appears this error :


    Device discovered 0016b8a3aa25
    Name : Hòòd_@
    Device discovered 00188d6cd79c
    Name : Kùm€ñg Phöñê
    Device discovered 8156de0631f0
    Name : LANGLANG
    Inquiry completed ...
    Now searching for services ........
    Service search completed ...........
    Opening a connection with the server ....
    Exception in thread "Thread-1" java.lang.NullPointerException
    at com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:61)
    at javax.microedition.io.Connector.open(Connector.java:79)
    at phone.FTClient.serviceSearchCompleted(FTClient.java:69)
    at com.intel.bluetooth.BluetoothPeer$SearchServicesThread.run(BluetoothPeer.java:94)

    why this error???

  5. #5
    Registered User
    Join Date
    Jun 2007
    Posts
    28

    Re: Bluetooth OBEX ( image transfer using bluetooth ) problem

    Can you send me code or part of code so i can better tell you.

    BR,
    kami

  6. #6
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    78

    Re: Bluetooth OBEX ( image transfer using bluetooth ) problem

    i just use standart FTCient :

    [QUOTE]
    /*original imports */
    package phone;
    import java.io.*;


    import javax.microedition.io.*;
    import javax.bluetooth.*;
    import javax.bluetooth.UUID;

    /* add the de.aventna obex */
    import de.avetana.javax.obex.ClientSession;
    import de.avetana.javax.obex.HeaderSet;
    import de.avetana.javax.obex.Operation;

    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();
    }
    }

  7. #7
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    78

    Re: Bluetooth OBEX ( image transfer using bluetooth ) problem

    package J2SEbtSPPlinkServer;
    //import bartelo.javax.microedition.io.HttpConnection;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.microedition.io.*;
    import java.io.*;
    import javax.bluetooth.*; //comes from bluecove
    //import javax.obex.*;
    // uses the de.avetana OBEX library
    import de.avetana.obexsolo.OBEXConnector;
    import de.avetana.javax.obex.HeaderSet;
    import de.avetana.javax.obex.Operation;
    import de.avetana.javax.obex.ResponseCodes;
    import de.avetana.javax.obex.ServerRequestHandler;
    import de.avetana.javax.obex.SessionNotifier;


    public class J2SEbtSPPlinkServer implements ActionListener, Runnable{
    // Bluetooth singleton object
    LocalDevice device;
    DiscoveryAgent agent;
    String HTBTurl = null;
    boolean mServerState = false; // stop is default state

    Thread mServer = null;
    String msgOut = "srv out msg";
    String msgIn = "no msg rcv";
    StreamConnectionNotifier btServerNotifier ;
    UUID uuid = new UUID("9106", true);
    JLabel spacerlabel = new JLabel(" ");
    JButton startButton = new JButton("Start Server");
    JTextArea textarea = new JTextArea("",20, 40);
    JButton endButton = new JButton("End Server");

    public J2SEbtSPPlinkServer(){

    //Give it the Java look and feel
    JFrame.setDefaultLookAndFeelDecorated(true);

    JFrame frame = new JFrame("FileServer ");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JScrollPane scrollPane = new JScrollPane(textarea);
    textarea.setEditable(false);

    Container cp = frame.getContentPane();
    cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));

    startButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    startButton.addActionListener(this);
    cp.add(startButton);

    endButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    endButton.addActionListener(this);
    cp.add(endButton);


    spacerlabel.setAlignmentX(Component.CENTER_ALIGNMENT);
    cp.add(spacerlabel);

    scrollPane.setAlignmentX(Component.CENTER_ALIGNMENT);
    cp.add(scrollPane);

    frame.pack();
    frame.setVisible(true);

    updateStatus("[server:] FileServer Application started");
    updateStatus("[server:] Press the \"Start Server\" button to await for client devices");


    }

    private void startServer() {
    if (mServer !=null)
    return;
    //start the server and receiver
    mServer = new Thread(this);
    mServer.start();
    }

    private void endServer() {
    if (mServer == null)
    return;
    try {
    mServer.join();
    } catch (Exception ex) {};
    mServer = null;

    }




    public void run(){
    try {
    UUID uuid = new UUID("1106", true);
    //UUID uuid = new UUID("9106", true);
    device = LocalDevice.getLocalDevice(); // obtain reference to singleton
    device.setDiscoverable(DiscoveryAgent.GIAC); // set Discover mode to LIAC
    }catch (Exception e)
    { System.err.println("Cant init set discvover");
    e.printStackTrace();
    }
    String url = "btspp://localhost:" + uuid + ";name=BTTP;authenticate=false;master=false;encrypt=false";
    //Bluecove does not support btgeop on server
    // String url = "btgoep://localhost:" + uuid + ";name=BTTP;authenticate=false;master=false;encrypt=false";

    try{

    // obtain connection and stream to this service
    btServerNotifier = (StreamConnectionNotifier) Connector.open( url );
    System.out.println(url);

    // 0013eff1440b
    } catch ( Exception e) {
    e.printStackTrace();
    }


    while (mServerState )
    {
    StreamConnection btConn = null;
    try {
    updateStatus("[server:] Now waiting for a client to connect");

    btConn = btServerNotifier.acceptAndOpen();
    } catch (IOException ioe) { }
    if (btConn != null) processConnection(btConn);
    }
    }

    void processConnection(StreamConnection conn) {
    updateStatus("[server:] A client is now connected");

    try {
    DataInputStream in = conn.openDataInputStream();

    // // write data into serial stream
    // msgIn = in.readUTF();

    char s ='a';

    String h =null;
    try {
    while (s!='\n'){
    s = in.readChar();
    System.out.println(s);
    h += s;
    }
    System.out.println(s); // typing the result
    } catch (IOException ex) {
    System.out.println("unable to handle incoming data");
    ex.printStackTrace();
    }
    msgIn = h;
    in.close();
    System.out.print("The receive message is '" + msgIn + "'");

    Thread.sleep(1000);

    DataOutputStream out = conn.openDataOutputStream();
    msgOut = msgIn +" srv reply";
    System.out.print("Sending the message is '" + msgOut + "'");

    // write data into serial stream
    out.writeUTF( msgOut );
    out.flush();


    Thread.sleep(1000);

    // finish, close output stream
    out.close();

    } catch (Exception e)
    {
    e.printStackTrace();

    }
    try {
    conn.close();
    updateStatus("[server:] Finished connection");

    }catch (Exception e ){ }


    }

    public void actionPerformed(ActionEvent e) {
    if ((e.getActionCommand()).equals("Start Server") ) {
    startButton.setEnabled(false);
    mServerState = true; // set server state started
    startServer();
    }
    if ((e.getActionCommand()).equals("End Server") ) {
    endButton.setEnabled(false);
    startButton.setEnabled(true);
    mServerState = false;
    endServer();

    }

    }



    public void updateStatus(String message){
    textarea.append("\n" + message);

    }


    public static void main(String[] args) {
    new J2SEbtSPPlinkServer();
    }
    }
    but the error alway appers

    [/QUOTE]

  8. #8
    Registered User
    Join Date
    Aug 2008
    Posts
    3

    Re: Bluetooth OBEX ( image transfer using bluetooth ) problem

    hello Frendz, can you give the Library of
    org.netbeans.microedition.util when i compilling my Program that import org.netbeans.microedition.util.*; always make a error package org.netbeans.microedition.util does not exist

    plz email me at sherwin_corpuz01@yahoo.com.ph the Library..

    thnx in Advance

Similar Threads

  1. help me on file transfer - pc to phone over bluetooth.
    By kiran10182 in forum Bluetooth Technology
    Replies: 2
    Last Post: 2009-09-05, 10:07
  2. Can not send any Obex Objects to a billionton bluetooth
    By hoy_cpe in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2006-08-01, 07:28
  3. Replies: 1
    Last Post: 2005-01-04, 18:16
  4. 6230 global problems with Bluetooth
    By asterixmlm in forum General Development Questions
    Replies: 1
    Last Post: 2004-12-10, 18:12
  5. Replies: 3
    Last Post: 2004-04-20, 07:40

Posting Permissions

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