void IdleTask(event_t events) { /* Just to avoid the compiler warning */ (void)events; #if gNvStorageIncluded_d /* Process NV Storage save-on-idle and save-on-count requests. */ NvIdle(); #endif #if (gLpmIncluded_d == 1) /*Low power management*/ if(PWR_CheckIfDeviceCanGoToSleep()) { PWR_EnterLowPower(); } #endif /*gLpmIncluded_d*/ }
/* This function is used to save data appropriately (usually interval) based on object type */ void ZdoNwkMng_SaveToNvm(zdoNvmObject_t iNvmObject) { switch(iNvmObject) { /* Save network data and/or neighbor table. */ case zdoNvmObject_NwkData_c: case zdoNvmObject_NeighborTable_c: ZdoNwkMng_SaveDataSet(gNvDataSet_Nwk_ID_c); break; /* Saves address map and Aps secure material if Link key enable. */ case zdoNvmObject_AddrMap_c: //ZdoNwkMng_SaveDataSet(gNvDataSet_Aps_Sec_ID_c); break; case zdoNvmObject_AddrMapPermanent_c: ZdoNwkMng_SaveDataSet(gNvDataSet_Aps_Sec_ID_c); break; /* All the data related to communication is saved here. */ case zdoNvmObject_BindingTable_c: /*save addressmap when binding is saved as well*/ ZdoNwkMng_SaveDataSet(gNvDataSet_Aps_Sec_ID_c); /*fall through*/ case zdoNvmObject_GroupTable_c: case zdoNvmObject_RoutingTable_c: case zdoNvmObject_ZclData_c: ZdoNwkMng_SaveDataSet(gNvDataSet_App_ID_c); break; #if gStandardSecurity_d || gHighSecurity_d /* Saves the Aps security material set plus the address map. */ case zdoNvmObject_ApsLinkKeySet_c: ZdoNwkMng_SaveDataSet(gNvDataSet_Aps_Sec_ID_c); /* Saves Secure Info */ ZdoNwkMng_SaveDataSet(gNvDataSet_Sec_ID_c); /* Saves the key table. */ break; /* Saves NWK security material plus key table when available. */ case zdoNvmObject_SecureSet_c: ZdoNwkMng_SaveDataSet(gNvDataSet_Sec_ID_c); break; #endif /* Save all data. */ case zdoNvmObject_All_c: NvSaveOnIdle(gNvDataSet_Nwk_ID_c); NvSaveOnIdle(gNvDataSet_App_ID_c); NvSaveOnIdle(gNvDataSet_Aps_Sec_ID_c); #if gStandardSecurity_d || gHighSecurity_d NvSaveOnIdle(gNvDataSet_Sec_ID_c); #endif break; /* Used by Aps and Nwk layer to save the outgoing counters. */ case zdoNvmObject_SecurityCounters_c: #if gStandardSecurity_d || gHighSecurity_d /* Nwk security material is divided on Nwk data set and Sec data set, Aps counters have its own data set. */ NvSaveOnCount(gNvDataSet_Sec_ID_c); NvSaveOnCount(gNvDataSet_Nwk_ID_c); NvSaveOnCount(gNvDataSet_Aps_Sec_ID_c); #endif break; /* Make sure all data sets are sasved at once. */ case zdoNvmObject_AtomicSave_c: NvSaveOnIdle(gNvDataSet_Nwk_ID_c); NvSaveOnIdle(gNvDataSet_App_ID_c); NvSaveOnIdle(gNvDataSet_Aps_Sec_ID_c); #if gStandardSecurity_d || gHighSecurity_d NvSaveOnIdle(gNvDataSet_Sec_ID_c); #endif NvIdle(); NvOperationEnd(); break; } }