Ejemplo n.º 1
0
def feed():
    global first
    wdt.feed()
    if safemode and not revert:
        return
    elif first is None:
        return  # done with safe mode stuff
    elif first == 0:
        first = time.ticks_ms()  # record time of first feeding
    elif time.ticks_diff(time.ticks_ms(), first) > allok:
        if sys.platform == 'esp32':
            # mark the current partition as OK, this prevents rollback after OTA
            from esp32 import Partition
            part = Partition(Partition.RUNNING)
            part.mark_app_valid_cancel_rollback()
        if safemode:
            log.critical("Switching to NORMAL MODE via reset")
            reset(True)
        else:
            log.warning("Next reset: normal boot")
            normalboot(True)
            first = None
Ejemplo n.º 2
0
Archivo: boot.py Proyecto: iot49/iot49
        if wlan.isconnected(): break
        time.sleep_ms(100)
    if not wlan.isconnected():
        print("Unable to connect to WiFi!")
        wlan.disconnect()
        return
    print("IP", wlan.ifconfig()[0])
    print("mDNS", mdns_name + ".local")
    # set clock to local time
    tm = time.localtime(ntptime.time() + getattr(secrets, 'tz_offset', 0))
    print("time", tm)
    machine.RTC().datetime(
        (tm[0], tm[1], tm[2], tm[6] + 1, tm[3], tm[4], tm[5], 0))


# OTA ... accept uploaded image (if we uploaded a new one)
from esp32 import Partition

Partition.mark_app_valid_cancel_rollback()

# connect to WiFi
connect()

if True:
    # webrepl
    import webrepl
    webrepl.start()
    network.WLAN(network.STA_IF).mdns_add_service('_ws', '_tcp', 8266)

gc.collect()