-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fixed memory leaks in rainmaker examples #7965
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
Merged
me-no-dev
merged 5 commits into
espressif:master
from
sanketwadekar:fix/rmaker_example_changes
Mar 31, 2023
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7e7310b
task: Added Rainmaker partition to esp32 wrover and
sanketwadekar 196d124
fix: memory leaks in rainmaker examples
sanketwadekar 0108492
Rainmaker: Improved error log messages
sanketwadekar b658b10
Merge branch 'task/add_rmaker_partition_to_more_boards' into fix/rmak…
sanketwadekar 60e3c2a
task: format Rainmaker examples
sanketwadekar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -21,7 +21,7 @@ static int gpio_switch = 16; | |
bool switch_state = true; | ||
|
||
//The framework provides some standard device types like switch, lightbulb, fan, temperaturesensor. | ||
static Switch my_switch; | ||
static Switch *my_switch = NULL; | ||
|
||
void sysProvEvent(arduino_event_t *sys_event) | ||
{ | ||
|
@@ -69,13 +69,15 @@ void setup() | |
my_node = RMaker.initNode("ESP RainMaker Node"); | ||
|
||
//Initialize switch device | ||
my_switch = Switch("Switch", &gpio_switch); | ||
|
||
my_switch = new Switch("Switch", &gpio_switch); | ||
if(!my_switch) { | ||
return; | ||
} | ||
//Standard switch device | ||
my_switch.addCb(write_callback); | ||
my_switch->addCb(write_callback); | ||
|
||
//Add switch device to the node | ||
my_node.addDevice(my_switch); | ||
my_node.addDevice(*my_switch); | ||
|
||
//This is optional | ||
RMaker.enableOTA(OTA_USING_TOPICS); | ||
|
@@ -111,17 +113,19 @@ void loop() | |
|
||
if ((endTime - startTime) > 10000) { | ||
// If key pressed for more than 10secs, reset all | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please follow consistent styling. |
||
Serial.printf("Reset to factory.\n"); | ||
RMakerFactoryReset(2); | ||
Serial.printf("Reset to factory.\n"); | ||
RMakerFactoryReset(2); | ||
} else if ((endTime - startTime) > 3000) { | ||
Serial.printf("Reset Wi-Fi.\n"); | ||
// If key pressed for more than 3secs, but less than 10, reset Wi-Fi | ||
RMakerWiFiReset(2); | ||
Serial.printf("Reset Wi-Fi.\n"); | ||
// If key pressed for more than 3secs, but less than 10, reset Wi-Fi | ||
RMakerWiFiReset(2); | ||
} else { | ||
// Toggle device state | ||
switch_state = !switch_state; | ||
Serial.printf("Toggle State to %s.\n", switch_state ? "true" : "false"); | ||
my_switch.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, switch_state); | ||
switch_state = !switch_state; | ||
Serial.printf("Toggle State to %s.\n", switch_state ? "true" : "false"); | ||
if(my_switch) { | ||
my_switch->updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, switch_state); | ||
} | ||
(switch_state == false) ? digitalWrite(gpio_switch, LOW) : digitalWrite(gpio_switch, HIGH); | ||
} | ||
} | ||
|
This file contains hidden or 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
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.
Please follow same styling across the file
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.
We are losing time with style issues when an automatic script with clang formatter could keep all PR at same pattern.
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.
We have a script in IDF which uses
astyle
programme to achieve this: here. However this has to be run manually for this repo.If you have a change for using automated clang formatter, would you please raise a PR for the same?
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'm not an expert in this subject otherwise I could make a PR. Actually I'm using uncrustify in VSCode only.
Anyway there's an action with example for artistic style here:
https://github.com/marketplace/actions/artistic-style