mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
tests/multi_espnow: Add test case for espnow rate changes.
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c5_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c5_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Uses constants added in previous commit. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
committed by
Damien George
parent
7e10d22134
commit
938e2c0f2b
@@ -172,7 +172,7 @@ Configuration
|
||||
api-reference/network/esp_wifi.html#_CPPv415wifi_phy_rate_t>`_. This
|
||||
parameter is actually *write-only* due to ESP-IDF not providing any
|
||||
means for querying the radio interface's rate parameter.
|
||||
See also `espnow-long-range`.
|
||||
See also `espnow-long-range`. This API currently doesn't work on ESP32-C6.
|
||||
|
||||
.. data:: Returns:
|
||||
|
||||
|
||||
92
tests/multi_espnow/75_rate.py
Normal file
92
tests/multi_espnow/75_rate.py
Normal file
@@ -0,0 +1,92 @@
|
||||
# Test configuring transmit rates for ESP-NOW on ESP32
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
||||
try:
|
||||
import network
|
||||
import espnow
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
# ESP8266 doesn't support multiple ESP-NOW data rates
|
||||
if sys.platform == "esp8266":
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
# Currently the config(rate=...) implementation is not compatible with ESP32-C6
|
||||
# (this test passes when C6 is receiver, but not if C6 is sender.)
|
||||
if "ESP32C6" in sys.implementation._machine:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
# ESP32-C2 doesn't support Long Range mode. This test is currently written assuming
|
||||
# LR mode can be enabled.
|
||||
if "ESP32C2" in sys.implementation._machine:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
||||
timeout_ms = 1000
|
||||
default_pmk = b"MicroPyth0nRules"
|
||||
CHANNEL = 9
|
||||
|
||||
|
||||
def init_sta():
|
||||
sta = network.WLAN(network.WLAN.IF_STA)
|
||||
e = espnow.ESPNow()
|
||||
e.active(True)
|
||||
sta.active(True)
|
||||
sta.disconnect() # Force AP disconnect for any saved config, important so the channel doesn't change
|
||||
sta.config(channel=CHANNEL)
|
||||
e.set_pmk(default_pmk)
|
||||
# Enable both default 802.11 modes and Long Range modes
|
||||
sta.config(protocol=network.WLAN.PROTOCOL_LR | network.WLAN.PROTOCOL_DEFAULT)
|
||||
return sta, e
|
||||
|
||||
|
||||
# Receiver
|
||||
def instance0():
|
||||
sta, e = init_sta()
|
||||
multitest.globals(PEER=sta.config("mac"))
|
||||
multitest.next()
|
||||
while True:
|
||||
peer, msg = e.recv(timeout_ms)
|
||||
if peer is None:
|
||||
print("Timeout")
|
||||
break
|
||||
# Note that we don't have any way in Python to tell what data rate this message
|
||||
# was received with, so we're assuming the rate was correct.
|
||||
print(msg)
|
||||
e.active(False)
|
||||
|
||||
|
||||
# Sender
|
||||
def instance1():
|
||||
sta, e = init_sta()
|
||||
multitest.next()
|
||||
peer = PEER
|
||||
|
||||
e.add_peer(peer)
|
||||
# Test normal, non-LR rates
|
||||
for msg, rate in (
|
||||
(b"default rate", None),
|
||||
(b"5Mbit", espnow.RATE_5M),
|
||||
(b"11Mbit", espnow.RATE_11M),
|
||||
(b"24Mbit", espnow.RATE_24M),
|
||||
(b"54Mbit", espnow.RATE_54M),
|
||||
(b"250K LR", espnow.RATE_LORA_250K),
|
||||
(b"500K LR", espnow.RATE_LORA_500K),
|
||||
# switch back to non-LR rates to check it's all OK
|
||||
(b"1Mbit again", espnow.RATE_1M),
|
||||
(b"11Mbit again", espnow.RATE_11M),
|
||||
):
|
||||
if rate is not None:
|
||||
e.config(rate=rate)
|
||||
for _ in range(3):
|
||||
e.send(peer, msg)
|
||||
time.sleep_ms(50) # give messages some time to be received before continuing
|
||||
e.del_peer(peer)
|
||||
|
||||
e.active(False)
|
||||
31
tests/multi_espnow/75_rate.py.exp
Normal file
31
tests/multi_espnow/75_rate.py.exp
Normal file
@@ -0,0 +1,31 @@
|
||||
--- instance0 ---
|
||||
b'default rate'
|
||||
b'default rate'
|
||||
b'default rate'
|
||||
b'5Mbit'
|
||||
b'5Mbit'
|
||||
b'5Mbit'
|
||||
b'11Mbit'
|
||||
b'11Mbit'
|
||||
b'11Mbit'
|
||||
b'24Mbit'
|
||||
b'24Mbit'
|
||||
b'24Mbit'
|
||||
b'54Mbit'
|
||||
b'54Mbit'
|
||||
b'54Mbit'
|
||||
b'250K LR'
|
||||
b'250K LR'
|
||||
b'250K LR'
|
||||
b'500K LR'
|
||||
b'500K LR'
|
||||
b'500K LR'
|
||||
b'1Mbit again'
|
||||
b'1Mbit again'
|
||||
b'1Mbit again'
|
||||
b'11Mbit again'
|
||||
b'11Mbit again'
|
||||
b'11Mbit again'
|
||||
Timeout
|
||||
--- instance1 ---
|
||||
|
||||
Reference in New Issue
Block a user