Exemplo n.º 1
0
def connectToWifiAndUpdate():
    import time, machine, network, gc, app.secrets as secrets
    time.sleep(1)
    print('Memory free', gc.mem_free())

    from app.ota_updater import OTAUpdater

    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect(secrets.WIFI_SSID, secrets.WIFI_PASSWORD)
        while not sta_if.isconnected():
            pass
    print('network config:', sta_if.ifconfig())
    otaUpdater = OTAUpdater(
        'https://github.com/rdehuyss/micropython-ota-updater',
        main_dir='app',
        secrets_file="secrets.py")
    hasUpdated = otaUpdater.install_update_if_available()
    if hasUpdated:
        machine.reset()
    else:
        del (otaUpdater)
        gc.collect()
Exemplo n.º 2
0
def connectToWifiAndUpdate():
    import time, machine, network, gc
    from app.secrets import Secrets
    time.sleep(1)
    print('Memory free', gc.mem_free())

    from app.ota_updater import OTAUpdater

    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected():
        print('Connecting to network...')
        secrets = Secrets()
        sta_if.active(True)
        sta_if.connect(secrets.WIFI_SSID, secrets.WIFI_PASSWORD)
        while not sta_if.isconnected():
            pass
    print('network config:', sta_if.ifconfig())
    # otaUpdater = OTAUpdater('https://github.com/shivomthakkar/micropython-ota-updater', main_dir='app', secrets_file="secrets.py")
    token = 'aa517681738b4971cc55b7d9e8967780ff1f443b'
    otaUpdater = OTAUpdater(
        'https://github.com/shivomthakkar/micropython-ota-updater',
        main_dir="app",
        headers={'Authorization': 'token {}'.format(token)})
    hasUpdated = otaUpdater.install_update_if_available()
    if hasUpdated:
        machine.reset()
    else:
        del (otaUpdater)
        gc.collect()
Exemplo n.º 3
0
def connectToWifiAndUpdate():
    import time, machine, network, gc, app.secrets as secrets
    time.sleep(1)
    print('Memory free', gc.mem_free())

    from app.ota_updater import OTAUpdater

    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect(secrets.WIFI_SSID, secrets.WIFI_PASSWORD)
        while not sta_if.isconnected():
            pass
    print('network config:', sta_if.ifconfig())
    token = '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'
    otaUpdater = OTAUpdater(
        'https://github.com/veriaci/Yummy-IoTChiller',
        headers={'Authorization': 'token {}'.format(token)},
        main_dir='app',
        secrets_file="secrets.py")
    hasUpdated = otaUpdater.install_update_if_available()
    if hasUpdated:
        machine.reset()
    else:
        del (otaUpdater)
        gc.collect()
Exemplo n.º 4
0
def ota():
    from app.ota_updater import OTAUpdater
    #def download_and_install_update_if_available():
    # o = OTAUpdater('https://github.com/sensorwifi/ota_door')
    #otaUpdater = OTAUpdater('https://github.com/rdehuyss/chicken-shed-mgr', github_src_dir='app', main_dir='app', secrets_file="secrets.py")
    o = OTAUpdater('https://github.com/sensorwifi/ota_door_temperature',
                   main_dir='app',
                   headers={'Authorization': 'token {}'.format(token)})
    print(o)
    o.install_update_if_available_after_boot(ssid, password)
    print(update)
Exemplo n.º 5
0
def check_for_updates():
    print('Checking for updates...')
    otaUpdater = OTAUpdater(secrets.GITHUB_URL,
                            github_src_dir='src',
                            main_dir='app',
                            secrets_file="secrets.py")
    was_installed = False
    version = '?'
    try:
        (was_installed, version) = otaUpdater.install_update_if_available()
    except Exception as e:
        print('Error during update check:', e)
    del (otaUpdater)
    if was_installed:
        print('Update to version {} installed, reboot...'.format(version))
        machine.reset()
        utime.sleep(5)
    else:
        print('Current version {} ok, no new version found'.format(version))
    return version