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

Ned/reduce memory usage #33

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

ned-pcs
Copy link

@ned-pcs ned-pcs commented Jun 8, 2023

This PR allows running Micropython-ESP-WiFi-Manager on an ESP32 without SPI RAM.
Doing this requires pre-compiling static resources (see below).
It changes the string concatenation that was being used for formatting the discovered networks into HTML into utemplate iteration and inclusion.
It also allows for static resources to be compiled into frozen strings using mpy_bin2res.py (this requires pkg_resources from micropython-lib).
The code for serving static resources has been unified and simplified (which required moving static/favicon.ico into static/ico).
It also vendors microdot files directly from github:miguelgrinberg.

Full change list:

    Render network list using included template rather than string appending.
    
    Use utemplate iteration for select.tpl
    Add _tpl.py files to flake8 exclude list
    Ignore pre-compiled templates and .vscode dir
    Removed (board-dependent) LED stuff from boot.py
    Delete two unused templates.
    Add simpler static server method.
    Search for static files in pre-compiled bytecode modules
    Allow for frozen pre-compiled templates to be used instead of ones from the filesystem
    Change spelling of Passwort => Password
    Add boot.py and main.py under lib/wifi_manager.
    Also add instructions as to how to invoke the logic of these files from your own /boot.py and /main.py.
    Move favicon.ico under static/ico for consistent searching.
    Add garbage collect before every request.
    Add aiorepl to run().

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2023

Codecov Report

Merging #33 (8fa1fb2) into develop (d911e69) will not change coverage.
The diff coverage is 52.83%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@           Coverage Diff            @@
##           develop      #33   +/-   ##
========================================
  Coverage    68.32%   68.32%           
========================================
  Files           21       21           
  Lines         1364     1364           
  Branches       194      194           
========================================
  Hits           932      932           
  Misses         392      392           
  Partials        40       40           
Flag Coverage Δ
unittests 68.32% <52.83%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
wifi_manager/wifi_manager.py 56.09% <52.83%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@brainelectronics
Copy link
Owner

relates to micropython/micropython#11764

Copy link
Owner

@brainelectronics brainelectronics left a comment

Choose a reason for hiding this comment

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

Looks good so far, could you please fix my remarks and add a changelog entry similar to the previous ones? The version would be 1.13.0 I assume as this is nice feature and not just a fix :)

README.md Outdated Show resolved Hide resolved
boot.py Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
wifi_manager/wifi_manager.py Outdated Show resolved Hide resolved
ned-pcs added 2 commits June 12, 2023 09:33
Also add instructions as to how to invoke the logic of these files from your own /boot.py and /main.py.
…ing.

Use utemplate iteration for select.tpl
Add _tpl.py files to flake8 exclude list
Ignore pre-compiled templates and .vscode dir
Removed (board-dependent) LED stuff from boot.py
Delete two unused templates.
Add simpler static server method.
Search for static files in pre-compiled bytecode modules
Allow for frozen pre-compiled templates to be used instead of ones from the filesystem
Change spelling of Passwort => Password
Add boot.py and main.py under lib/wifi_manager.
Also add instructions as to how to invoke the logic of these files from your own /boot.py and /main.py.
Move favicon.ico under static/ico for consistent searching.
Add garbage collect before every request.
Add aiorepl to run().
@ned-pcs ned-pcs force-pushed the ned/reduce-memory-usage branch 2 times, most recently from 21e6524 to 78a1037 Compare June 12, 2023 16:45
ned-pcs added 2 commits June 12, 2023 09:53
Also made starting aiorepl optional (started if available).
@ned-pcs
Copy link
Author

ned-pcs commented Jun 12, 2023

OK @brainelectronics I think I addressed everything you mentioned. How does it look?

Copy link
Owner

@brainelectronics brainelectronics left a comment

Choose a reason for hiding this comment

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

LGTM, I've published the https://test.pypi.org/project/micropython-esp-wifi-manager/1.13.0rc18.dev33/ to Test PyPI. It contains your latest changes.
May you have also the possibility to test it on MicroPython 1.19.1 with upip? I'm currently not at home, so testing can be done on Friday from my side.

@brainelectronics
Copy link
Owner

Hey @ned-pcs , I've merged #35 to add the pkg_resources also for older upip users. Everything got tested successfully today. So one more rebasing and this great PR can be merged 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants