ccalendar.py 1.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
import uurequests
import time
import machine
import network
import gc

def getEvents(param):
    led = machine.Pin(2, machine.Pin.OUT)
    sta_if = network.WLAN(network.STA_IF)
    ap_if = network.WLAN(network.AP_IF)
    ap_if.active(False)

    while True:
        text = "No events yet..."

        if sta_if.isconnected() == True:
            print("NEW REQUEST")
            print(sta_if.ifconfig())
            r = uurequests.get("https://script.google.com/macros/s/AKfycbyz55y8cdFmtX31yiOOuPn5SLGdGOuL6KvPOorfZZEmvzUppo0/exec")
            print(r.text)
            text = r.text
        else:
            import cconnect
            cconnect.make_connect()
            print("NEW REQUEST AFTER RECONNECT")
            r = uurequests.get("https://script.google.com/macros/s/AKfycbyz55y8cdFmtX31yiOOuPn5SLGdGOuL6KvPOorfZZEmvzUppo0/exec")
            print(r.text)
            text = r.text
        for i in range(120):
            print("FreeMem" + str(gc.mem_free()))
            led.on()
            time.sleep(1)
            led.off()
            time.sleep(1)
            print(text)

print("Welcome to calendar eventsssss")
Giacomo Lavermicocca's avatar
Giacomo Lavermicocca committed
38