-
Notifications
You must be signed in to change notification settings - Fork 9
Firmware JSON document memory management #117
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
Open
brian-r-calder
wants to merge
17
commits into
main
Choose a base branch
from
development
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4986cf4
Avoid holding a large JSON document while initiating SSL connections
parkercoates 90f0daa
Shrink file number lists to their contents
parkercoates 9c91835
Show question marks for missing file detail fields
parkercoates 1d44de7
Allow CountLogFiles to optionally determine total size
parkercoates c2f1724
Allow JSON to be moved directly into the WiFi message buffer
parkercoates 9e0d495
Store ESP32WiFiAdapter::m_messages by value instead of pointer
parkercoates ac066fe
Remove declared-but-never-defined SerialCommand::GenerateFilelist
parkercoates 3ba1ce6
Shrink ESP32WiFiAdapter's JSON document if it gets to large
parkercoates 1054b78
Introduce a common functions to grow the capacity of a DynamicJsonDoc…
parkercoates cc8e8af
Reduce DynamicJsonDocument growth factor to 1.5×
parkercoates 9dbc0ae
Add a SerialCommand::EmitJSON() overload that takes a JSON document
parkercoates cc63c32
Add a new "catalog" command that sends the JSON file list
parkercoates 9b08ed4
Remove the file list from the status JSON message
parkercoates e6ff03e
fw: Merge PR #108 for better memory usage for JSON documents
brian-r-calder 4f22660
fw: Mods to upload server to compensate for new status message struct…
brian-r-calder ec8140f
Updated README for upload server, and pinned localstack (for local te…
brian-r-calder b4ec680
fw: Small updates to resolve questions on PR #117.
brian-r-calder 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
|
|
||
|
|
||
| #ifndef JSONUTILITIES_H | ||
| #define JSONUTILITIES_H | ||
|
|
||
| #include <ArduinoJson.h> | ||
|
|
||
| inline bool GrowJsonDocumentBy(DynamicJsonDocument& json, size_t capacityIncrease) | ||
| { | ||
| auto newCapacity = json.capacity() + capacityIncrease; | ||
| DynamicJsonDocument temp(newCapacity); | ||
|
|
||
| // Allocation failed. Nothing we can do. | ||
| if (temp.capacity() == 0) return false; | ||
|
|
||
| temp.set(json); | ||
| json = std::move(temp); | ||
| return true; | ||
| } | ||
|
|
||
| inline bool GrowJsonDocument(DynamicJsonDocument& json) | ||
| { | ||
| // Grow capacity by 50%. A growth rate less than the golden ratio allows | ||
| // the document to potentially reuse allocations it previously occupied. | ||
| return GrowJsonDocumentBy(json, json.capacity() / 2); | ||
| } | ||
|
|
||
| #endif // JSONUTILITIES_H |
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
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
Oops, something went wrong.
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.
Should be
*fileSizeinstead of* fileSize.