IT Community - Software Programming, Web Development and Technical Support

How to create a client application using irDA with the OBEX protocol?

This is a discussion on How to create a client application using irDA with the OBEX protocol? within the Mobile Software Development forums, part of the Software Development category; How to create a client application using irDA with the OBEX protocol?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Mobile Software Development

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-30-2007, 01:09 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Question How to create a client application using irDA with the OBEX protocol?

How to create a client application using irDA with the OBEX protocol?
__________________
The OXYGEN
Delivers edgy, intelligent Technology to all...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-30-2007, 01:13 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: How to create a client application using irDA with the OBEX protocol?

As the OBEX API is based on the Generic Connection Framework (GCF) it is easy to create a normal HTTP connection.To create a client connection, you simply use the Connector.open(String url) method.

The URL for OBEX should be formatted according to GCF framework: {protocol}:[{target}][{params}] where the protocol is set to "irdaobex".

The target can be "discover", "addr", "conn", or "name".

The "discover" target is used for searching for Infrared devices nearby and we will use this as we want to connect to any Sony Ericsson mobile phone in our immediate surroundings.

ClientSession session = (ClientSession) Connector.open("irdaobex://discover");

The Connector factory returns a ClientSession object which is the client-side connection object for OBEX. It extends the Connection interface and adds methods for OBEX requests and defines headers for the OBEX operations.

Use the ClientSession object to start a CONNECT operation.

HeaderSet head = session.connect(null);

The returned Headerset object is used to add headers for this session. First, tell the OBEX server the length of the message.

head.setHeader(head.LENGTH, new Long(messageBytes.length));

Then instruct the server that your message should be saved as JUMAR.TXT.

head.setHeader(HeaderSet.NAME, " JUMAR.TXT ");

We are now ready to initiate the PUT request with the defined header.

Operation op = session.put(head);

The returned Operation object extends the ContentConnection interface and adds functionality for header manipulation. Use it to open an OutputStream to the server.

OutputStream out = op.openOutputStream();

Now you can send your message as a byte array to the server.

out.write(new String("Hello there").getBytes());
out.flush();

Don't forget to end the session with the DISCONNECT operation and close the ClientSession,

session.disconnect(null);
session.close();

as well as the Operation and the OutputStream.

out.close();
op.close();

You can easily send your message as a calendar note or a contact by formatting the message and specifying the correct file type with the NAME header. For example if you want to send a calendar note containing the message "Hello there" you first have to set the name header to the calendar notes file type ".vnt":

head.setHeader(HeaderSet.NAME, "VNote.vnt");

This will make the receiving Sony Ericsson phone aware that there is a calendar note coming. Now format the message according to VNote format:

BEGIN:VNOTE
VERSION:1.1
BODY:Hello there
END:VNOTE

Now the message is ready to be sent.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-06-2007, 10:40 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default Re: How to create a client application using irDA with the OBEX protocol?

That is nice. But I cannot find a proper reason to use IrDA to communicate between applications on two mobile devices. They have to be kept at 10-15 cm distance, one's sensor facing the other. Will that be easy to use some applications in that position ???
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-09-2007, 03:07 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Default Re: How to create a client application using irDA with the OBEX protocol?

using this same application is not the better option..since the distance between the two mobile where kept nearly 10-15 cm ...and the infrared cant penerate to that extend...obex protocol with bluetooth will be better for transfering files...point me if i made any mistake.....
__________________
cheers
Aman
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create an auto startup application on WM5 ? theone Windows Mobile 1 07-30-2007 03:49 AM
Client server Testing & Web Based Application Testing vigneshgets Software Testing 1 07-27-2007 07:54 AM
difference between client server application testing & web application testing vigneshgets Software Testing 1 07-27-2007 05:28 AM
About ISDN protocol Jeyaseelansarc Server Management 0 05-18-2007 02:38 AM
Desktop,Web & client server application vadivelanvaidyanathan Software Testing 1 04-13-2007 04:12 AM


All times are GMT -7. The time now is 08:59 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0