You Are Here:

Community: Developer Discussion Boards

#1 Old Bluetooth OBEX ( image transfer using bluetooth ) problem - 2007-07-21, 19:14

Join Date: Jun 2007
Posts: 27
atiqkamran
Offline
Registered User
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
Reply With Quote

#2 Old Re: Bluetooth OBEX ( image transfer using bluetooth ) problem - 2007-07-25, 18:04

Join Date: Dec 2005
Posts: 1,159
Location: England,UK
jimgilmour1's Avatar
jimgilmour1
Offline
Forum Nokia Champion
Hi,
There is an article on the wiki which might help

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

Good Luck
Jim
Reply With Quote

#3 Old 2007-07-26, 15:08

Join Date: Mar 2003
Posts: 2,617
traud
Offline
Super Contributor
http://discussion.forum.nokia.com/fo...d.php?t=112731
Reply With Quote

#4 Old Re: Bluetooth OBEX ( image transfer using bluetooth ) problem - 2007-07-26, 17:30

Join Date: Aug 2006
Posts: 78
saifulhq
Offline
Regular Contributor
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???
Reply With Quote

#5 Old Re: Bluetooth OBEX ( image transfer using bluetooth ) problem - 2007-07-27, 08:02

Join Date: Jun 2007
Posts: 27
atiqkamran
Offline
Registered User
Can you send me code or part of code so i can better tell you.

BR,
kami
Reply With Quote

#6 Old Re: Bluetooth OBEX ( image transfer using bluetooth ) problem - 2007-07-27, 09:18

Join Date: Aug 2006
Posts: 78
saifulhq
Offline
Regular Contributor
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();
}
}
Reply With Quote

#7 Old Re: Bluetooth OBEX ( image transfer using bluetooth ) problem - 2007-07-27, 09:19

Join Date: Aug 2006
Posts: 78
saifulhq
Offline
Regular Contributor
Quote:
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]
Reply With Quote

#8 Old Re: Bluetooth OBEX ( image transfer using bluetooth ) problem - 2008-08-14, 09:02

Join Date: Aug 2008
Posts: 3
winzter143
Offline
Registered User
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
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
help me on file transfer - pc to phone over bluetooth. kiran10182 Bluetooth Technology 2 2009-09-05 11:07
Can not send any Obex Objects to a billionton bluetooth hoy_cpe Symbian Networking & Messaging 3 2006-08-01 08:28
problems with bluetooth file transfer to 6230? - here's the solution! spyghost Bluetooth Technology 1 2005-01-04 18:16
6230 global problems with Bluetooth asterixmlm General Discussion 1 2004-12-10 18:12
Transfering image to series 40 device problem andk General Symbian C++ 3 2004-04-20 08:40

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