WiPy FW update OTA

  • Hi, I am trying to do FW update to WiPy module.
    I am getting Exception: Failed to download\config.py
    But, if I type the same url in browser, config.py gets downloaded.
    As there is no LoRa on WiPy, I altered the code in terms of trigger for update.
    If "123" is entered through serial comm, it triggers the fw update.

    from network import WLAN
    import socket
    import time
    from OTA import WiFiOTA
    from time import sleep
    import pycom
    import binascii
    WIFI_SSID = "#####"
    WIFI_PW = "#######"
    SERVER_IP = ""
    from config import WIFI_SSID, WIFI_PW, SERVER_IP
    # Turn on GREEN LED
    # Setup OTA
    ota = WiFiOTA(WIFI_SSID,
                  SERVER_IP,  # Update server address
                  8000)  # Update server port
    # Turn off WiFi to save power
    w = WLAN()
    # Initialize LoRa in LORAWAN mode.
    #lora = LoRa(mode=LoRa.LORAWAN)
    #app_eui = binascii.unhexlify('ENTER_ME')
    #app_key = binascii.unhexlify('ENTER_ME')
    # join a network using OTAA (Over the Air Activation)
    #lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)
    # wait until the module has joined the network
    #while not lora.has_joined():
    #    time.sleep(2.5)
    #    print('Not yet joined...')
    # create a LoRa socket
    #s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    # create tcp socket for non-lora
    #s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    # set the LoRaWAN data rate
    #s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)
    #tcp socket
    #s.connect((SERVER_IP, 3000))
    # make the socket blocking
    # (waits for the data to be sent and for the 2 receive windows to expire)
    print("created socket..now listening")
    print("ip addr is", w.ifconfig())
    while True:
        # send some data
        #s.send(bytes([0x04, 0x05, 0x06]))
        print(bytes([0x04, 0x05, 0x06]))
        # make the socket non-blocking
        # (because if there's no data received it will block forever...)
        # get any data received (if any...)
        #data = s.recv(64)
        data=input("enter 123 for firmware update")
        print("data", data)
        # Some sort of OTA trigger
        #if data == bytes([0x01, 0x02, 0x03]):
        if data=="123":
            print("Performing OTA")
            # Perform OTA
            print("OTA connect")

  • administrators


    It's likely that your web browser is automatically correcting this but the wipy is not, the manifest downloads ok because it has no backslashes in the URL. Could you add the following line to OTA_server.py and let me know if it fixes the issue:

    def generate_manifest_entry(host, path, version):
        path = "/".join(path.split(os.path.sep))  # Add this line
        entry = {}

  • @seb Yes, I see message that it requested. I am running server on my windows system.
    I thought the same that issue is with backward slash. But, if I copy-paste the same url i.e. with backward slash, the file gets downloaded.
    So, I thought something might be wrong on client running on pycom board.
    It is getting manifest.json successfully.
    The issue is with "Get file".

    0_1518714729654_pycom OTA server.PNG

    Thank you,

  • administrators

    It could be due to the backslash rather than a forward slash. What OS are you running the server on? When the WiPy tries to download this file do you see a message from the server that it has tried?

  • Please edit your post and add ˋ`ˋ on separate lines before and after your code so it gets properly formatted.

Log in to reply

Pycom on Twitter

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