You Are Here:

Community: Developer Discussion Boards

#1 Old send file from mobile phone to PC - 2007-07-30, 18:37

Join Date: Aug 2006
Posts: 78
saifulhq
Offline
Regular Contributor
i am success send file from my computer to mobile phone with vietcovo application, now my problem is how to send file from mobile phone (Nokia E50) to my computer.

i try many script from this forum but, just don't appears anything :

this is my OBEXServer on my computer:
Quote:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
//import net.benhui.bluecove.spp_bt;

import javax.bluetooth.*;


// 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 HTBTServer extends ServerRequestHandler implements ActionListener{
// Bluetooth singleton object
LocalDevice device;
DiscoveryAgent agent;


JLabel spacerlabel = new JLabel(" ");

JButton startButton = new JButton("Start Server");
JTextArea textarea = new JTextArea("",20, 40);

public HTBTServer(){

//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);

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");


}



public void actionPerformed(ActionEvent e) {

startButton.setEnabled(false);

try {
UUID uuid = new UUID("9106", true);
device = LocalDevice.getLocalDevice(); // obtain reference to singleton
device.setDiscoverable(DiscoveryAgent.GIAC); // set Discover mode to LIAC

String url = "btgoep://localhost:" + uuid + ";name=HTBP;authenticate=false;master=false;encrypt=false";

SessionNotifier sn = (SessionNotifier)OBEXConnector.open(url);

// Retrieve the service record template
//ServiceRecord rec = device.getRecord( sn );
// set ServiceRecord ServiceAvailability (0x0008) attribute to indicate our service is available
// 0xFF indicate fully available status
// This operation is optional
//rec.setAttributeValue( 0x0008, new DataElement( DataElement.U_INT_1, 0xFF ) );

updateStatus("[server:] Now waiting for a client to connect");
sn.acceptAndOpen(this);

updateStatus("[server:] A client is now connected");
} catch (Exception ex){
System.out.println(ex);
}

}



public int onConnect(HeaderSet request, HeaderSet reply) {
updateStatus("[server:] The client has created an OBEX session");
return ResponseCodes.OBEX_HTTP_OK;
}


public int onPut (Operation op) {

try {
java.io.InputStream is = op.openInputStream();

updateStatus("Got data bytes " + is.available() + " name " + op.getReceivedHeaders().getHeader(HeaderSet.NAME) + " type " + op.getType());

File f = new File((String)op.getReceivedHeaders().getHeader(HeaderSet.NAME));
FileOutputStream fos = new FileOutputStream (f);
byte b[] = new byte[1000];
int len;

while (is.available() > 0 && (len = is.read(b)) > 0) {
fos.write (b, 0, len);
}

fos.close();
updateStatus("[server:] Wrote data to " + f.getAbsolutePath());
} catch (Exception e) {
e.printStackTrace();
}

return ResponseCodes.OBEX_HTTP_OK;
}


public void onDisconnect (HeaderSet req, HeaderSet resp) {

updateStatus("[server:] The client has disconnected the OBEX session");

}




public void updateStatus(String message){

textarea.append("\n" + message);

}


public static void main(String[] args) {

new HTBTServer();

}





}

and this is my OBEXclient in my mobile phone :
Quote:
import de.avetana.javax.obex.ClientSession;
import de.avetana.javax.obex.HeaderSet;
import de.avetana.javax.obex.Operation;
import de.avetana.javax.obex.ResponseCodes;
import de.avetana.obexsolo.OBEXConnector;

