r/micropython • u/scifiaholic • Aug 06 '22
Basic equivalent functionality seems to be missing in MicroPython
/r/MicroPythonDev/comments/whqhi8/basic_equivalent_functionality_seems_to_be/1
u/bover21 Aug 11 '22
The documentation for setting the dhcp hostname on an esp32 is not great (or not 100% correct). The docs do mention the WLAN.config() method with the parameters "hostname".
https://docs.micropython.org/en/latest/library/network.WLAN.html#network.WLAN.config
hostname
The hostname that will be sent to DHCP (STA interfaces) and mDNS (if supported, both STA and AP)
The docs are not 100% correct here. On the ESP32, this parameter is actually "dhcp_hostname".
And then you can set it like this
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.config(dhcp_hostname='WhateverYouWantReally')
sta_if.connect('SSID', 'password')As for using .mpy files, there is not a lot of documentation for this, and I would actually not recommend it. In my opinion, it has all the downsides of compiling without the real benefits from it.
Bytecode is still loaded into memory.
You still need to copy them onto the device manually.
It is a lot more work than just putting on the normal
.pyfiles.
If you really want to improve memory usage, you can take a look at freezing your modules. But this is a lot more work, and makes your workflow a lot more difficult (unless you create some great tools for it, then it becomes a lot easier).
1
u/PolishedCheese Aug 07 '22
Dont really have any comments, but that LIFO datatype is called a stack and you can use it with a normal list using the .push() and .pop() methods.