Implementation of repeaters
We look at the basic implementation of a repeater.
Module definition, include
#define ToCoNet_USE_MOD_NWK_LAYERTREE
#define ToCoNet_USE_MOD_NBSCAN
#define ToCoNet_USE_MOD_NBSCAN_SLAVE
#define ToCoNet_USE_MOD_NWK_MESSAGE_POOL
#define ToCoNet_USE_MOD_DUPCHK
// 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
sToCoNet_AppContext.u32AppId = 0x12345678;
sToCoNet_AppContext.u8Channel = 18;
sToCoNet_AppContext.bRxOnIdle = TRUE;
// Register user PRSEV.
ToCoNet_Event_Register_State_Machine(vProcessEvCore);
}
}cbToCoNet_vNwkEvent()
The relay processes the E_EVENT_TOCONET_NWK_START E_EVENT_TOCONET_NWK_DISCONNECT message.
cbToCoNet_vRxEvent()
The method of reception is much the same as for simple nets, with the exception of the tsRxDataApp structure.
vProcessEvCore()
On system start-up E_EVENT_START_UP of the data, set the tsToCoNet_NwkLyTr_Config structure, execute the ToCoNet_NwkLyTr_psConfig() function, initialize the network with the ToCoNet_Nwk_bInit() function and start the network with the ToCoNet_Nwk_bStart() function.
The setting must specify the repeater (TOCONET_NWK_ROLE_ROUTER), the number of layers, and the NB beacon (TOCONET_MOD_LAYERTREE_STARTOPT_NB_BEACON).
We get E_EVENT_TOCONET_NWK_START event after network start. It also receives E_EVENT_TOCONET_NWK_DISCONNECT if the upper node is lost.
最終更新