Move espnow to seperate file
This commit is contained in:
14
src/main.py
14
src/main.py
@@ -9,6 +9,7 @@ import machine
|
||||
import time
|
||||
import wifi
|
||||
import json
|
||||
from p2p import p2p
|
||||
|
||||
async def main():
|
||||
settings = Settings()
|
||||
@@ -26,17 +27,6 @@ async def main():
|
||||
patterns.tick()
|
||||
await asyncio.sleep_ms(1)
|
||||
|
||||
|
||||
async def espnow():
|
||||
e = aioespnow.AIOESPNow() # Returns AIOESPNow enhanced with async support
|
||||
e.active(True)
|
||||
async for mac, msg in e:
|
||||
data = json.loads(msg)
|
||||
#print(data)
|
||||
if "ids" not in data or settings["id"] in data["ids"]:
|
||||
settings.set_settings(data["settings"], patterns, data.get("save", False))
|
||||
print("should not print")
|
||||
|
||||
async def wifi_connect():
|
||||
for i in range(10):
|
||||
config = wifi.connect(settings.get("wifi_ssid", ""),
|
||||
@@ -60,7 +50,7 @@ async def main():
|
||||
|
||||
#asyncio.create_task(wifi_connect())
|
||||
asyncio.create_task(tick())
|
||||
asyncio.create_task(espnow())
|
||||
asyncio.create_task(p2p(settings, patterns))
|
||||
|
||||
while True:
|
||||
|
||||
|
Reference in New Issue
Block a user