Connecting the LoPy in STA mode



  • Hello,

    I'm currently working on a project where my lopy is mounted on top of my roof for data logging. He's connecting my local wifi in STA mode.

    Since my code surely isn't perfect yet, but in the same time it is hard to quickly access the mounted lopy, I was asking myself if it was possible to connect to it via telnet and ftp in STA mode. I tried, but it failed with a "Connection refused" error. Can someone tell me what I have to do with my lopy so he's allowing to connect and upload new code?

    Thanks in adavance!



  • @robert-hh Thanks for the snippet. I can confirm that it seems to be a problem with my windows machine. I can now connect to the LoPy in STA mode via telnet and ftp (with my linux machine). Thanks for all the suggestions!



  • @binux I just tested it with my LoPy:
    STA_AP mode works. If enabled, I can connect to both the station and AP address with Telnet and ftp. The little script I use to set up the mode is:

    import network
    import time
    # setup as a station and AP
    wlan = network.WLAN(mode=network.WLAN.STA_AP)
    wlan.connect(ssid="ROUTER_SSID", auth=(network.WLAN.WPA2, "ROUTER PWD"))
    while not wlan.isconnected():
        time.sleep_ms(50)
    wlan.ifconfig(config=("my_fixed_IP", "255.255.255.0", "router_ip",  "router_ip"))
    print(wlan.ifconfig())
    

    It sets a fixed IP address in station mode. If you remove that statement, it will ask you home router for an IP address. The default IP address in AP mode stays 192.168.4.1, as you know.



  • @binux
    on Windows use Filezilla not built in Windows ftp.



  • @jmarcelino I'm sorry don't misunderstand me. I said the STA_AP mode is uinplemented or at least does not work for my 2 LoPys I have here.

    However your guess might be right. I'm on a windows machine I will switch to my other machine which runs Linux and see if I can reach it there. The iP adress should be correct since I see the packets sent by it through wireshark.



  • @binux
    I can assure you STA mode is implemented on the LoPy, I'm actually using that right now with both FTP and telnet.



  • @livius I'm on the most recent firmware. I have the WiPy aswell. The WiPy is a breeze to work with, sadly this doesn't apply to the LoPy where the most basic functions are pretty unstable. I think the Pycom guys yet didn't implement this mode on the LoPy (it's also not documented). At least I think I read that somewhere once.



  • The LoPy will answer on FTP and Telnet by default. Could you by any chance be trying the wrong IP address for it?

    I was also going to suggest there could be a firewall between your computer and the LoPy.



  • @binux It works well for me with a LoPy in STA mode. Which OS do you use. Windows command line ftp connects, but you can not transfer any data or list files, but telnet should work.
    (sysname='LoPy', nodename='LoPy', release='1.7.3.b1', version='18f1fd8-dirty on 2017-06-15', machine='LoPy with ESP32', lorawan='1.0.0')



  • @binux
    did you tried this on quite recent firmware?
    It work for me really good but i work with wipy2 not Lopy



  • I tried that mode in the past. I didn't work... On top in AP mode the LoPy also not always works and just times out the connection requests. So as long as the firmware is as unstable as it is right now it's not an option for me.

    I know you can answer HTTP requests with a socket and send a custom webpage as response however I don't know how I could possibly let someone interact with it. And that's why a simple FTP/Telnet connection would be so much better.

    Thanks for the suggestion though :)



  • @binux
    better use WLAN.STA_AP mode instead of only STA- then you can be connected to the router and in the same time you have AP running - and you can connect to it simple as always :)



Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.