irlib.h
declares the IR library API. For more information on the IR library, see the chapter "Beaming (Infrared Communication)" in the Palm OS Programmer's Companion.
/* Forward declaration of the IrConnect structure */
typedef struct _hconnect IrConnect;
/*------------------------------------------------------------- */
typedef struct _hconnect {
UInt8 lLsap; /* Local LSAP this connection will listen on */
UInt8 rLsap; /* Remote Lsap */
/*============== For Internal Use Only =======================
*
* The following is used internally by the stack and should not be
* modified by the user.
*
*=============================================================*/
UInt8 flags; /* Flags containing state, type, etc. */
UInt8 reserved; /* Explicitly account for 16-bit alignment padding */
IrCallBack callBack; /* Pointer to callback function */
/* Tiny TP fields */
IrPacket
packet; /* Packet for internal use */
ListEntry packets; /* List of packets to send */
UInt16 sendCredit; /* Amount of credit from peer */
UInt8 availCredit; /* Amount of credit to give to peer */
UInt8 dataOff; /* Amount of data less than IrLAP size */
} _hconnect;
typedef struct _IrPacket {
/* The node field must be the first field in the structure. It is
* used internally by the stack. */
ListEntry node;
/* The buff field is used to point to a buffer of data to send and
* len field indicates the number of bytes in buff. */
UInt8 *buff;
UInt16 len;
/*================== For Internal Use Only ======================
*
* The following is used internally by the stack and should not be
* modified by the upper layer.
*
*==============================================================*/
IrConnect* origin; /* Pointer to connection which owns packet */
UInt8 headerLen; /* Number of bytes in the header */
UInt8 header[14]; /* Storage for the header */
UInt8 reserved; /*Explicitly account for 16-bit alignment padding*/
} IrPacket;
obj
parameter to the
IrIAS_Add
function.
typedef struct _IrIasObject {
UInt8 *name; /* Pointer to name of object */
UInt8 len; /* Length of object name */
UInt8 nAttribs; /* Number of attributes */
IrIasAttribute* attribs; /* A pointer to an array of attributes */
} IrIasObject;
name
| Pointer to name of object |
len
| Length of object name |
nAttribs
| Number of attributes |
attribs
| Pointer to an array of attributes |
token
parameter to the
IrIAS_Query
function (and several other functions as well).
* Forward declaration of a structure used for performing IAS
* Queries so that a callback type can be defined for use in
* the structure. */
typedef struct _IrIasQuery IrIasQuery;
typedef void (*IrIasQueryCallBack)(IrStatus);
* Actual definition of the IrIasQuery structure. */
typedef struct _IrIasQuery
{
/* Query fields. The query buffer contains the class name and
* class attribute whose value is being queried--it is as follows:
*
* 1 byte - Length of class name
* "Length" bytes - class name
* 1 byte - length of attribute name
* "Length" bytes - attribute name
*
* queryLen - contains the total number of byte in the query */
UInt8 queryLen; /* Total length of the query */
UInt8 reserved; /* Explicitly account for 16-bit alignment padding */
UInt8 *queryBuf; /* Points to buffer containing the query */
/* Fields for the query result */
UInt16 resultBufSize; /* Size of the result buffer */
UInt16 resultLen; /* Actual number of bytes in the result buffer */
UInt16 listLen; /* Number of items in the result list. */
UInt16 offset; /* Offset into results buffer */
UInt8 retCode; /* Return code of operation */
UInt8 overFlow; /* Set TRUE if result exceeded result buffer size*/
UInt8 *result; /* Pointer to buffer containing result; */
/* Pointer to callback function */
IrIasQueryCallBack callBack;
} _IrIasQuery;
IrCallback
function.
typedef struct {
IrEvent event; /* Event causing callback */
UInt8 reserved1; /* Explicitly account for 16-bit alignment padding */
UInt8 *rxBuff; /* Receive buffer already advanced to app data */
UInt16 rxLen; /* Length of data in receive buffer */
IrPacket* packet; /* Pointer to packet being returned */
IrDeviceList* deviceList; /* Pointer to discovery device list */
IrStatus status; /* Status of stack */
UInt8 reserved2; /* Explicitly account for 16-bit alignment padding */
} IrCallBackParms;
IrConnect
structure. The callback function is called with a pointer to the IrConnect
structure and a pointer to a parameter structure. The parameter structure contains an event
field, which indicates the reason the callback is called, and other parameters, which have meaning based on the event.
rxBuff
and rxLen
.
deviceList
points to the discovery list.
IrConnect
structures is called.
IrConnect
structures is called.
LEVENT_LM_CON_IND
will not be given. The callback function of all bound IrConnect
structures is called.
rxBuff
and rxLen
.
IrConnectRsp
should be called to accept the connection. Any data associated with the connection request can be found using fields rxBuff
and rxLen
, for the data pointer and length, respectively.
rxBuff
and rxLen
, for the data pointer and length, respectively.
packet
.
status
field indicates the status generating the event. Possible statuses are as follows.
status
field indicates if the test was successful. IR_STATUS_SUCCESS
indicates that operation was successful and the data in the test response can be found by using the rxBuff
and rxLen
fields. IR_STATUS_FAILED
indicates that no TEST response was received. The packet passed to perform the test command is passed back in the packet
field and is now available (no separate packet handled event will occur).
rxBuff
and rxLen
. A pointer to the packet that will be sent in response to the test command is in the packet
field. The packet is currently set up to respond with the same data sent in the command TEST frame. If different data is desired as a response, then modify the packet structure. This event is sent to the callback function in all bound IrConnect
structures. The IAS connections ignore this event.
void IrAdvanceCredit (IrConnect* con, UInt8 credit)
  |
