intellij-micropython icon indicating copy to clipboard operation
intellij-micropython copied to clipboard

cannot find reference to 'STA_IF' in 'network.pyi'

Open waanito opened this issue 2 years ago • 3 comments

environment: macos; pycharm professional 2023.1.3 & 4; esp32 devkit1 attached as /dev/cu.SLAB_USBtoUART; micropython plugin installed; micropython esp8266 selected in languages.

trying to connect to wifi works fine from REPL in PyCharm when entered directly in REPL after ESP32 is erased then flashed with micropython but as soon as I write a simple main as below in PyCharm to connect it brings up the error in the title. Same code works fine in two other IDEs tried...

import network
from time import sleep


def getwifi():
    sta_if = network.WLAN(network.STA_IF)
    sta_if.active(True)
    sta_if.connect('AP_name', 'AP_password')
    while not sta_if.isconnected():
        pass
    sleep(2)
    print('network config:', sta_if.ifconfig())
    sta_if.active(False)
    print('network config:', sta_if.ifconfig())


if __name__ == '__main__':
    getwifi()

inspection of micropython.network.pyi shows the only reference to STA_IF within comments suggesting code like above. inspection of esp8266.network.pyi shows STA_IF defined. FWIW attempted workaround by copying 'esp8266.network.pyi' to a user module and importing gets past the title error but produces a new error that 'typing' is not defined.

waanito avatar Jul 14 '23 20:07 waanito

Screen Shot 2023-07-17 at 1 27 17 PM

waanito avatar Jul 17 '23 20:07 waanito

Same issue. Have you figured it out, @waanito ?

andreluisos avatar Feb 11 '24 02:02 andreluisos

Following up to see if there is a resolution for this, I am also experiencing it.

acloaf avatar Mar 25 '24 16:03 acloaf