25 lines
679 B
Python
25 lines
679 B
Python
from espnow import ESPNow
|
|
import network
|
|
|
|
sta = network.WLAN(network.STA_IF)
|
|
sta.active(True)
|
|
|
|
espnow = ESPNow()
|
|
espnow.active(True)
|
|
|
|
# add_peer() expects a 6-byte MAC (bytes/bytearray), not integers.
|
|
# Unicast placeholders (not broadcast/multicast) so get_peers() lists them.
|
|
# PEERS = aa:aa:aa:aa:aa:START … aa:aa:aa:aa:aa:END (inclusive last octet).
|
|
_PREFIX = b"\xaa\xaa\xaa\xaa\xaa"
|
|
_START_LAST_OCTET = 1
|
|
_END_LAST_OCTET = 40
|
|
PEERS = tuple(_PREFIX + bytes((i,)) for i in range(_START_LAST_OCTET, _END_LAST_OCTET + 1))
|
|
for peer in PEERS:
|
|
espnow.add_peer(peer)
|
|
|
|
print("peers:", PEERS)
|
|
|
|
for peer in PEERS:
|
|
espnow.send(peer, b"Hello, world!")
|
|
|
|
print(espnow.get_peers()) |