Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ports/espressif/bindings/espnow/ESPNow.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ static void espnow_check_for_deinit(espnow_obj_t *self) {
//| :param int buffer_size: The size of the internal ring buffer. Default: 526 bytes.
//| :param int phy_rate: The ESP-NOW physical layer rate. Default: 1 Mbps.
//| `wifi_phy_rate_t <https://docs.espressif.com/projects/esp-idf/en/release-v4.4/esp32/api-reference/network/esp_wifi.html#_CPPv415wifi_phy_rate_t>`_
//|
//| **Limitations:** Currently, setting ``phy_rate`` does nothing. The rate is always 1 Mbps.
//| """
//| ...
//|
Expand Down Expand Up @@ -231,6 +233,8 @@ MP_PROPERTY_GETTER(espnow_buffer_size_obj,
//| phy_rate: int
//| """The ESP-NOW physical layer rate.
//| `wifi_phy_rate_t <https://docs.espressif.com/projects/esp-idf/en/release-v4.4/esp32/api-reference/network/esp_wifi.html#_CPPv415wifi_phy_rate_t>`_
//|
//| **Limitations:** Currently, setting ``phy_rate`` does nothing. The rate is always 1 Mbps.
//| """
//|
static mp_obj_t espnow_get_phy_rate(const mp_obj_t self_in) {
Expand Down
21 changes: 13 additions & 8 deletions ports/espressif/common-hal/espnow/ESPNow.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,20 @@ void common_hal_espnow_init(espnow_obj_t *self) {
common_hal_wifi_radio_set_enabled(&common_hal_wifi_radio_obj, true);
}

esp_now_rate_config_t rate_config = {
.phymode = WIFI_PHY_MODE_LR,
.rate = self->phy_rate,
.ersu = false,
.dcm = false,
};
CHECK_ESP_RESULT(esp_now_set_peer_rate_config(NULL, &rate_config));

CHECK_ESP_RESULT(esp_now_init());

// esp_now_set_peer_rate_config() is poorly documented, and we haven't figured out
// what the esp_now_rate_config_t settings should be. For now, just ignore phy_rate.
// Note that esp_now_set_peer_rate_config() must be called after esp_now-init().
//
// esp_now_rate_config_t rate_config = {
// .phymode = WIFI_PHY_MODE_LR,
// .rate = self->phy_rate,
// .ersu = false,
// .dcm = false,
// };
// CHECK_ESP_RESULT(esp_now_set_peer_rate_config(NULL, &rate_config));

CHECK_ESP_RESULT(esp_now_register_send_cb(send_cb));
CHECK_ESP_RESULT(esp_now_register_recv_cb(recv_cb));
}
Expand Down
Loading