george-hawkins / micropython-wifi-setup

MIT License
38 stars 8 forks source link

file issues when adding as frozen packages #5

Open steoj opened 2 months ago

steoj commented 2 months ago

First of all: Thank you so much for making this project. It is exactly what I need for my Micropython project.

I have added what I need from the modules/micropython-wifi-setup/lib folder as packages in my manifest.py after cloning your project as a submodule under my modules folder.

Seems to be working until it tries to load the modules/micropython-wifi-setup/lib/micro_web_srv_2/status-code.html file using the path micro_web_srv_2/status-code.html. My temporary workaround is to add the file its looking for in the file storage under a micro_web_srv_2/ folder. Problem with this is that python then thinks the micro_web_srv_2. module is local and complains

ImportError: no module named 'micro_web_srv_2.http_request'

Any suggestions on how to handle this?

george-hawkins commented 2 months ago

Sorry, Sten - I've never tried using the whole manifest/freezing process. I can understand why you'd want to use it for micropython-wifi-setup - it's a reasonably large package and I remember it pushing at the edges of what could comfortably be compiled on the fly by MicroPython on low-memory ESP32 devices.

I'm not in a position to investigate this (I'm away from home at the moment for work) and it's a long time since I worked on this project. All I can suggest is that you try to create some super minimal project that reproduces a similar issue and then ask on the MicroPython discussions forum - I find they tend to be very helpful there.

steoj commented 2 months ago

Thank you for your quick response. I have done some more investigations and it seems reading files from frozen memory is a bit of a pickle. As also the web interface is based on files read on demand, this inhibits the captive portal to start up at all. It seems that one way out of this is to replace all file loads with the resulting string constants. This will make the whole captive portal freezable and I have 4MB of Flash memory to work with, rather than the limited space of python code I can run. For now I can make it all work by copying the lib/wifi-setup/ folder in to the file system, and leave the other parts in frozen memory. I agree that the discussion forum on MicroPython.org is a good place to get competent help. I'll look into that further.

Thanks again for all your effort to help out and make this available.