Irda is not fun on the Palm...
- swap the two lines
err = IrBind(refNum, &IrCon, IrHandler);
IrSetDeviceInfo(refNum, MyDeviceInfo, MyDeviceInfoLen);
to
IrSetDeviceInfo(refNum, MyDeviceInfo, MyDeviceInfoLen);
err = IrBind(refNum, &IrCon, IrHandler);
(set device info before you bind)
Now for the bad news... You're not going to be able to do the discovery
right after the bind, because the media will be busy for a little while. You
can try waiting for it to go non-busy:
while (IrIsMediaBusy (refNum))
SysTaskDelay(SysTicksPerSecond()/10));
That gives the Irda stack a chance to come up. Then you can do the
irStatus = IrDiscoverReq(refNum, &IrCon);
==-
John Schettino author of
Palm OS Programming For Dummies, http://schettino.tripod.com
-----Original Message-----
From: Matchz [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 06, 2000 7:41 PM
To: [EMAIL PROTECTED]
Subject: A chat program using Irda between Palm and PC
I am trying to write a chat program using Irda between a Palm and PC.
On the PC side, I use winsock2. I initialize the sock as follow:
SOCKET cli_sock = socket(AF_IRDA, SOCK_STREAM, 0);
SOCKADDR_IRDA srv_addr = {AF_IRDA, 0, 0, 0, 0, "PALMDEMO"};
bind(cli_sock,(LPSOCKADDR)&cli_addr,sizeof(cli_addr));
The code work well for 2 PC both have an Irda port.
So I try to program the palm side. I start the Irda service as follow:
static UInt refNum;
static IrConnect IrCon;
static Byte MyDeviceInfo[] = {IR_HINT_PDA, IR_CHAR_ASCII,
'P','A','L','M','D','E','M','O'};
static Byte MyDeviceInfoLen = sizeof(MyDeviceInfo);
err = SysLibFind(irLibName, &refNum);
err = IrOpen(refNum, irOpenOptSpeed9600);
err = IrBind(refNum, &IrCon, IrHandler);
IrSetDeviceInfo(refNum, MyDeviceInfo, MyDeviceInfoLen);
irStatus = IrDiscoverReq(refNum, &IrCon);
switch (irStatus) {
case IR_STATUS_MEDIA_BUSY:
SetStatus("IR Status Media Busy");
break;
case IR_STATUS_FAILED:
SetStatus("IR Status Failed");
IrUnbind(refNum, &IrCon);
IrClose(refNum);
break;
case IR_STATUS_PENDING:
SetStatus("IR Status Pending => Success");
handled = true;
}
However, function IrDisvocerReq always return IR_STATUS_MEDIA_BUSY while I
expect a IR_STATUS_PENDING should be returned. We can assume that the
statements before IrDisvoverReq always return no error.
Do I make any mistake in the statements above, what should I pay attention
when I
programming Irda?
Thank you.
Matchz.