diff options
| author | Damien George <damien@micropython.org> | 2023-05-09 09:52:54 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-06-23 15:34:22 +1000 |
| commit | e4650125b88a35f074097f16d84a8f49bd22ac06 (patch) | |
| tree | 6b87f056d0c23f2eb043fa2da0f949429af50e94 /ports/esp32/modespnow.c | |
| parent | 2af229c3cc55ceefc4cfba0f50092af725c3bfa9 (diff) | |
esp32: Update port to support IDF v5.0.2.
This commit updates the esp32 port to work exclusively with ESP-IDF v5.
IDF v5 is needed for some of the newer ESP32 SoCs to work, and it also
cleans up a lot of the inconsistencies between existing SoCs (eg S2, S3,
and C3).
Support for IDF v4 is dropped because it's a lot of effort to maintain both
versions at the same time.
The following components have been verified to work on the various SoCs:
ESP32 ESP32-S2 ESP32-S3 ESP32-C3
build pass pass pass pass
SPIRAM pass pass pass N/A
REPL (UART) pass pass pass pass
REPL (USB) N/A pass pass N/A
filesystem pass pass pass pass
GPIO pass pass pass pass
SPI pass pass pass pass
I2C pass pass pass pass
PWM pass pass pass pass
ADC pass pass pass pass
WiFi STA pass pass pass pass
WiFi AP pass pass pass pass
BLE pass N/A pass pass
ETH pass -- -- --
PPP pass pass pass --
sockets pass pass pass pass
SSL pass ENOMEM pass pass
RMT pass pass pass pass
NeoPixel pass pass pass pass
I2S pass pass pass N/A
ESPNow pass pass pass pass
ULP-FSM pass pass pass N/A
SDCard pass N/A N/A pass
WDT pass pass pass pass
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'ports/esp32/modespnow.c')
| -rw-r--r-- | ports/esp32/modespnow.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/ports/esp32/modespnow.c b/ports/esp32/modespnow.c index c71201e9b..c94fc8170 100644 --- a/ports/esp32/modespnow.c +++ b/ports/esp32/modespnow.c @@ -179,7 +179,7 @@ STATIC mp_obj_t espnow_make_new(const mp_obj_type_t *type, size_t n_args, // Forward declare the send and recv ESPNow callbacks STATIC void send_cb(const uint8_t *mac_addr, esp_now_send_status_t status); -STATIC void recv_cb(const uint8_t *mac_addr, const uint8_t *data, int len); +STATIC void recv_cb(const esp_now_recv_info_t *recv_info, const uint8_t *msg, int msg_len); // ESPNow.init(): Initialise the data buffers and ESP-NOW functions. // Initialise the Espressif ESPNOW software stack, register callbacks and @@ -254,13 +254,9 @@ STATIC mp_obj_t espnow_config(size_t n_args, const mp_obj_t *pos_args, mp_map_t self->recv_timeout_ms = args[ARG_timeout_ms].u_int; } if (args[ARG_rate].u_int >= 0) { - #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0) esp_initialise_wifi(); // Call the wifi init code in network_wlan.c check_esp_err(esp_wifi_config_espnow_rate(ESP_IF_WIFI_STA, args[ARG_rate].u_int)); check_esp_err(esp_wifi_config_espnow_rate(ESP_IF_WIFI_AP, args[ARG_rate].u_int)); - #else - mp_raise_ValueError(MP_ERROR_TEXT("rate option not supported")); - #endif } if (args[ARG_get].u_obj == MP_OBJ_NULL) { return mp_const_none; @@ -329,11 +325,7 @@ static inline int8_t _get_rssi_from_wifi_pkt(const uint8_t *msg) { (wifi_promiscuous_pkt_t *)(msg - sizeof_espnow_frame_format - sizeof(wifi_promiscuous_pkt_t)); - #if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 2, 0) - return wifi_pkt->rx_ctrl.rssi - 100; // Offset rssi for IDF 4.0.2 - #else return wifi_pkt->rx_ctrl.rssi; - #endif } // Lookup a peer in the peers table and return a reference to the item in the @@ -573,7 +565,7 @@ STATIC void send_cb(const uint8_t *mac_addr, esp_now_send_status_t status) { // ESPNow packet. // If the buffer is full, drop the message and increment the dropped count. // Schedules the user callback if one has been registered (ESPNow.config()). -STATIC void recv_cb(const uint8_t *mac_addr, const uint8_t *msg, int msg_len) { +STATIC void recv_cb(const esp_now_recv_info_t *recv_info, const uint8_t *msg, int msg_len) { esp_espnow_obj_t *self = _get_singleton(); ringbuf_t *buf = self->recv_buffer; // TODO: Test this works with ">". @@ -590,7 +582,7 @@ STATIC void recv_cb(const uint8_t *mac_addr, const uint8_t *msg, int msg_len) { #endif // MICROPY_ESPNOW_RSSI ringbuf_put_bytes(buf, (uint8_t *)&header, sizeof(header)); - ringbuf_put_bytes(buf, mac_addr, ESP_NOW_ETH_ALEN); + ringbuf_put_bytes(buf, recv_info->src_addr, ESP_NOW_ETH_ALEN); ringbuf_put_bytes(buf, msg, msg_len); self->rx_packets++; if (self->recv_cb != mp_const_none) { |