--> |
Pointer to IrConnect structure representing connection to which credit is advanced. |
  |
--> |
Amount of credit to advance. |
IrStatus IrBind (UInt16 refNum, IrConnect* con, IrCallBack callBack)
  |
--> |
IR library refNum. |
  |
<--> |
Pointer to IrConnect structure. |
  |
--> |
Pointer to a callBack function that handles the indications and confirmation from the protocol stack. |
IrConnect
structure will be initialized. Any values stored in the structure will be lost. The assigned LSAP will be in the lLsap
field of con
. The type of the connection will be set to IrLMP. The IrConnect
must be bound to the stack before it can be used.
Err IrClose (UInt16 refnum)
IrStatus IrConnectIrLap (UInt16 refNum, IrDeviceAddr deviceAddr)
  |
--> |
IR library refNum. |
  |
--> |
32-bit address of device to which connection should be made. |
IR_STATUS_PENDING
means the operation is started successfully; the result is returned via callback.
IR_STATUS_MEDIA_BUSY
means the operation failed because the media is busy. Media busy is caused by one of the following reasons:
IrConnect
structures via the callback function. The callback event is LEVENT_LAP_CON_CNF
if successful or LEVENT_LAP_DISCON_IND
if unsuccessful.
IrStatus IrConnectReq (UInt16 refNum, IrConnect* con, IrPacket* packet, UInt8 credit)
  |
--> |
IR library refNum. |
IR_STATUS_PENDING
means the operation has been started successfully and the result will be returned via the callback function with the event LEVENT_LM_CON_CNF
if the connection is made or LEVENT_LM_DISCON_IND
if connection fails. The packet is returned via the callback with the event LEVENT_PACKET_HANDLED
.
IR_STATUS_FAILED
means the operation failed because of one of the following reasons. Note that the packet is available immediately.
IrConnect
structure is not bound to the stackIR_STATUS_NO_IRLAP
means the operation failed because there is no IrLAP connection (the packet is available immediately).
IrConnect
structure. The callback event is LEVENT_LM_CON_CNF
indicates that the connection is up and LEVENT_LM_DISCON_IND
indicates that the connection failed. Before calling this function the fields in the con structure must be properly set.
LEVENT_LM_CON_IND
.
IrStatus IrConnectRsp (UInt16 refNum, IrConnect* con, IrPacket* packet, UInt8 credit)
  |
--> |
IR library refNum. |
  |
--> |
Pointer to IrConnect structure to managed connection. |
IR_STATUS_PENDING
means the operation has been started successfully and the packet will be returned via the callback function with the event LEVENT_PACKET_HANDLED
.
IR_STATUS_FAILED
means the operation failed because of one of the following reasons. Note that the packet is available immediately.
IrConnect
structure is not bound to the stackIR_STATUS_NO_IRLAP
means the operation failed because there is no IrLAP connection (the packet is available immediately).
IrConnectRsp
can be called during the callback or later to accept the connection. The type of the connection must already have been set to IrLMP or Tiny TP before the LEVENT_LM_CON_IND
event.
IrStatus IrDataReq (UInt16 refNum, IrConnect* con, IrPacket* packet)
  |
