You Are Here:

Community: Developer Discussion Boards

#1 Old Trying to send text file to phone over bluetooth - 2008-11-26, 05:02

Join Date: Aug 2008
Posts: 4
singhzubin
Offline
Registered User
Hi,
I am having some major issues when trying to send a text file that is stored on my Nokia N95 picture gallery. The program runs in an infinite loop - its for a research project for my school. Please help me out, as the device gives me the following warnings which means it is able to connect to the URL:

Allow _____ to use conectivity applications? --> I select YES on the server (Nokia N95 8GB)
Allow _____ to read user data? --> I select YES on the server (Nokia N95 8GB)
Allow _____ to write user data? --> I select YES on the server (Nokia N95 8GB)

But the text file names "text.txt" residing in the Server (Nokia N95) pictures folder directory is NEVER sent to the device it connected to, which is also a Nokia N95 (8GB).


So my server is an Nokia N95 S60:

I am able to discover all the devices in range and here is the specfic UUID i use to discover the "Obex object Push":

int[] attributes = {0x0100, 0x0200};
UUID[] uuids = new UUID[1];
uuids[0] = new UUID(0x1105L);

---------------------------------------

My connectionURL:
=====================
if(service_name.equals("OBEX Object Push"))
try {
btScanner.sendFile(((ServiceRecord) btScanner.services.elementAt(x)).getConnectionURL(0,false));

} catch (IOException ex) {
ex.printStackTrace();
}
---------------------------------------

Here is the function that handles the "send file" feature:

public void sendFile(String connectionURL) throws IOException {
Connection connection = null;

try {
connection = Connector.open(connectionURL);

ClientSession cs = (ClientSession) connection;
HeaderSet hs = cs.createHeaderSet();
cs.connect(hs);

String file = System.getProperty("fileconn.dir.photos") + "test.txt";
InputConnection fc = (FileConnection) Connector.open(file);
InputStream fis = fc.openInputStream();

byte filebytes[] = new byte[fis.available()];
fis.read(filebytes);
fis.close();

hs = cs.createHeaderSet();
hs.setHeader(HeaderSet.NAME, "test.txt");
hs.setHeader(HeaderSet.TYPE, "text/x-vcard");
hs.setHeader(HeaderSet.LENGTH, new Long(filebytes.length));

Operation putOperation = cs.put(hs);

OutputStream outputStream = putOperation.openOutputStream();
outputStream.write(filebytes);

outputStream.close();
putOperation.close();

cs.disconnect(null);

connection.close();
} catch (Exception e) {
do_alert("IO Error", 4000);
}

}
Last edited by singhzubin : 2008-11-26 at 21:11.
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
Problem with GCCE build in Carbide.vs raffaelbechara General Symbian C++ 6 2008-10-20 17:06
Problem with pyobfuscate JOM Python 3 2008-06-20 23:47
how to send a value from openSUSE Linux to py60 mobile phone via bluetooth? jasonxvii Python 1 2008-01-09 07:38
Contacts fields order?? timatima General Symbian C++ 1 2007-06-08 14:51
nokia 7210 modem via IR doesn't work ! oussamaaiadi PC Suite API and PC Connectivity SDK 1 2003-03-06 11:46

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