micropython/ports
Glenn Moloney 7fa322afb8 esp32,esp8266: Add support for the Espressif ESP-NOW protocol.
ESP-NOW is a proprietary wireless communication protocol which supports
connectionless communication between ESP32 and ESP8266 devices, using
vendor specific WiFi frames.  This commit adds support for this protocol
through a new `espnow` module.

This commit builds on original work done by @nickzoic, @shawwwn and with
contributions from @zoland.  Features include:
- Use of (extended) ring buffers in py/ringbuf.[ch] for robust IO.
- Signal strength (RSSI) monitoring.
- Core support in `_espnow` C module, extended by `espnow.py` module.
- Asyncio support via `aioespnow.py` module (separate to this commit).
- Docs provided at `docs/library/espnow.rst`.

Methods available in espnow.ESPNow class are:
- active(True/False)
- config(): set rx buffer size, read timeout and tx rate
- recv()/irecv()/recvinto() to read incoming messages from peers
- send() to send messages to peer devices
- any() to test if a message is ready to read
- irq() to set callback for received messages
- stats() returns transfer stats:
    (tx_pkts, tx_pkt_responses, tx_failures, rx_pkts, lost_rx_pkts)
- add_peer(mac, ...) registers a peer before sending messages
- get_peer(mac) returns peer info: (mac, lmk, channel, ifidx, encrypt)
- mod_peer(mac, ...) changes peer info parameters
- get_peers() returns all peer info tuples
- peers_table supports RSSI signal monitoring for received messages:
    {peer1: [rssi, time_ms], peer2: [rssi, time_ms], ...}

ESP8266 is a pared down version of the ESP32 ESPNow support due to code
size restrictions and differences in the low-level API.  See docs for
details.

Also included is a test suite in tests/multi_espnow.  This tests basic
espnow data transfer, multiple transfers, various message sizes, encrypted
messages (pmk and lmk), and asyncio support.

Initial work is from https://github.com/micropython/micropython/pull/4115.
Initial import of code is from:
https://github.com/nickzoic/micropython/tree/espnow-4115.
2023-05-01 16:47:21 +10:00
..
bare-arm bare-arm/mpconfigport.h: Disable remaining optional features. 2021-11-01 14:23:06 +11:00
cc3200 all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
embed embed: Fix arguments to mp_raw_code_load_mem. 2023-03-13 12:35:12 +11:00
esp32 esp32,esp8266: Add support for the Espressif ESP-NOW protocol. 2023-05-01 16:47:21 +10:00
esp8266 esp32,esp8266: Add support for the Espressif ESP-NOW protocol. 2023-05-01 16:47:21 +10:00
mimxrt all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
minimal all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
nrf all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
pic16bit ports: Implement simple write polling for stdout. 2023-03-23 13:51:17 +11:00
powerpc all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
qemu-arm shared/runtime/gchelper: Drop cpu directive from ARM asm helpers. 2023-01-28 15:51:38 +11:00
renesas-ra renesas-ra/modutime: Use extmod version of time module. 2023-04-27 15:11:51 +10:00
rp2 all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
samd all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
stm32 all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
teensy all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
unix all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
webassembly webassembly/modutime: Use extmod version of time module. 2023-04-27 15:11:52 +10:00
windows unix/modutime: Use extmod version of time module. 2023-04-27 15:11:52 +10:00
zephyr zephyr/modutime: Use extmod version of time module. 2023-04-27 15:11:52 +10:00