×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    2

    Sending data via OBEX: Transferring works, but no data is stored.

    Hello,

    I'm trying to send messages over Bluetooth by using OBEX Object Push and/or OBEX File Transfer Protocol.

    In order to solve my problem i've discovered a post in this forum about a simmilar problem : http://discussion.forum.nokia.com/fo...+file+transfer

    Summing up, i'm trying to send text files (messages) between mobile phones with BT and one of those devices enabled. The problem is that sending works (the bt icon on my test cells -- n90 and 6680 -- changes, having two brackets besides it). But no data is stored.

    Debugging the app i've managed to find out that bt address i was using is wrong, (before reading the forum thread mentioned above). After correcting the code, it stills no working, and now this stuff is an oddity. I prepare the connection looking for the needed service, get the URL connection, set the needed headers and send it.

    Here a piece of the code:

    PHP Code:

    //Called to send the msg via BT
    public void sendMsg(String msg)
    {
        
    //...
        
    sender.prepareToSend();
        
    sender.sendTextToSelected(msg);
        
    //...
    }

    //...

    //In class Sender
    public void prepareToSend()
    {
            try
            {
                
    int[] attrSet = new int[]{0x01000x00010x00020x00030x0004};
                
                
    append("Buscando..."null);
                
    int trans = -1;
                
                
    UUID[] uuidSet = new UUID[1];
                
    uuidSet[0] = new UUID(OBEX_UUID);
                
    trans discoveryAgent.searchServices(attrSet
                        
    uuidSet,
                        (
    RemoteDevice) (btDevices.elementAt(getSelectedIndex())), 
                        
    this);
                
                
    Thread.sleep(4000);
            }
            catch (
    BluetoothStateException e)
            {
                
    BTMessaging.showFatalError("Error preparing device");
                
    e.printStackTrace();
            }
            catch (
    InterruptedException e)
            {
            }
    }

    //...

        
    public void sendTextToSelected(String msg)
        {
            
    RemoteDevice rDev = (RemoteDevicebtDevices.elementAt(getSelectedIndex());
            try
            {
                
    ClientSession cs = (ClientSessionConnector.open(conn);
                
    HeaderSet headerSet cs.connect(null);
                
    headerSet.setHeader(HeaderSet.LENGTH, new Long(msg.getBytes().length));
                
    headerSet.setHeader(HeaderSet.NAME"bt_msg.txt");
                
    headerSet.setHeader(HeaderSet.TYPE"text/plain");
                

                
    Operation op cs.put(headerSet);

                
    op.sendHeaders(headerSet);
                
    OutputStream os op.openOutputStream();
                
    os.write(msg.getBytes());
                
                
    cs.disconnect(null);
                
    cs.close();
                
    os.close();
                
    op.close();
            }
            catch (
    IOException e)
            {
                
    BTMessaging.showFatalError("Cannot read stream");
            }
        } 
    OBEX_UUID = 0x1105 or 0x1106

    Thanks in advance.

    EDIT: I forgot to mention that the idea is to leave the destiny mobile phones without running a sort of server application.

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

    Thumbs up Re: Sending data via OBEX: Transferring works, but no data is stored.

    Fixed. It seems to be that connect method of ClientSession shouldn't have null as the HeaderSet parameter.

Similar Threads

  1. how to use udp, for sending data server to client
    By acayir in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2006-08-02, 19:18
  2. error sending data to the server. SymbianOS error -1
    By dihex in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-11-15, 18:55
  3. Incoming call while sending data.
    By Lebihen in forum Symbian
    Replies: 0
    Last Post: 2003-08-28, 15:36
  4. sending data from computer to midlet
    By Strunker in forum Mobile Java General
    Replies: 4
    Last Post: 2003-08-26, 00:27
  5. Data connection 6310i to Windows XP Pro..used PC Suite 8.1.. sync works
    By rawsonweb in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2002-08-01, 13:18

Posting Permissions

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