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?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| How to create a client application using irDA with the OBEX protocol?
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... |
| Sponsored Links |
| |||
| 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. |
| |||
| 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 ??? |
| |||
| 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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 |