# WMPortRecvCallback

## Definitions

  `#include <nitro/wm.h>`

      typedef struct WMPortRecvCallback
      {
          u16             apiid;
          u16             errcode;
          u16             state;
          u16             port;
          WMMpRecvBuf*    recvBuf;
          u16*            data;
          u16             length;
          u16             aid;
          u8              macAddress[6];
          u16             seqNo;
          void*           arg;
          u16             myAid;
          u16             connectedAidBitmap;
          u8              ssid[24];
          u16             reason;
          u16             rsv;

      } WMPortRecvCallback;

## Elements

apiid | This is the ID of the API that acts as the source for the callback generation. It is synonymous to the `WMApiid` enumerated type. This argument is fixed to `WM_APIID_PORT_RECV`.
errcode | This is the result of the asynchronous process. It is synonymous to the `WMErrCode` enumerated type.
state | If `errcode` is `WM_ERRCODE_SUCCESS`, the cause code generated by the callback is stored. There are five possible causes: WM_STATECODE_PORT_INIT, WM_STATECODE_PORT_RECV, WM_STATECODE_CONNECTED, ;WM_STATECODE_DISCONNECTED, WM_STATECODE_DISCONNECTED_FROM_MYSELF.
port | Stores the port that received the data.
recvBuf | This member was prepared for compatibility with `WMStartMPCallback`.
data | Stores the address of the buffer that received the data.
length | Stores the length of the received data.
aid | Stores the AID of the source that sent the received data. Note that the `WM_STATECODE_CONNECTED` acknowledgement also contains the AID of the other machine. If a parent machine, it is fixed at 0 (the parent's AID).
macAddress | When the state is WM_STATECODE_CONNECTED, WM_STATECODE_DISCONNECTED, or WM_STATECODE_DISCONNECTED_FROM_MYSELF, stores the MAC address of the connected or disconnected child.
seqNo | Stores the sequence number.
arg | Stores the argument that is specified by the `WM_SetPortCallback` function.
myAid | Stores this machine's AID.
connectedAidBitmap | The AID bitmap during connection is stored.
ssid | Stores the ssid specified by the child using `WM_StartConnect`. Only valid during parent's `WM_STATECODE_CONNECTED` acknoweledgement.
reason | Stores the code showing the reason for disconnection when the state is WM_STATECODE_DISCONNECTED or WM_STATECODE_DISCONNECTED_FROM_MYSELF. This member is used internally in the library for debugging.
rsv | Reserved.

## Description

This structure is passed to the callback function that is set by the `WM_SetPortCallback` function.

## Revision History

02/17/2005 Revised description of code returned in state. 11/14/2005 Restored the description of the `rsv` member that was mistakenly deleted.
10/31/2005 Added `connectedAidBitmap` and `reason` members.
02/01/2005 Added explanations of `myAid` and `ssid` members.
10/05/2004 Standardized MAC address as u8 type
09/13/2004 Changed `WM_STATECODE_CHILD_CONNECTED` to `WM_STATECODE_CONNECTED`
08/11/2004 Initial version.

CONFIDENTIAL