You Are Here:

Community: Developer Discussion Boards

#1 Old Is it possible transfer data using IR port? - 2004-08-27, 17:20

Join Date: Aug 2004
Posts: 9
arqbispo2
Offline
Registered User
How can I send/receive data using IR on MIDP 1.0?
Which phone should I use?

Thanks
Flavio
Reply With Quote

#2 Old 2004-08-30, 12:38

Join Date: Jan 2004
Posts: 82
Location: Mumbai,India
ankur_k
Offline
Regular Contributor
At my end its working fine with Series 60 devices 3650/6600 and on series 40 Device.

You can use the CD provided by S-60 phones & can use Developer Suite for S40 phones.

But the problem I was facing was with OS. It doesnt work properly with 2000. But working with Win-98.
Connect the device & keep it in the range. Then it will show you that it has connected or not. If yes then you can transfer your data.

Ankur
Reply With Quote

#3 Old 2004-08-31, 09:25

Join Date: Mar 2003
Posts: 382
jalev's Avatar
jalev
Offline
Forum Nokia Expert
Nokia 5140 support Java Irda serial port butt he IRComm API is Nokia Proprietary API and do not follow the MIDP 2.0 specification but provides same features. The difference is when requesting an IRComm link, the URL is different than defined in MIDP 2.0 specification.

Detailed Description
Requesting an IRComm link in Nokia 5140 differs from MIDP 2.0 specification in usage of URL. In MIDP 2.0 the IRComm link is opened using:
“comm :<port_name”>
and in Nokia 5140 implementation IRComm link is opened using:
“nokiacomm:<port_name”>

Port numbers can be queried using System.getProperty("microedition.commports")
Nokia5140 returns “IR0” which can be used with URL: nokiacomm for opening the connection.
Connection speed for Irda connection can not be defined. The connection speed is negotiated automatically by the devices in handshake.
Current implementation of Java API ignores the baud rate parameter on the connection and calling the setBaudRate method has no effect and It should not be used.
One thing you need to be aware of is that if you want to connect to the PC you MUST open the PC port first. If you do not, then the phone will not discover the PC.
Examples
This section presents a simple example code that requests IRComm port following MIDP 2.0 specification and if ConnectionNotFoundException is thrown, it tries to open connection using Nokia Proprietary IRComm API.
In MIDP 2.0 IRComm is requested following way:
try {

Connector.open("comm:IR0.....");

} catch (ConnectionNotFoundException cnfe) {

// Do whatever, read or write

} catch (other stuff.....) {

// Do whatever...
}
To make IRComm work in Nokia 5140, the following change is needed in code:

try {

Connector.open("comm:IR0.....");

} catch (ConnectionNotFoundException cnfe) {

try {

Connector.open("nokiacomm:IR0.....");

} catch (ConnectionNotFoundException cnfe) {

// Do whatever you did before...

}

} catch (other stuff.....) {

// Do whatever...

}
Reply With Quote

#4 Old 2004-09-02, 10:01

Join Date: Jul 2004
Posts: 9
zkarpati2
Offline
Registered User
Full story:

As Jalev wrote 5140 uses IrCOMM 9 Wire protocoll. On the mobile's side:

// Open connection
CommConnection commConn = (CommConnection)Connector.open("nokiacomm:IR0");

Funny, but get Baudrate works:

// Get baud rate
info=Integer.toString(commConn.getBaudRate());

Create streams, and use them as it was a TCP socket

// Write text to the port
OutputStream oStream = commConn.openOutputStream();
oStream.write(msg.getBytes());
oStream.write('\r');

// Close connection
commConn.close();

The more tricky part is the PC's side.
First disable the IrTran-P server sitting
on the port we need by Control Panel-> Wireless Link -> Image Transfer -> Use Wireless ....

A code expert for the IrComm server I use (C++):

// buffer for IAS set
BYTE IASSetBuff[sizeof(IAS_SET) - 3 + IAS_SET_ATTRIB_MAX_LEN];
int IASSetLen = sizeof(IASSetBuff);
PIAS_SET pIASSet = (PIAS_SET) &IASSetBuff;

// for the setsockopt call to enable 9 wire IrCOMM
int Enable9WireMode = 1;

// server sockaddr with IrCOMM name
SOCKADDR_IRDA address = { AF_IRDA, 0, 0, 0, 0, "IrDA:IrCOMM" };

SOCKET ServerSock;
SOCKET ClientSock;

// Specifies the server socket address
int index = 0, // Integer index
iReturn; // Return value of recv function
char szServerA[100]; // ASCII string
TCHAR szServerW[100]; // Unicode string
TCHAR szError[100]; // Error message string
WORD WSAVerReq = MAKEWORD(1,1);
WSADATA WSAData;

if (WSAStartup(WSAVerReq, &WSAData) != 0)
{
MessageBox (NULL, TEXT("Error at WSA Startup"), TEXT("Error"), MB_OK);
return FALSE;
}

