WiFi AP



  • Hi everyone,
    I am following this tutorial:
    https://docs.pycom.io/tutorials/networks/wlan/#connecting-to-the-device
    But I can not see created AP from NTB.

    When Connecting to a Router everything alright (ftp, ssh, ping).
    https://docs.pycom.io/tutorials/networks/wlan/#connecting-to-a-router

    Thank you in advance for your assistance.
    Regards, Vojtech

    Test script:

    from network import WLAN
    wlan = WLAN(mode=WLAN.AP, ssid='hello world')
    wlan.init()
    print(wlan.ifconfig(id=1)) #id =1 signifies the AP interface
    while True:
        print("isconnected:",wlan.isconnected(), wlan.ifconfig(id=1))
    

    output:

    ('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')
    isconnected: False ('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')
    isconnected: False ('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')
    

    I am getting wlan.antenna() = 2 ?

    >>> wlan.antenna()
    2
    >>> WLAN.EXT_ANT
    1
    >>> WLAN.INT_ANT
    0
    

    system version:
    (sysname='GPy', nodename='GPy', release='1.20.2.r4', version='v1.11-ffb0e1c on 2021-01-12', machine='GPy with ESP32', pybytes='1.6.1')



  • @Gijs said in WiFi AP:

    I looked at this for a long time, but then figured it out

    Hi @Gijs
    I really appreciate the support you’ve given me. I have testes, everything all right.
    Regards, Vojtech



  • @Gijs this is a common trap. The init() calls of a device have to carry all parameters that are different from the default, since it usually sets all parameters.



  • @nadvorvo said in WiFi AP:

    I am getting wlan.antenna() = 2 ?

    This is WLAN.MAN_ANT, as you're not explicitly setting the antenna. MAN_ANT refers to manual antenna, and defaults to the internal antenna selected. In this mode, you can manually change P12 to reflect the antenna setting, and is used for the OEM modules, as they do not have an antenna switch.

    I looked at this for a long time, but then figured it out. There is a slight mistake in the example. If you remove the line wlan.init(), or transfer the arguments from wlan = WLAN() to wlan.init() it will work. What is happening is that wlan.init() overrides the settings in wlan = WLAN().
    I will change the example
    Sorry for the inconvenience,
    Gijs



  • @nadvorvo said in WiFi AP:

    while True:
    print("isconnected:",wlan.isconnected(), wlan.ifconfig(id=1))

    remove this lines as they are not relevant to AP mode - and this code never ending



  • @robert-hh said in WiFi AP:

    You could try to deactivate pybytes, for instance with:
    import pycom
    pycom.pybytes_on_boot(False)

    Hi @robert-hh,
    Thank you for your reply.

    I have deactivated pybytes, but I can not see created AP from NTB.

    pycom.pybytes_on_boot()
    False
    

    Then I tried to activate wifi_on_boot

    import pycom
    from network import WLAN
    pycom.pybytes_on_boot(False) #we do not want Pybytes using the WLAN
    pycom.smart_config_on_boot(False) #we also do not want smart config
    pycom.wifi_on_boot(True)
    pycom.wifi_mode_on_boot(WLAN.AP)
    pycom.wifi_ssid_ap('ssid')
    

    I can see wifi AP now.

    Then I tried to deactivate wifi_on_boot

    pycom.wifi_on_boot(False)
    

    no wifi AP now.



  • @nadvorvo You could try to deactivate pybytes, for instance with:

    import pycom
    pycom.pybytes_on_boot(False)


Log in to reply
 

Pycom on Twitter