Page 1 of 1

Full List of Args for network.WLAN(network.AP_IF)

Posted: Mon Oct 21, 2019 2:17 pm
by kinno
Good morning everyone,

I am looking for clear documentation on the full list and explanation of arguments available for the WLAN.

I have found that the esp_wifi.h and other files are hidden for security on the Github so I could no look through those. Also, I found these other resources that may in fact cover all the arguments (or not?). I was wondering if there is a place where all these arguments are available with a small explanation.

Why do I bring this up? It took a while to discover with ES32 using AP_IF mode that you have to use the 'authmode' argument in order to get your access point to use a password and secure the wireless connection. I found it in a forum but don't see any explanation for the different modes. Example, authmode=1, authmode=2, authmode=3 are not exactly self explanatory. I used authmode=3 because I assumed that 1=Open, 2=WEP, 3=WPA. I am betting this is incorrect but I still got the WPA security from authmode=3. :?

Anyways, any links or resources for a consolidated place on this would be greatly appreciated and if it doesn't exist it would be a good document to have in the future.

Here are some resources I used to overcome this:

1. https://github.com/micropython/micropyt ... dnetwork.c
2. http://docs.micropython.org/en/v1.9.4/w ... twork.html (I know it's older documentation)
3. https://docs.micropython.org/en/latest/ ... twork.html
4. https://randomnerdtutorials.com/micropy ... -point-ap/ (This DID not secure the network due to missing authmode=3 argument. Which sent me on my initial hunt).

Thanks everyone for your time, looking forward to feedback.

Re: Full List of Args for network.WLAN(network.AP_IF)

Posted: Mon Oct 21, 2019 7:33 pm
by Christian Walther
I don’t know if there is a better “consolidated place” – I usually just use the search function of the documentation – but the WLAN auth modes are documented at WLAN.scan(), and one can assume that they are the same for WLAN.config(). The documentation there just states “see module constants”, which don’t seem to be documented, but they are easy enough to check on the device using help(network). On my ESP32, it says

Code: Select all

  AUTH_OPEN -- 0
  AUTH_WEP -- 1
  AUTH_WPA_PSK -- 2
  AUTH_WPA2_PSK -- 3
  AUTH_WPA_WPA2_PSK -- 4
  AUTH_MAX -- 6

Re: Full List of Args for network.WLAN(network.AP_IF)

Posted: Mon Oct 21, 2019 11:44 pm
by jimmo
I think the documentation could use a bit of work in this area, it is confusing.

I think the most confusing thing is that by the looks of it you were looking at (link 3) which is the documentation for the network module (which is for an abstract network interface), but you need the docs specifically for WLAN -- https://docs.micropython.org/en/latest/ ... .WLAN.html -- which says the config takes an "authmode" param.

As Christian points out, it says "see module constants" doesn't help because they aren't documented on the module https://docs.micropython.org/en/latest/ ... twork.html (I suspect this possibly got lost when the docs were merged, where they used to be port-specific).

I think the problem here is that the module docs are generic, but the module is actually implemented port-specific.

Anyway, https://github.com/micropython/micropython/issues/5245 to track getting this improved! Thanks for the report!
kinno wrote:
Mon Oct 21, 2019 2:17 pm
I have found that the esp_wifi.h and other files are hidden for security on the Github so I could no look through those.
Btw, what did you mean by "hidden for security" -- https://github.com/espressif/esp-idf/bl ... esp_wifi.h

In general though, there's not necessarily a 1:1 link between the MicroPython constants and the low-level ones. So stuff in this header file might not be helpful.

Re: Full List of Args for network.WLAN(network.AP_IF)

Posted: Sat Nov 09, 2019 2:46 pm
by kinno
Thank you both for your replies.

I really appreciate the time. I am slowly getting the full picture of how micropython works on the ESP32 and 8266. It is one thing to program for it and another to understand the whole process including ESP-IDF and the Kernel of ESP's etc. So forgive me if I ask ignorant questions regarding these topics.

I bring this up because I thought that the esp_wifi.h was included in the micropython esp32 port.... Pointed out by Jimmo that is is in the IDF. :oops:

Thank you Jimmo for explaining this, and your patience.

Thank you Christian Walther for the answer to my question it helped a lot.

Take care,