int main(int argc, char *argv[]) { uint32_t atomic_state; if (cmdline_parser(argc, argv, &args_info) != 0) { exit(1); } hwAlarmInit(); hwRadioInit(); hwRandomInit(); otInit(); sCliServer.Start(); while (1) { otProcessNextTasklet(); atomic_state = otPlatAtomicBegin(); if (!otAreTaskletsPending()) { hwSleep(); } otPlatAtomicEnd(atomic_state); } return 0; }
void nodeLock(const char* str) { // Make sure EEPROM is updated to locked status hwWriteConfig(EEPROM_NODE_LOCK_COUNTER, 0); while (1) { debug(PSTR("Node is locked. Ground pin %d and reset to unlock.\n"), MY_NODE_UNLOCK_PIN); #if defined(MY_GATEWAY_ESP8266) yield(); #endif _sendRoute(build(_msg, _nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_LOCKED, false).set(str)); #if defined(MY_RADIO_FEATURE) transportPowerDown(); #endif (void)hwSleep((unsigned long)1000*60*30); // Sleep for 30 min before resending LOCKED message } }
int8_t sleep(unsigned long ms) { #if defined(MY_OTA_FIRMWARE_FEATURE) if (_fwUpdateOngoing) { // Do not sleep node while fw update is ongoing wait(ms); return -1; } #endif // if repeater, do not sleep #if defined(MY_REPEATER_FEATURE) wait(ms); return -1; #else #if defined(MY_RADIO_FEATURE) transportPowerDown(); #endif return hwSleep(ms); #endif }
int8_t sleep(uint8_t interrupt, uint8_t mode, unsigned long ms) { #if defined(MY_OTA_FIRMWARE_FEATURE) if (_fwUpdateOngoing) { // not supported return -2; } #endif #if defined(MY_REPEATER_FEATURE) // not supported (void)interrupt; (void)mode; (void)ms; return -2; #else #if defined(MY_RADIO_FEATURE) transportPowerDown(); #endif return hwSleep(interrupt, mode, ms); #endif }
int8_t hwSleep(const uint8_t interrupt, const uint8_t mode, uint32_t ms) { return hwSleep(interrupt, mode, INVALID_INTERRUPT_NUM, 0u, ms); }
int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) { return hwSleep(interrupt,mode,INVALID_INTERRUPT_NUM,0u,ms); }