public void run() {
try {
parent.chatMessage(null, "file://"+directory+fileName);
FileConnection conn = (FileConnection)Connector.open("file://"+directory+fileName);
parent.chatMessage(null, String.valueOf(conn.fileSize()));
file = conn.openInputStream();
fileSize = (int)conn.fileSize();
imageData = new byte[fileSize];
file.read(imageData, 0, fileSize);
file.close();
conn.close();
parent.chatMessage(null, "kok gak dieksekusi");

String adr = btAddress;

String adrProto = "btgoep://"+ adr +":9";
System.out.println("adrProto :\n"+ adrProto);

// no lookup code here … put your phone's bt address here!
ClientSession cs = (ClientSession) OBEXConnector.open(adrProto);
System.out.println("opening");

HeaderSet hs = cs.connect(cs.createHeaderSet());
System.out.println("created header set");

hs.setHeader(HeaderSet.NAME, fileName);
hs.setHeader(HeaderSet.TYPE, "text");
System.out.println("putting....");

Operation po = cs.put(hs);
System.out.println("put....");

po.openOutputStream().write(imageData);
po.close();

}catch(IOException e) {
parent.chatMessage(null, "[client] "+e);
return;
}
}
please help my how to send file from mobile phone to my computer, i just want my computer receive file or OBEXServeron my computer.
Last edited by saifulhq : 2007-07-30 at 18:44.
Reply With Quote

#2 Old Re: send file from mobile phone to PC - 2007-07-30, 18:42

Join Date: Aug 2006
Posts: 78
saifulhq
Offline
Regular Contributor
this is Error on OBEXserver (computer) :

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: javax.bluetooth.LocalDevice.updateRecord(Ljavax/bluetooth/ServiceRecordV
at de.avetana.obexsolo.OBEXConnector.open(OBEXConnector.java:94)
at HTBTServer.actionPerformed(HTBTServer.java:76)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

i was read replay from Jim in http://discussion.forum.nokia.com/fo...t=99783&page=2 to recompile aventanaOBEX with new OBEXConnector. i get the avetanaOBEX from vietcove, that is new not implemented the new OBEXConnector like from Jim.
Last edited by saifulhq : 2007-07-30 at 19:08.
Reply With Quote

#3 Old Re: send file from mobile phone to PC - 2007-07-30, 18:59

Join Date: Aug 2006
Posts: 78
saifulhq
Offline
Regular Contributor
this is error on mobile phone (Nokia E50):

[client] java.io.IOException SymbianOS.error = -34
Reply With Quote

#4 Old Re: send file from mobile phone to PC - 2007-08-05, 07:36

Join Date: Dec 2005
Posts: 1,159
Location: England,UK
jimgilmour1's Avatar
jimgilmour1
Offline
Forum Nokia Champion
Hi,
There is an example of file tranfer in J2ME on the Wiki at.
http://wiki.forum.nokia.com/index.ph...EX%29_protocol

Jim
Reply With Quote

#5 Old Re: send file from mobile phone to PC - 2007-08-07, 06:47

Join Date: Nov 2006
Posts: 186
Location: Pune, india
sagars's Avatar
sagars
Offline
Regular Contributor
Can we develop a same code in VB.

please help
Reply With Quote

#6 Old Re: send file from mobile phone to PC - 2007-08-07, 18:00

Join Date: Dec 2005
Posts: 1,159
Location: England,UK
jimgilmour1's Avatar
jimgilmour1
Offline
Forum Nokia Champion
Quote:
Originally Posted by sagars View Post
Can we develop a same code in VB.

please help
The only thing I know is http://msdn2.microsoft.com/en-gb/embedded/Aa714533.aspx
Which is MicroSoft on bluetooth but its Windows CE embedded version
There is no Visual Basic embedded

http://search.msdn.microsoft.com/sea...=00&lang=en-us

Oh yes and the error

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError
this is the java windows error


Jim
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
[announce] PyUIQ. Python for UIQ 2.1 and 3.x OscarBernabeu Python 35 2008-01-17 10:12
What is the error in my code here? Unable to Save document to file yuva69 General Symbian C++ 1 2005-05-26 15:22
Sending .jpg file from phone to PC ja_calulot General Symbian C++ 0 2003-09-06 10:34
Mounting file system on Mobile Phone. ehsvgup Symbian Networking & Messaging 0 2003-08-21 08:07
Looking for help from member......pl...help me in my source code. yuva69 General Symbian C++ 0 2002-06-10 13:24

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia