Where is the WiFi config held?



  • I want to access the pre-existing WiFi config from micropython, the one you setup with M5burner.

    On 1.4.5, on the M5StickC, the SSID + password are stored in apps/config.json. This is cool, as I don't have to hard-code it into my apps.

    On 1.5.1, on the Core/Gray, there does not appear to be any equivalent file, yet it still knows the information. How do I access it?

    I tried wifi_history = machine.nvs_getstr("history") from WifiCfg.py, but machine doesn't have nvs_getstr().

    Is there any way to get this now? I really don't want to go back to hard-coding!



  • Poking around a bit:

    wifiCfg.deviceCfg.get_wifi()
    ['fbi covert AP', 'letmein']
    
    wifiCfg.deviceCfg.wifi_read_from_flash()
    ['not the cia', 'really']
    

    This actually sort of makes sense in that I used not the cia with m5burner, but I called doConnect once with 'fbi covert AP` hard-coded.

    Reflashing back to 1.4.5, I see that it is not the same:

    >>> wifiCfg.deviceCfg.wifi_read_from_flash()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'module' object has no attribute deviceCfg'
    
    >>> wifiCfg.wifi_read_from_flash()
    ['not the cia', 'really']
    

    Ugh.

    1.5.2 is the same as 1.5.1 though.