FTP connection to Gpy and AWS IoT platform connection



  • I have been working with Pycom for a while. Now I hope to connect the Gpy to AWS IoT platform following https://docs.pycom.io/tutorials/all/aws.html.

    But I got stuck at the step to
    "Connect to the device via FTP and put the root CA certificate, the client certificate (.pem.crt) and the private key (.private.pem.key) in the /flash/cert folder."

    I always use USB to update files in "/flash" and never use FTP. But seems like I cannot update files directly to "/flash/cert" as I used to do. However, I tried ftp connection, and no matter I use Filezilla, Mac OS Finder original ftp or cmd line ftp, I cannot get access to 192.168.4.1. The error is "ftp: Can't connect to `192.168.4.1': Connection refused"

    Therefore, two questions:

    1. Can I use Serial USB instead of FTP to modify the files in '/flash/cert'?
    2. If I want to use FTP, do I need to do some special configs on Gpy, such as running under the same wifi with my laptop or something? The tutorial document is too much simplified.


  • @robert-hh Sure thanks! I made it.



  • @Terry666 if you have the files on your PC you can upload them with Adafruit'd ampy or Dave Hyland's rshell app via USB.



  • @robert-hh Thanks!

    I happened to find what the problem is. The FTP IP of Gpy seems to be blocked by our intranet.

    Anyway, is there any other way to upload the CA files of AWS IoT platform to Gpy without using FTP?



  • @Terry666 Connection refused indicates a basic problem. What is the IP address of your PC? And as a test, can you 'ping' the GPy?



  • @robert-hh Thanks!

    I use them under the same WIFI. The main problem is that I cannot connect to the Gpy via FTP.

    I am using Mac and have tried the command line "ftp 192.168.4.1", Filezilla, and the original FTP method of Mac finder. All the ways failed.

    I am pretty sure that I followed the instructions of "https://docs.pycom.io/gettingstarted/programming/ftp.html" and changed essential configs like passive mode and one connection only. The error appeared to be "Connection refused".

    Could you please advise how to fix this?
    Or if you can advise another way to upload CA keys to cert folder, that would be great too.



  • @Terry666

    If I want to use FTP, do I need to do some special configs on Gpy, such as running under the same wifi with my laptop or something? The tutorial document is too much simplified.

    To use ftp, you PC and the GPY have to be on the same network. So either reconfigure the PC to have an IP address like 192.168.4.x (x not 1), or reconfigure the GPY. if you have already a local network, which you use for your PC, it may be more convenient to connect the GPY to that network in STA mode. Instructions and sample code is here: https://docs.pycom.io/tutorials/all/wlan.html, subsection "Connecting to a router". The script I use is below. It uses a static address WIFI_IP in the form 'xxx.xxx.xxx.xxx'. WIFI_SSID and WIFI_PASSWD are ssid and password. If you do not want to use a static address (even if it is useful), omit the first wlan.ifconfig() call.

    def do_connect():
        import network
        import time
        from uos import uname
        wlan = network.WLAN(mode=network.WLAN.STA) # create station interface
        if not wlan.isconnected():      # check if the station is connected to an AP
            wlan.ifconfig(config=(WIFI_IP, "255.255.255.0", ROUTER_IP,  ROUTER_IP))
            wlan.connect(ssid=WIFI_SSID, auth=(network.WLAN.WPA2, WIFI_PASSWD))
            for _ in range(100):
                if wlan.isconnected():      # check if the station is connected to an AP
                    break
                print('.', end='')
                time.sleep_ms(200)
            else:
                print("Connect attempt timed out\n")
                return
        print('\nnetwork config:', wlan.ifconfig())
    
    do_connect()
    
    

Log in to reply
 

Pycom on Twitter