test(led-driver): add espnow peer and ap pm0 scripts
Made-with: Cursor
This commit is contained in:
25
tests/peers.py
Normal file
25
tests/peers.py
Normal file
@@ -0,0 +1,25 @@
|
||||
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())
|
||||
Reference in New Issue
Block a user