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.