# WM_StartConnect

## Syntax

      #include <nitro/wm.h>

      WMErrCode WM_StartConnect( WMCallbackFunc callback , const WMBssDesc* pInfo , const u8* ssid );

## Arguments

`callback` | Callback function to be called when the notification of the status for the asynchronous process is sent or when the asynchronous process completes. This callback is called from within the interrupt handler.
`pInfo` | Information on the parent to be connected. Structure that is obtained with `WM_StartScan`. Note that this structure entity will be forcibly cached.
`ssid` | Child information, fixed at 24 bytes (`WM_SIZE_CHILD_SSID`), to be sent to the parent. The specified data will be sent to the parent by the callback of `WM_StartParent`. If `NULL`, the 24 bytes of data will be set to all zeros.

## Return Values

Returns the results of the `WMErrCode` enumerated type process.

## Description

Initiates a connection process to a parent. This function is executable only when the WM is in the `IDLE` state. If the return value for the function is `WM_ERRCODE_OPERATING`, a callback is triggered when the connection process starts, the request is approved by the parent, and AID was allocated. The callback is also generated when the normal connection state could not be achieved after starting the connection process. When the connection is complete, the WM changes to the `CHILD` state. After the connection is established, the callback specified by this function is generated when the device is disconnected from the parent. The callback that was specified with this function is also generated if the beacon that was transmitted by the parent on a periodic basis was not received after a set period of time. If the connection process fails along the way and the callback is returned, this indicates that there is an error in the internal state, so try to call the `WM_Reset` function before retrying the `WM_StartConnect` function.

## Note

After calling this function, a callback will be generated when the connection as a child device completes as expected, but sometimes before the callback is generated a notification will be generated that shows that there was a beacon receive notification or a disconnect from the parent device. When performing an initialization process, etc., as the child device, perform it before this function is called rather than when the callback has been generated.
Because the API return value WM_ERRCODE_OVER_MAX_ENTRY sometimes occurs temporarily the instant another inappropriate child device without matching GGID or TGID connects to the parent, we recommend that you retry execution.
This problem can arise easily if another IPL child device arrives for a download connection based on the old beacon of the parent device, particularly in the case of connections made immediately before child device program boot during download play.

The `pInfo` data is forcibly stored in the internal cache. To avoid overwriting surrounding memory regions, be sure to pass data that is 32-byte aligned.
See the Wireless Communication Library Manual (AboutWirelessManager.pdf) for additional details.

## See Also

`WM_StartScan`
`WM_EndScan`
`WM_Disconnect`

## Revision History

2008/12/17 Added a note about how data passed in arguments is forcibly cached internally.
2007/04/12 Added a note about `WM_ERRCODE_OVER_MAX_ENTRY`.
2005/06/08 Added the fact that the callback is called from the interrupt handler.
2005/02/07 Added a note about the callback.
2004/10/27 Added to and revised Description.
2004/10/22 Changed the type of return values.
2004/08/23 Added the ssid argument.
2004/08/02 Standardized structure names.
2004/07/29 Added to Description.
2004/07/23 Initial version.

CONFIDENTIAL