wlan.ssid()



  • Hello,

    I'm not sure whether this is a bug or if I'm doing or interpreting something wrong (or if there is no way to implement this differently due to hardware/firmware limitations).

    The following code was part of my boot.py:

    import network
    wlan = network.WLAN()
    if not (wlan.ssid() == 'mywlanname' and wlan.isconnected()):
        ...
    

    I programmed it this way because machine.reset_cause() wasn't available right from the start, but it always disconnected my telnet session after a soft reset. I didn't give this much thought because I was waiting for the new firmware anyway as I was hit by the write-protection bug, but after modifiying my code to branch based on machine.reset_cause() I noticed that after a soft reset ssid() is reset to the default name starting with lopy-..., but the device is still connected to my WLAN and I can connect to it.

    This means that I have no possibility to identify the WLAN that I'm connected to after a soft reset as ssid() returns the default name even if my LoPys are connected to a different network.

    Is this a bug, working as intended or a limitation we have to accept?

    P.S.: The reason why I'm interested in getting the correct ssid() even after a soft reset is that I'd like to switch WLANs while the LoPy is running but reconnect to the maintenance WLAN after a soft reset, but only if not already connected to the maintenance WLAN to avoid cutting an active telnet connection. If that is not possible it is only a mild annoyance :).



  • @daniel Great! You might have to revisit this issue though, see Github. It might have been fixed in the same commit. You know that better than I do.

    I also opened a another issue: I would like access to the current BSSID: https://github.com/pycom/pycom-micropython/issues/13



  • The API will change a bit when we enable AP+STA mode so that you can select the correct interface (the AP or the STA).



  • @daniel how is it going to work for AP+STA?



  • Thanks @betabrain. The problem is fixed, and the solution is already on github.





  • @betabrain thanks for the bug report. Could you open an issue here: https://github.com/pycom/pycom-micropython ?

    Cheers,
    Daniel



  • It seems as if wlan.ssid() returns the default lopy-wlan-xxxx not just after a reset. I am using version 0.9.4.b1.

    from network import WLAN
    
    w = WLAN()
    w.ssid() # lopy-wlan-xxxx
    w.connect('homewifi', auth=(3, 'secretsecret'), timeout=5000)
    w.ssid() # lopy-wlan-xxxx
    w = WLAN()
    w.ssid() # lopy-wlan-xxxx
    w.connect('homewifi', auth=(3, 'secretsecret'), timeout=5000)
    w.ssid() # lopy-wlan-xxxx
    w = WLAN()
    w.ssid() # lopy-wlan-xxxx
    

    Edit: LoPy does connect to homewifi, reliably, but ssid() fails to report that.


Log in to reply
 

Pycom on Twitter