// Create a socket bound to the server.
if ((ServerSock = socket (AF_IRDA, SOCK_STREAM, 0)) == INVALID_SOCKET)
{
wsprintf (szError, TEXT("Allocating socket failed. Error: %d"),
WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
return FALSE;
}

// add IrCOMM IAS attributes for 3 wire cooked and 9 wire raw, see IrCOMM spec
memcpy(&pIASSet->irdaClassName[0], "IrDA:IrCOMM", 12);
memcpy(&pIASSet->irdaAttribName[0], "Parameters", 11);

pIASSet->irdaAttribType = IAS_ATTRIB_OCTETSEQ;
pIASSet->irdaAttribute.irdaAttribOctetSeq.Len = 6;

memcpy(&pIASSet->irdaAttribute.irdaAttribOctetSeq.OctetSeq[0],
"\000\001\006\001\001\001", 6);

if (setsockopt(ServerSock, SOL_IRLMP, IRLMP_IAS_SET, (const char *) pIASSet, IASSetLen)
== SOCKET_ERROR)
{
wsprintf (szError, TEXT("Setsockopt failed. Error: %d"),
WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
return FALSE;
}

// enable 9wire mode before bind()
if (setsockopt(ServerSock, SOL_IRLMP, IRLMP_9WIRE_MODE, (const char *) &Enable9WireMode,
sizeof(int)) == SOCKET_ERROR)
{
wsprintf (szError, TEXT("Setsockopt failed. Error: %d"),
WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
return FALSE;
}

if (bind(ServerSock, (const struct sockaddr *) &address, sizeof(SOCKADDR_IRDA))
== SOCKET_ERROR)
{
wsprintf (szError, TEXT("Binding socket failed. Error: %d"),
WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
closesocket (ServerSock);
return FALSE;
}


// Establish a socket to listen for incoming connections.
if (listen (ServerSock, 5) == SOCKET_ERROR)
{
wsprintf (szError,
TEXT("Listening to the client failed. Error: %d"),
WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
closesocket (ServerSock);
return FALSE;
}

// Accept a connection on the socket.
if ((ClientSock = accept (ServerSock, 0, 0)) == INVALID_SOCKET)
{
wsprintf (szError, TEXT("Accepting connection with client failed.")
TEXT(" Error: %d"), WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
closesocket (ServerSock);
return FALSE;
}

// Stop listening for connections from clients.
closesocket (ServerSock);

// Send a string from the server socket to the client socket.
if (send (ClientSock, "To Client!", strlen ("To Client!") + 1, 0)
== SOCKET_ERROR)
{
wsprintf (szError,
TEXT("Sending data to the client failed. Error: %d"),
WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
}

// Receive data from the client.
iReturn = recv (ClientSock, szServerA, sizeof (szServerA), 0);

Best regards,

Zoltan
Reply With Quote

#5 Old 2004-10-27, 13:57

Join Date: Oct 2004
Posts: 1
airia
Offline
Registered User
Is it possible to access the Nokia 5140's IR port avoiding the IrCOMM protocol layers?

I would like to connect to a device using low level IR communication (without IrCOMM layers: IrLAP, IrLMP), just open the port (without device discovery), and read/write data.

Is it possible ?

Thanks in advance,

Aitor
Reply With Quote

#6 Old 2005-02-26, 01:50

Join Date: Feb 2005
Posts: 2
mikeballard
Offline
Registered User
hello there

ankur_k says

"At my end its working fine with Series 60 devices 3650/6600 "

does this mean that the example code should work on a 6600?

I have tried it and I just get nulls returned (including System.getProperty("microedition.commports").

Has anyone successfully read or written data to the Irda port on a 6600 using java?

many thanks

Mike
Reply With Quote

#7 Old 2005-07-06, 19:48

Join Date: May 2004
Posts: 41
davidgu
Offline
Registered User
Hello,
From the discussion above, could I conclude that I can control the IR in low level to use it in a given infrared specs?
I have a diagram and wish to know if it is doable in J2ME and by which phone model.

Any help will be appreciated.
Thanks,
David
david@nessicom.com
Last edited by davidgu : 2005-07-06 at 22:31.
Reply With Quote

#8 Old Re: Is it possible transfer data using IR port? - 2005-11-04, 06:52

Join Date: Oct 2005
Posts: 13
yaringal
Offline
Registered User
Can I use s40 phones as well to control IR communication?
Reply With Quote

#9 Old Re: Is it possible transfer data using IR port? - 2007-07-13, 12:07

Join Date: Jul 2007
Posts: 6
kuma88
Offline
Registered User
I think that in my Nokia n80 ie it's not possible to create an application which supported IRDA using Java, does it?
Last edited by kuma88 : 2007-07-13 at 12:13.
Reply With Quote

#10 Old 2007-07-13, 18:01

Join Date: Mar 2003
Posts: 2,617
traud
Offline
Super Contributor
IrOBEX (java.obex) and/or IrCOMM (CommConnection) should be possible since Nokia S60 2nd Edition Feature Pack 3 or Nokia Series 40 3rd Edition + Nokia 5410i. Of course only those models which have IrDA. No other layer like TinyTP, IrLMP or even none.
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 Off
[IMG] code is Off
HTML code is Off
Forum Jump

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