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
Breaks network on-going network connection when Sleep stop mode is called #1125
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "application.h" | ||
|
||
#define MIN_CONNECT_DURATION 1000 // Milliseconds | ||
#define MAX_CONNECT_DURATION 5000 | ||
#define SLEEP_DURATION 5 // Seconds | ||
|
||
SYSTEM_MODE(MANUAL) | ||
SYSTEM_THREAD(ENABLED) | ||
|
||
namespace { | ||
|
||
SerialLogHandler logHandler(LOG_LEVEL_WARN, { // Default logging level | ||
{ "app", LOG_LEVEL_ALL } // Logging level for application messages | ||
}); | ||
|
||
uint32_t t = 0, d = 0; | ||
|
||
void resetTimer() { | ||
d = rand() % (MAX_CONNECT_DURATION - MIN_CONNECT_DURATION) + MIN_CONNECT_DURATION; | ||
t = millis(); | ||
} | ||
|
||
} // namespace | ||
|
||
void setup() { | ||
// Set incorrect WiFi credentials to cause repeated connection attempts | ||
WiFi.on(); | ||
WiFi.clearCredentials(); | ||
WiFi.setCredentials("param-pam-pam"); | ||
WiFi.connect(); | ||
resetTimer(); | ||
} | ||
|
||
void loop() { | ||
if (millis() - t >= d) { | ||
LOG(INFO, "Entering stop mode"); | ||
// The current taken by the device should be around 3 mA when the stop mode is active | ||
System.sleep(D1, RISING, SLEEP_DURATION); | ||
LOG(INFO, "Leaving stop mode"); | ||
resetTimer(); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed that
wakeupState.cloud
was used before initialization previously.