Move espnow to seperate file

This commit is contained in:
2025-06-19 19:05:08 +12:00
parent 279416cded
commit 524db5e979
2 changed files with 19 additions and 12 deletions

17
src/p2p.py Normal file
View 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")