MiApp_EstablishConnection Function

MiWi Development Environment

MiWi(TM) Development Environment Help
MiApp_EstablishConnection Function
C
BYTE MiApp_EstablishConnection(
    BYTE ActiveScanIndex, 
    BYTE Mode
);
Description

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.

Preconditions

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
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 
  • CONN_MODE_DIRECT Establish a connection within radio range.
  • CONN_MODE_INDIRECT Establish a virtual connection with a device that may be in or out of the radio range. This mode sometimes is called cluster socket, which is only valid for network protocol. The PAN Coordinator will be involved to establish a virtual indirect socket connection.

 

Returns

The index of the peer device on the connection table.

Remarks

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.

Example
// Establish one or more connections with any device
PeerIndex = MiApp_EstablishConnection(0xFF, CONN_MODE_DIRECT);
Microchip My Application xx.yy - [Jan 1, 2009]
Copyright © 2009 Microchip Technology, Inc.  All rights reserved.