Qstr strangeness in network_wlan
Posted: Tue Nov 30, 2021 6:37 pm
This feels like it should be something simple but I'm baffled, so hoping someone can help please
I've modified network_wlan.c to get the number of clients connected in AP mode.
I've added the following code into network_wlan_config function here:
https://github.com/micropython/micropyt ... lan.c#L537
If I use in in the REPL all works well.
However if I run the same code on boot in _boot.py, I get ValueError: unknown config param i.e. the case statement doesn't match the connected_clients string passed in.
To try and debug things, I also added a line that prints the value of the qsrt passed in:
When I call it from the REPL I get:
but from _boot.py
For comparison I tried
ap.config('mac')
and this works both in the REPL and from _boot.py. In both cases I log:
So, it looks like `connected_clients` in _boot.py isn't being interned properly? Any thoughts gratefully received!
[edit -- additional]
Just compiled latest esp32 from micropython github repo and added the following under _boot.py
result is:
So `mac` works but not `dhcp_hostname`!
I've modified network_wlan.c to get the number of clients connected in AP mode.
I've added the following code into network_wlan_config function here:
https://github.com/micropython/micropyt ... lan.c#L537
Code: Select all
case QS(MP_QSTR_connected_clients):
req_if = WIFI_IF_AP;
val = MP_OBJ_NEW_SMALL_INT(ap_connected_client_count);
Code: Select all
>>> import network
>>> ap = network.WLAN(network.AP_IF)
>>> ap.config('connected_clients')
0
To try and debug things, I also added a line that prints the value of the qsrt passed in:
Code: Select all
ESP_LOGI("wifi", "got param %d", (uintptr_t)args[1]);
Code: Select all
I (16557) wifi: got param 2074
Code: Select all
I (947) wifi: got param 1061406248
ap.config('mac')
and this works both in the REPL and from _boot.py. In both cases I log:
Code: Select all
I (307417) wifi: got param 6738
[edit -- additional]
Just compiled latest esp32 from micropython github repo and added the following under _boot.py
Code: Select all
import network
ap = network.WLAN(network.AP_IF)
print(ap.config('mac'))
print(ap.config('dhcp_hostname'))
Code: Select all
b'\xd8\xa0\x1deh\x1d'
Traceback (most recent call last):
File "_boot.py", line 18, in <module>
ValueError: unknown config param
MicroPython v1.17-217-gde7e3cd79-dirty on 2021-11-30; ESP32 module with ESP32
Type "help()" for more information.