Skip to content

ESP-NOW uasyncio, sending heartbeat to multiple peers #9171

Discussion options

You must be logged in to vote

I figured it out!

changed

async def heartbeat(e, peer, period=30):
    while True:
        if not await e.asend(peer, b'ping'):
            print("Heartbeat: peer not responding:", peer)
        else:
            print("Heartbeat: ping", peer)
        await asyncio.sleep(period)


to this

async def heartbeat(e, peers, period=30):
    while True:
        for i in peers:
            if not await e.asend(i, b'ping'):
                print("Heartbeat: peer not responding:", i)
            else:
                print("Heartbeat: ping", i)
            await asyncio.sleep(period)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@glenn20
Comment options

Answer selected by dtuando
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants