Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ESP32 power down code #1125

Merged
merged 2 commits into from
Jan 9, 2019

Conversation

josesimoes
Copy link
Member

Description

  • Improve ESP32 power down code.

Motivation and Context

  • Need to follow the new goto power down workflow.

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Signed-off-by: José Simões [email protected]

@josesimoes josesimoes added Type: enhancement Series: ESP32 Everything related specifically with ESP32 series targets labels Dec 21, 2018
@nfbot
Copy link
Member

nfbot commented Dec 21, 2018

Hi @josesimoes,

I'm nanoFramework bot.
Thank you for your contribution!

A human will be reviewing it shortly. 😉

@josesimoes
Copy link
Member Author

Please validate this. I added that call to esp_wifi_stop() following a recommendation that is on the EPS32 documentation.

@AdrianSoundy
Copy link
Member

I tried this and although code looks ok it didn't seem to work. The only change i would make is to call the nanoHAL_Uninitialize() instead of esp_wifi_stop() before the esp_deep_sleep_start() as that should stop the wifi( not sure if it does at the moment, but it should do. Can sort that out later ).

The CPU_SetPowerMode(PowerLevel_type powerLevel) function doesn't get called. I added some tracing and it doesn't seem to exit the g_CLR_RT_ExecutionEngine.Execute()

@josesimoes josesimoes force-pushed the update-power-down-esp32 branch from 0755491 to 46527bc Compare January 3, 2019 00:26
@josesimoes
Copy link
Member Author

@AdrianSoundy I've pushed the changes as you've suggested. It's now calling nanoHAL_Uninitialize_C().

As for not going into SetPowerMode() it can be either because the execution engine doesn't exit (strange because the code is common) or the flags on that if statement before are being changed after being set in NativeStartDeepSleep___STATIC__nanoFrameworkHardwareEsp32EspNativeError() which looks even more weird...

Signed-off-by: José Simões <[email protected]>
@josesimoes josesimoes force-pushed the update-power-down-esp32 branch from 46527bc to b5610e1 Compare January 5, 2019 11:55
@josesimoes
Copy link
Member Author

@AdrianSoundy there was a bug in the call to nanoHAL_Uninitialize_C() please give this another try.

@AdrianSoundy
Copy link
Member

I have now tested this and it seems to be working.
Test code - Goes to deep sleep for 2 minutes then reboots

       public static void Main()
        {
            Console.WriteLine("Hello world! "+ Sleep.GetWakeupCause().ToString() );

            Console.WriteLine("Deep sleep in 10 seconds "+ DateTime.UtcNow.ToString());
            
            Thread.Sleep(10000);

            Sleep.EnableWakeupByTimer(new TimeSpan(0, 2, 0));
 
            Console.WriteLine("Start deep sleep " + DateTime.UtcNow.ToString());
            Sleep.StartDeepSleep();
            Console.WriteLine("after deep sleep, should not see");

            Thread.Sleep(Timeout.Infinite);
        }

Copy link
Member

@AdrianSoundy AdrianSoundy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@josesimoes josesimoes merged commit 518d121 into nanoframework:develop Jan 9, 2019
@josesimoes josesimoes deleted the update-power-down-esp32 branch January 9, 2019 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Series: ESP32 Everything related specifically with ESP32 series targets Type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants