// define module
#define ToCoNet_USE_MOD_ENERGYSCAN
// includes
#include "ToCoNet.h"
#include "ToCoNet_mod_prototype.h"
void inSomeFunc() {
// start energy scan (scan 1ch only)
ToCoNet_EnergyScan_bStart(1 << sAppData.u8channel, 2);
sAppData.bTxBusy = TRUE; // set internal busy flag.
}
void cbToCoNet_vNwkEvent(teEvent eEvent, uint32 u32arg) {
int i;
switch(eEvent) {
case E_EVENT_TOCONET_ENERGY_SCAN_COMPLETE:
_C {
uint8 *pu8Result = (uint8*)u32arg;
sAppData.u8ChEnergy = pu8Result[1];
//save history...
int i, max = 0;
static uint8 u8Hist[8] = { 0 };
static uint8 u8Idx = 0;
u8Hist[(u8Idx++) & 0x7] = pu8Result[1];
for (i = 0; i < 8; i++) {
if (u8Hist[i] > max) max = u8Hist[i];
}
sAppData.u8ChEnergyMax = max;
sAppData.bTxBusy = FALSE;
}
break;
default:
break;
}
}