1.7.1.1 G3 Management
The G3 management application file (app_g3_management.c) manages the G3 stack,
including:
- Network discovery and join. A random back-off is performed before starting network discovery and join. The back-off is restarted if Beacon, LOADNG or LBP frames are seen. This is done to avoid collisions during network formation.
- Configuration of G3 stack (ADP, MAC and LBP) parameters, including specific configuration for G3 Conformance tests.
The state machine is implemented in the
APP_G3_MANAGEMENT_Tasks()
function. LBP_TasksDev()
must be called periodically to maintain LBP
Device state machine. The different states are:APP_G3_MANAGEMENT_STATE_ADP_OPEN
: First state in which ADP is opened.APP_G3_MANAGEMENT_STATE_WAIT_ADP_READY
: ADP status is checked and when it is ready, G3 stack (ADP, MAC and LBP) parameters are configured (using_APP_G3_MANAGEMENT_InitializeParameters()
function) and the LBP Device module is initialized (including callback configuration).APP_G3_MANAGEMENT_STATE_START_BACKOFF_DISCOVERY
: Random back-off is started before network discovery.APP_G3_MANAGEMENT_STATE_BACKOFF_DISCOVERY
: When back-off time expires, network discovery is started if Beacon, LOADNG or LBP frames haven’t been seen in the network; otherwise a new back-off is performed.APP_G3_MANAGEMENT_STATE_SCANNING
: Network discovery in progress. When a network is found (Beacon received) it is indicated by_ADP_DiscoveryIndication()
callback function. The end of discovery is indicated by_ADP_DiscoveryConfirm()
callback function.APP_G3_MANAGEMENT_STATE_START_BACKOFF_JOIN
: Random back-off is started before network join.APP_G3_MANAGEMENT_STATE_BACKOFF_JOIN
: When back-off time expires, network join is requested if Beacon, LOADNG or LBP frames haven’t been seen in the network; otherwise a new back-off is performed.APP_G3_MANAGEMENT_STATE_JOINING
: Network join in progress. The end of join process is indicated by_LBP_ADP_NetworkJoinConfirm()
callback function.APP_G3_MANAGEMENT_STATE_JOINED
: The Device is joined to the network, unless_LBP_ADP_NetworkLeaveIndication()
callback function is called.APP_G3_MANAGEMENT_STATE_ERROR
: There was an error during G3 stack initialization, probably because neither PLC nor RF transceivers are available.
Three ADP callbacks are registered:
_ADP_DiscoveryIndication()
: A network is found (Beacon received). If Link Quality is more than the minimum required and Route Cost to Coordinator is less than the maximum required, the PAN descriptor is stored if it has better parameters than the one stored previously._ADP_DiscoveryConfirm()
: It indicates the end of network discovery. If a good Beacon has been found, the state machine is updated to start back-off before network join (APP_G3_MANAGEMENT_STATE_START_BACKOFF_JOIN
), otherwise it is updated to start back-off before a new network discovery (APP_G3_MANAGEMENT_STATE_START_BACKOFF_DISCOVERY
)._ADP_NonVolatileDataIndication()
: The G3 stack indicates that non-volatile parameters have changed and need to be updated in non-volatile memory. This is notified to storage application throughAPP_STORAGE_UpdateNonVolatileData()
function.
Two LBP Device callbacks are registered:
_LBP_ADP_NetworkJoinConfirm()
: It indicates the end of network join process. If it is successful, Context Information Table is updated with PAN ID, a route request is started to Coordinator and UDP responder application is notified to set IPv6 addresses throughAPP_UDP_RESPONDER_NetworkJoined()
function._LBP_ADP_NetworkLeaveIndication()
: It indicates that the Device has been kicked from the network. ADP is reset internally, so G3 stack (ADP, MAC and LBP) parameters have to be configured again, which is done by updating state machine toAPP_G3_MANAGEMENT_STATE_WAIT_ADP_READY
. UDP responder application is notified to remove IPv6 addresses throughAPP_UDP_RESPONDER_NetworkDisconnected()
function.
In order to configure the application to pass the G3 Conformance certification tests, the
function
APP_G3_MANAGEMENT_SetConformanceConfig()
must be called. In
the provided example this is done at initialization if macro
APP_G3_MANAGEMENT_CONFORMANCE_TEST
is defined (uncomment it in
app_g3_management.h):/* If APP_G3_MANAGEMENT_CONFORMANCE_TEST macro is defined, ADP parameters are
* configured according to Conformance test */
#define APP_G3_MANAGEMENT_CONFORMANCE_TEST
The user could implement
another method to configure it dynamically.There are another functions that are called from UDP responder application:
APP_G3_MANAGEMENT_GetPanId()
: Returns the PAN ID of the network.APP_G3_MANAGEMENT_GetShortAddress()
: Returns the Short Address of the Device.APP_G3_MANAGEMENT_GetCoordinatorShortAddress()
: Returns the Short Address of the Coordinator.APP_G3_MANAGEMENT_GetExtendedAddress()
: Returns the Extended Address (EUI64) of the Device.APP_G3_MANAGEMENT_SetConformanceTrickleConfig()
: Configures Trickle Mode from an UDP message, required by G3 Conformance certification tests.APP_G3_MANAGEMENT_SetConfigRF()
: Configures the RF PHY layer from an UDP message, required by G3 Conformance certification tests.APP_G3_MANAGEMENT_SetContinuousTxRF()
: Configures the RF PHY layer in continuous transmission mode, required by G3 Conformance certification tests.APP_G3_MANAGEMENT_SetLastGaspMode()
: Configures Last Gasp Mode from an UDP message, required by G3 Conformance certification tests.