--> |
IR library refNum. |
  |
--> |
Pointer to IrConnect structure that specifies the connection over which the packet should be sent. |
  |
--> |
Pointer to a valid IrPacket structure that contains data to send. The packet should not exceed the max size found with IrMaxTxSize . |
IR_STATUS_PENDING
means the packet has been queued by the stack. The packet will be returned via the callback with event LEVENT_PACKET_HANDLED
.
IR_STATUS_FAILED
means the operation failed because of one of the following reasons. Note that the packet is available immediately.
LEVENT_PACKET_HANDLED
. The largest packet that can be sent is found by calling
IrMaxTxSize
.
IrStatus IrDisconnectIrLap (UInt16 refNum)
IR_STATUS_PENDING
means the operation started successfully and all bound IrConnect
structures will be called back when complete.
IR_STATUS_NO_IRLAP
means the operation failed because no IrLAP connection exists.
IrConnect
structures is called with event LEVENT_LAP_DISCON_IND
.
IrStatus IrDiscoverReq (UInt16 refNum, IrConnect* con)
  |
--> |
IR library refNum. |
  |
--> |
Pointer to a bound IrConnect structure. |
IR_STATUS_PENDING
means the operation is started successfully; the result is returned via callback.
IR_STATUS_MEDIA_BUSY
means the operation failed because the media is busy. Media busy is caused by one of the following reasons:
IR_STATUS_FAILED
means the operation failed because the IrConnect
structure is not bound to the stack.
IrConnect
structure with the event LEVENT_DISCOVERY_CNF
. Only one discovery can be invoked at a time.
BOOL IrIsIrLapConnected (UInt16 refNum)
IR_IS_LAP_FUNCS
is defined.
BOOL IrIsMediaBusy (UInt16 refNum)
BOOL IrIsNoProgress (UInt16 refNum)
BOOL IrIsRemoteBusy (UInt16 refNum)
void IrLocalBusy (UInt16 refNum, BOOL flag)
  |
--> |
IR library refNum. |
  |
--> |
Value (true or false) to set for IrLAP's local busy flag. |
UInt16 IrMaxRxSize (UInt16 refNum, IrConnect* con)
  |
--> |
IR library refNum. |
  |
--> |
Pointer to IrConnect structure that represents an active connection. |
UInt16 IrMaxTxSize (UInt16 refNum, IrConnect* con)
  |
--> |
IR library refNum. |
  |
--> |
Pointer to IrConnect structure that represents an active connection. |
Err IrOpen (UInt16 refnum, UInt32 options)
  |
--> |
IR library refNum. This value is returned from the function SysLibFind , which you must call first to load the IR library. |
  |
--> |
Open options flags. See the Comments section for details. |
IrConnect
structure is bound to the stack.
void IrSetConTypeLMP (IrConnect* con)
IrConnect
structure is bound to the stack.
void IrSetConTypeTTP (IrConnect* con)
IrStatus IrSetDeviceInfo (UInt16 refNum, UInt8 *info, UInt8 len)
  |
--> |
IR library refNum. |
  |
--> |
Pointer to array of bytes. |
  |
--> |
Number of bytes pointed to by info . |
IR_STATUS_SUCCESS
means the operation is successful.
IR_STATUS_FAILED
means the operation failed because info
is too big.
IR_MAX_DEVICE_INFO
bytes.
IrStatus IrTestReq (UInt16 refNum, IrDeviceAddr devAddr, IrConnect* con, IrPacket* packet)
  |
--> |
IR library refNum. |
  |
--> |
Device address of device where TEST will be sent. This address is not checked so it can be the broadcast address or 0. |
  |
