sleep(0) in V2.1 doesn't sleep indefinitely anymore. Used to powerdown and sleep in V1.5



  • For battery powered nodes that need to completely sleep between events sleep(0) could be used in V1.5 in conjunction with the pin change interrupts on portC of an ATmega 328p. It would gracefully power down the radio and then enter the CPU into sleep mode until a pin change event on port C woke it up. In V2.1 sleep(0) simply returns. PortC pin-change mode is needed because INT0 and INT1 only work on either falling or raising level changes but not on either edge at the same time on the 328p .

    I modified the file MyHwAVR.cpp as follows to restore the missing functionality back into V2.1 : Lines 150 and up:

    int8_t hwSleep(unsigned long ms)
    {
    
    
    	if (ms>0) {
    		// sleep for defined time
    		hwInternalSleep(ms);
    		return MY_WAKE_UP_BY_TIMER;
    	} else {  // Fix for missing feature that allowed (in 1.5.1) to use the pin chnage interrupt with a sleep(0) to completely power down the system
    		// sleep until ext interrupt triggered
    		hwPowerDown(SLEEP_FOREVER);
    		return 0;
    	}
    
    
    }
    

    Let me know if this is the correct venue to bring this to the attention of the code maintainers, or if I should go and furnish a git pull request or something like that.

    Or if this has been addressed in post V2.1.1 releases
    Thanks
    gary


  • Mod

    Thanks @garystofer

    Looks to me like this was fixed in https://github.com/mysensors/MySensors/pull/1113

    You seem to be using very old code 🙂

    Tombula created this issue in mysensors/MySensors

    closed Add sleep forever by sleep(0); #1113


Log in to reply
 

Suggested Topics

216
Online

9.3k
Users

9.9k
Topics

103.3k
Posts