Wykres commitów

12 Commity (7fa322afb8b3d4b124fa613d357cba5c30ac56d8)

Autor SHA1 Wiadomość Data
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
Jim Mussared eb51ca4a11 esp32: Use extmod/modnetwork.c instead of port-specific version.
Rather than duplicating the implementation of `network`, this allows ESP32
to use the shared one in extmod.  In particular this gains access to
network.hostname and network.country.

Set default hostnames for various ESP32 boards.

Other than adding these two methods and the change to the default hostname,
there is no other user-visible change.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-03-01 01:26:54 +11:00
ma-lalonde 30db33d1e0 esp32/network_lan: Add support for Ethernet PHY KSZ8081.
This is available since ESP-IDF v4.4.

Signed-off-by: Damien George <damien@micropython.org>
2023-01-19 22:50:41 +11:00
Damien Tournoud e982c1d8de esp32/network_lan: Add support for SPI-based ethernet chips.
Add support for various SPI-based ethernet chips (W5500, KSZ8851SNL,
DM9051) to the ESP32 port.  This leverages the existing support in ESP-IDF
for these chips -- which configures these chips in "MAC raw" mode -- and
the existing support for network.LAN in the ESP32 port.  In particular,
this doesn't leverage the wiznet5k support that is used on the rp2 and
stm32 ports (because that's for native use of lwIP).

Tested on the POE Featherwing (with the SJIRQ solder jumper bridged) and a
ESP32-S3 feather.

A note about the interrupt pin: The W5500 implementation within ESP-IDF
relies on hardware interrupt, and requires the interrupt pin from the W5500
to be wired to a GPIO.  This is not the case by default on the Adafruit
Ethernet FeatherWing, which makes it not directly compatible with this
implementation.
2023-01-18 11:16:09 +11:00
robert-hh efb4bd3555 esp32/network_lan: Add support for LAN8710 PHY.
LAN8710 uses the same drivers as LAN8720, so this commit just adds the
names.  Alternatively, both could be summarised under LAN87xx, like the
esp-idf does.
2023-01-18 10:04:31 +11:00
Damien George ea186de4c5 esp32: Split out WLAN code from modnetwork.c to network_wlan.c.
To match network_lan.c and network_ppp.c, and make it clear what code is
specifically for WLAN support.

Also provide a configuration option MICROPY_PY_NETWORK_WLAN which can be
used to fully disable network.WLAN (it's enabled by default).

Signed-off-by: Damien George <damien@micropython.org>
2021-09-24 12:41:35 +10:00
Tobias Eydam 48437cec45 esp32/network_lan: Add Ethernet support for IDF v4.1 and above.
Ethernet-PHYs from ESP-IDF (LAN8720, IP101, RTL8201, DP83848) are now
supported in IDF v4.1 and above.  PHY_KSZ8041 is only for ESP-IDF 4.3 and
above.  ESP32S2 is not supported.

Signed-off-by: Tobias Eydam <eydam-prototyping@outlook.com>
2021-06-17 15:36:14 +10:00
Kenneth Ryerson 76fefad18b esp32/network_lan: Add support for IP101 PHY.
Signed-off-by: Kenneth Ryerson <kenneth.ryerson@gmail.com>
2020-07-21 00:59:47 +10:00
Eric Poulsen 5635b96461 esp32: Add 'config' function to network.LAN, reusing network.WLAN. 2019-08-28 13:11:48 +10:00
Eric Poulsen 3c6f639aa5 esp32/network_ppp: Add PPPoS functionality.
This commit adds network.PPP(stream) which allows to create a TCP/IP
network interface over a stream object (eg a UART).
2018-10-19 23:32:02 +11:00
Damien George 999c8b9711 esp32/modsocket: Add support for registering socket event callbacks.
The esp8266 uses modlwip.c for its usocket implementation, which allows to
easily support callbacks on socket events (like when a socket becomes ready
for reading).  This is not as easy to do for the esp32 which uses the
ESP-IDF-provided lwIP POSIX socket API.  Socket events are needed to get
WebREPL working, and this patch provides a way for such events to work by
explicitly polling registered sockets for readability, and then calling the
associated callback if the socket is readable.
2018-04-27 23:57:26 +10:00
Eric Poulsen 29dd6a7678 esp32: Implement wired Ethernet via network.LAN().
Updates to Makefile, modnetwork.c, and addition of network_lan.c to
implement `network.LAN()` object for wired PHY objects.
2017-12-13 14:48:53 +11:00