Added WTD
This commit is contained in:
parent
941a5fb12f
commit
04580bb5a9
26
main.py
26
main.py
@ -5,38 +5,44 @@ from machine import Pin, UART, WDT
|
|||||||
from umqtt.simple import MQTTClient
|
from umqtt.simple import MQTTClient
|
||||||
|
|
||||||
prefix = config.MQTT_ID + "/"
|
prefix = config.MQTT_ID + "/"
|
||||||
|
print("Booting...")
|
||||||
|
|
||||||
led = Pin("LED", machine.Pin.OUT)
|
led = Pin("LED", machine.Pin.OUT)
|
||||||
led.value(1)
|
led.value(1)
|
||||||
time.sleep_us(200)
|
time.sleep(0.1)
|
||||||
led.value(0)
|
led.value(0)
|
||||||
time.sleep_us(200)
|
time.sleep(0.1)
|
||||||
led.value(1)
|
led.value(1)
|
||||||
time.sleep_us(200)
|
time.sleep(0.1)
|
||||||
led.value(0)
|
led.value(0)
|
||||||
time.sleep_us(200)
|
|
||||||
led.value(1)
|
|
||||||
|
|
||||||
wdt = WDT(timeout=30000)
|
wdt = WDT()
|
||||||
|
|
||||||
|
print("Setting up WLAN")
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(config.WIFI_SSID, config.WIFI_PASS)
|
wlan.connect(config.WIFI_SSID, config.WIFI_PASS)
|
||||||
|
|
||||||
|
wdt.feed()
|
||||||
while not wlan.isconnected() and wlan.status() >= 0:
|
while not wlan.isconnected() and wlan.status() >= 0:
|
||||||
print("Waiting to connect:")
|
print("Connecting...")
|
||||||
led.value(1)
|
led.value(1)
|
||||||
time.sleep_us(500)
|
time.sleep(0.5)
|
||||||
led.value(0)
|
led.value(0)
|
||||||
time.sleep_us(500)
|
time.sleep(0.5)
|
||||||
|
wdt.feed()
|
||||||
|
|
||||||
print("Connected!")
|
print("Connected!")
|
||||||
led.value(0)
|
led.value(0)
|
||||||
|
|
||||||
|
wdt.feed()
|
||||||
|
print("Setting up MQTT")
|
||||||
client = MQTTClient(config.MQTT_ID, config.MQTT_BROKER,user=None, password=None, keepalive=300, ssl=False, ssl_params={})
|
client = MQTTClient(config.MQTT_ID, config.MQTT_BROKER,user=None, password=None, keepalive=300, ssl=False, ssl_params={})
|
||||||
client.connect()
|
client.connect()
|
||||||
client.publish(prefix + 'status', "connected")
|
client.publish(prefix + 'status', "connected")
|
||||||
|
|
||||||
|
wdt.feed()
|
||||||
|
print("Setting up UART")
|
||||||
uart = machine.UART(0, 115200,invert=UART.INV_RX)
|
uart = machine.UART(0, 115200,invert=UART.INV_RX)
|
||||||
|
|
||||||
def readUntil(uartObject, termination, maxlen=-1, includeTermination=True):
|
def readUntil(uartObject, termination, maxlen=-1, includeTermination=True):
|
||||||
@ -80,6 +86,8 @@ def parse_han_protocol(data):
|
|||||||
|
|
||||||
data = ""
|
data = ""
|
||||||
|
|
||||||
|
wdt.feed()
|
||||||
|
print("Running...")
|
||||||
while True:
|
while True:
|
||||||
led.value(0)
|
led.value(0)
|
||||||
wdt.feed()
|
wdt.feed()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user