<class 'OSError'> Avialable Interfaces are down



  • Hi, I have a lopy4 and at the start of my program I get the following error:
    <class 'OSError'>
    Avialable Interfaces are down

    I do not know exactly why I get this error and why it is.
    Thank you.



  • @johand After I've set IP for HTTP server

    wlan.ifconfig(id=1, config=('192.168.4.10', '255.255.255.0', '192.168.4.1', '192.168.4.1'))
    

    i've tried to read IP address of HTTP Server and that was the problem, it's keep returning me '0.0.0.0'. IP address was set properly to '192.168.4.10' but function returns '0.0.0.0'.

    print('Network config:', wlan.ifconfig())
    Network config: ('0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0')
    

    Thank you for your help.

    @pigamonte I've managed to do it with 1.18.2.



  • @milan Yes, as @robert-hh wrote erlier, WIFI mode and what your application does is not related. I guess you have already tried, what problem do you run into?



  • @milan
    I had this exact problem. Roll back to firmware 1.18.0 solved it.



  • @robert-hh Thank you for your suggestion.
    I've tried configuration with three devices:

    • device 1 - HTTP client with WiFi in STA mode connected to device 3
    • device 2 - HTTP server with WiFi in STA mode connected to device 3
    • device 3 - WiFi in AP mode

    This configuration works ok.
    My idea is to have devices 2 and 3 as one device. Is that possible, to have HTTP server which WiFi is in AP mode?



  • @robert-hh no, it does not tell me any line or more information, it just shows me that error and continues to execute the code



  • @milan WiFi connection modes and Client/Server relation are completely independent topics. You can have all devices connected as STA to a separate AP and have a server on one device and clients on all devices.
    That's something I would do anyhow: Get a unexpensive AP and use that for interconneting, unless you have other restrictions.



  • @johand I want to have one device as HTTP server with WiFi in AP mode, and other device as HTTP client with WiFi in STA mode. HTTP client device should be connected to AP from HTTP server. Is that possible?

    Are there any example of plain socket communication?

    Than you in advance.



  • @milan said in <class 'OSError'> Avialable Interfaces are down:

    When Pycom is in WiFi STA mode everything works fine, but I want to do the same thing when Pycom is in WiFi AP mode

    What problem do you have?

    It is possible to run one device as HTTP server and one as client. Depending on what you want to transfer, it might be easier to use plain sockets instead.



  • @johand When Pycom is in WiFi STA mode everything works fine, but I want to do the same thing when Pycom is in WiFi AP mode, so other Pycom would be able to connect to AP and to send HTTP request.
    One Pycom should be HTTP server, listening for HTTP requests with WiFi in AP mode, and other should send HTTP requests with WiFi in STA mode connected to first Pycom WiFi.
    Is that even possible?



  • @milan This is how I usually do to get the correct security settings:

    wlan = WLAN(mode=WLAN.STA)
    nets = wlan.scan()
    for net in nets:
        if net.ssid == ssidName:
            print('Network found!')
            wlan.connect(net.ssid, auth=(net.sec, password), timeout=5000)
            while not wlan.isconnected():
                pass
            break
    

    Johan



  • @johand Thank you for your suggestion. I've tried your code and in that case pycom is stucked in while loop waiting for connection to be ready. I don't know what can be wrong, I'm 100% sure that hardware is ok.



  • @milan said in <class 'OSError'> Avialable Interfaces are down:

    @goro @robert-hh I'm also getting this error after final line of code:

    wlan.init(mode=WLAN.AP, ssid=ssidName, auth=(WLAN.WPA2, password), hidden=False)
    
    addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
    
    OSError: Avialable Interfaces are down
    

    I think you´ll have to wait until the connection is ready.

    wlan.init(mode=WLAN.AP, ssid=ssidName, auth=(WLAN.WPA2, password), hidden=False)
    while not wlan.isconnected():
        pass
    addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
    

    Johan



  • @goro @robert-hh I'm also getting this error after final line of code:

    import pycom
    import usocket as socket
    
    from network import WLAN
    
    ssidName = 'pycom'
    password = 'pycom123'
    
    wlan = WLAN()
    print("Turning on wlan: " + ssidName)
    wlan.init(mode=WLAN.AP, ssid=ssidName, auth=(WLAN.WPA2, password), hidden=False)
    
    addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
    
    OSError: Avialable Interfaces are down
    


  • @goro Is that all, or dou you have mre information like a line number and/or the respecitive part of the code?



Pycom on Twitter