--> |
Pointer to IrConnect structure specifying the callback function to call to report the result. |
IR_STATUS_PENDING
means the operation has been started successfully and the result will be returned via the callback function with the event LEVENT_TEST_CNF
. This is also the indication returning the packet.
IR_STATUS_FAILED
means the operation failed because of one of the following reasons. Note that the packet is available immediately.
IR_STATUS_MEDIA_BUSY
means the operation failed because the media is busy or the stack is not in the NDM state (the packet is available immediately).
IrConnect
structure. The callback event is LEVENT_TEST_CNF
and the status field indicates the result of the operation. IR_STATUS_SUCCESS
indicates success and IR_STATUS_FAILED
indicates no response was received. A packet must be passed containing the data to send in the TEST frame. The packet is returned when the LEVENT_TEST_CNF
event is given.
IrConnect
structure from the protocol stack, freeing it's LSAP selector.
IrStatus IrUnbind (UInt16 refNum, IrConnect* con)
  |
--> |
IR library refNum. |
  |
--> |
Pointer to IrConnect structure to unbind. |
IrStatus IrIAS_Add (UInt16 refNum, IrIasObject* obj)
IR_STATUS_SUCCESS
means the operation is successful.
IR_MAX_IAS_NAME
. Also, attribute values must not exceed IR_MAX_IAS_ATTR_SIZE
.
IAS_ATTRIB_INTEGER
. (Call
IrIAS_GetType
to determine the type of the current result item.)
IrIAS_GetInteger (t)
UInt32
.
IAS_ATTRIB_INTEGER
. (Call
IrIAS_GetType
to determine the type of the current result item.) Usually integer values returned in a query are LSAP selectors.
IrIAS_GetIntLsap (t)
UInt8
.
IrIAS_GetObjectID (t)
UInt16
type.
IrIAS_GetType
to determine the type of the current result item.)
IrIAS_GetOctetString (t)
UInt8
.
IAS_ATTRIB_OCTET_STRING
. (Call
IrIAS_GetType
to determine the type of the current result item.)
IrIAS_GetOctetStringLen (t)
UInt16
.
IrIAS_GetType (t)
IAS_ATTRIB_INTEGER
, IAS_ATTRIB_OCTET_STRING
or IAS_ATTRIB_USER_STRING
. The return value is of type UInt8
.
IAS_ATTRIB_USER_STRING
. (Call
IrIAS_GetType
to determine the type of the current result item.)
IrIAS_GetUserString(t)
UInt8
.
IAS_ATTRIB_USER_STRING
. (Call
IrIAS_GetType
to determine the type of the current result item.)
IrIAS_GetUserStringCharSet(t)
IrCharSet
value.
IAS_ATTRIB_USER_STRING
. (Call
IrIAS_GetType
to determine the type of the current result item.)
IrIAS_GetUserStringLen (t)
UInt8
value.
UInt8* IrIAS_Next (UInt16 refNum, IrIasQuery* token)
IrStatus IrIAS_Query (UInt16 refNum, IrIasQuery* token)
  |
--> |
IR library refNum. |
  |
--> |
Pointer to an IrIasQuery structure initialized as described in the Comments section. |
IR_STATUS_SUCCESS
means the operation is started successfully and the result will be signaled via the callback function.
IR_MAX_QUERY_LEN
.result
field of token
is 0.resultBufSize
field of token
is 0.callback
field of token
is 0.IR_STATUS_NO_IRLAP
means the operation failed because there is no IrLAP connection.
IrIasQuery
structure. Only one query can be made at a time.
IrIasQuery
structure passed in the token
parameter must be initialized as follows:
result
points to a buffer large enough to hold the result of the query.resultBufSize
is set to the size of the result buffer.queryBuf
must point to a valid query.queryLen
is set to the number of bytes in queryBuf
. The length must not exceed IR_MAX_QUERY_LEN
.value
field of the device name attribute of the "Device" object in the IAS database.
IrStatus IrIAS_SetDeviceName (UInt16 refNum, UInt8 *name, UInt8 len)
  |
--> |
IR library refNum. |
  |
--> |
Total length of the value field. Maximum size allowed is IR_MAX_IAS_ATTR_SIZE . |
IR_STATUS_SUCCESS
means the operation is successful.
IR_STATUS_FAILED
means len
is too big, or the value
field is not a valid user string.
IrIAS_StartResult(t)
callBack
field of the
IrIasQuery
structure.
void IrIasQueryCallBack (IrStatus status)
  |
|
The status of the query operation. The following values can be passed: |
  |
|
|
  |
|
|
  |   |