Move espnow to seperate file
This commit is contained in:
17
src/p2p.py
Normal file
17
src/p2p.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import asyncio
|
||||
import aioespnow
|
||||
import json
|
||||
|
||||
async def p2p(settings, patterns):
|
||||
e = aioespnow.AIOESPNow() # Returns AIOESPNow enhanced with async support
|
||||
e.active(True)
|
||||
async for mac, msg in e:
|
||||
try:
|
||||
data = json.loads(msg)
|
||||
except:
|
||||
print(f"Failed to load espnow data {msg}")
|
||||
continue
|
||||
#print(data)
|
||||
if "ids" not in data or settings.get("id") in data.get("ids", []):
|
||||
settings.set_settings(data.get("settings", {}), patterns, data.get("save", False))
|
||||
print("should not print")
|
Reference in New Issue
Block a user