Implementing a child device (MININODES)
We look at the basic implementation of a child device.
Module definition, include
#define ToCoNet_USE_MOD_NWK_LAYERTREE_MININODES
// includes
#include "ToCoNet.h"
#include "ToCoNet_mod_prototype.h"cbAppColdStart()
The application ID and channel are determined here. The initialization process is described in the vProcessEvCore() function.
void cbAppColdStart(bool_t bAfterAhiInit) {
if (!bAfterAhiInit) { // before AHI init, very first of code.
// Register modules
ToCoNet_REG_MOD_ALL();
} else {
// TWELITE NET configuration
/// Application ID
sToCoNet_AppContext.u32AppId = 0x12345678;
sToCoNet_AppContext.u8Channel = 18;
/// Receiver circuit is OFF
sToCoNet_AppContext.bRxOnIdle = FALSE;
/// Keep CCA to a minimum
sToCoNet_AppContext.u8CCA_Level = 1;
sToCoNet_AppContext.u8CCA_Retry = 0;
/// Postpone MAC initialisation at boot.
/// Initialised just before transmission, or not if not required.
sToCoNet_AppContext.u8MacInitPending = TRUE;
// Register user PRSEV.
ToCoNet_Event_Register_State_Machine(vProcessEvCore);
}
}cbAppWarmStart()
Hardware initialization and so on are performed in the same way as for simple nets, but the processing specific to relay nets is performed by vProcessEvCore().
cbToCoNet_vNwkEvent()
LayerTree MININODES does not need to handle E_EVENT_TOCONET_NWK_START E_EVENT_TOCONET_NWK_DISCONNECT events, since procedures such as determining the upper node are omitted.
cbToCoNet_vRxEvent()
The method of reception is much the same as for simple nets, with the exception of the tsRxDataApp structure.
vProcessEvCore()
On E_EVENT_START_UP when the system starts, sets the tsToCoNet_NwkLyTr_Config structure, executes the ToCoNet_NwkLyTr_psConfig_MiniNodes() function, initializes the network with the ToCoNet_Nwk_bInit() function and starts the network with the ToCoNet_Nwk_bStart() function.
Execute ToCoNet_Nwk_bPause() before sleep and ToCoNet_Nwk_bResumte() when waking up from sleep.
最終更新