The PalmPilot's Infrared Port
A. J. Musgrove


Example 1:
(a)
Err SysLibFind(CharPtr libName, Word *refNum);

(b)
Err IrOpen(Word refnum, DWord options);
Err IrClose(Word refnum);

(c)
IrStatus IrBind (UInt refNum, IrConnect* con, IrCallBack CallBack);
IrStatus IrUnbind (UInt refNum, IrConnect* con);

(d)
typedef void (*IrCallBack)(IrConnect* con, IrCallbackParms* irData);

(e)
IrStatus IrSetDeviceInfo(UInt refnum, BytePtr info, Byte len);

Example 2:
(a)
IrStatus IrDiscoverReq(UInt refNum, IrConnect *con);

(b)
IrStatus IrConnectIrLap(Uint refnum, IrDeviceAddr deviceAddr);

(c)
IrStatus IrDisconnectIrLap (UInt refnum);


Example 3:

(a)
void IrSetConTypeLMP (IrConnect* con);
void IrSetConTypeTTP (IrConnect *con);

(b)
IrStatus IrConnectReq(UInt refnum, IrConnect* con, 
                              IrPacket* packet, Byte credit);

(c)
IrStatus IrConnectRsp (UInt refnum, IrConnect* con, 
                              IrPacket* packet, Byte credit);

(d)
IrStatus IrDataReq (UInt refnum, IrConnect* con, IrPacket* packet);
Word IrMaxRxSize(UInt refnum, IrConnect* con);

(e)
void IrLocalBusy (UInt refnum, BOOL flag);

(f)
BOOL IrIsLapConnected (UInt refnum);
BOOL IrIsMediaBusy (UInt refnum);
BOOL IrIsNoProgress(UInt refnum);
BOOL IrIsRemoveBusy(UInt refnum);
Word IrMaxRxSize(UInt refnum, IrConnect* con);


Example 4:

IrStatus IrTestReq (UInt refnum, IrDeviceAddr devAddr, 
                               IrConnect* con, IrPacket* packet);




Listing One
static void StartApplication(void )
{
    // check for ir
    if (SysLibFind(irLibName,&irref) != 0)
    {
        irAvail = false;
    }
    else
    {
       if (IrOpen(irref,irOpenOptSpeed115200) != 0)
            irAvail = false;
        else
        {
            irAvail = true;
            IrBind(irref,&connect,BSIrCallBack);
            IrSetDeviceInfo(irref,(BytePtr)&connect.lLsap,1);
            IrSetConTypeLMP(&connect);
        }
    }
    if (!irAvail)
        FrmAlert(NoIRAlert);
    SysGetROMToken(0,sysROMTokenSnum,&serialNo,&serialNoLen);
    SysRandom(TimGetSeconds());
    game.recno = 65535;
    game.started = false;
    CurrentView = StartupFormForm;
    CurrentMenu = MenuInit(StartupMenuBar);
    FrmGotoForm(CurrentView);

    OpenDatabase(); 
}


3


