# WMPortRecvCallback

## Definition

  `#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             rssi;
          u16             maxSendDataSize;
          u16             maxRecvDataSize;

      }WMPortRecvCallback;

## Elements

`apiid` | ID of the API that acts as the source for the callback generation. It is equivalent to the `WMApiid` enumerated type. This argument is fixed to `WM_APIID_PORT_RECV`.
`errcode` | Result of the asynchronous process. It is equivalent to the `WMErrCode` enumerated type.
`state` | If `errcode` is `WM_ERRCODE_SUCCESS`, the WM 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` | Port that received the data.
`recvBuf` | Prepared for compatibility with `WMStartMPCallback`.
`data` | Address of the buffer that received the data.
`length` | Length of the received data.
`aid` | 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` | If `state` is `WM_STATECODE_DISCONNECTED` or `WM_STATECODE_DISCONNECTED_FROM_MYSELF`, stores the connected or disconnected child's MAC address.
`seqNo` | Sequence number.
`arg` | Argument that is specified by the `WM_SetPortCallback` function.
`myAid` | This machine's AID.
`connectedAidBitmap` | AID bitmap during connection is stored.
`ssid` | SSID specified by the child using `WM_StartConnect`. Only valid during parent's `WM_STATECODE_CONNECTED` acknowledgement.
`reason` | 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.
`rssi` | Stores the signal intensity when data is received.
`maxSendDataSize` | The size specified for send data. Stores the parent device send data size when operating as a parent, or the child send data size when operating as a child.
`maxRecvDataSize` | The size specified for received data. Stores the child device send data size when operating as a parent, or the parent send data size when operating as a child.

## Description

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

## Revision History

2009/01/27 Deleted the rsv member, and added the rssi, maxSendDataSize, and maxSendDataSize members.
006/02/17 Revised the description of codes returned in `state`.
2005/11/14 Restored the description of the rsv members, which was mistakenly deleted.
2005/10/31 Added the connectedAidBitmap and reason members.
2005/02/01 Added a description of the myAid and ssid members.
2004/10/05 Standardized MAC addresses as u8 type arrays.
2004/09/13 Changed `WM_STATECODE_CHILD_CONNECTED` to `WM_STATECODE_CONNECTED`.
2004/08/11 Initial version.

CONFIDENTIAL