This is the primary user interface function for the application layer to start communication with an existing PAN. For P2P protocol, this function call can establish one or more connections. For network protocol, this function can be used to join the network, or establish a virtual socket connection with a node out of the radio range. There are multiple ways to establish connection(s), all depends on the input parameters.
Protocol initialization has been done. If only to establish connection with a predefined device, an active scan must be performed before and valid active scan result has been saved.
Parameters |
Description |
BYTE ActiveScanIndex |
The index of the target device in the ActiveScanResults array, if a predefined device is targeted. If the value of ActiveScanIndex is 0xFF, the protocol stack will try to establish a connection with any device. |
BYTE Mode |
The mode to establish a connection. This parameter is generally valid in |
a network protocol. The possible modes are |
|
The index of the peer device on the connection table.
If more than one connections have been established through this function call, the return value points to the index of one of the peer devices.
// Establish one or more connections with any device PeerIndex = MiApp_EstablishConnection(0xFF, CONN_MODE_DIRECT);