Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change(esp_now_serial): No teardown on retry limit #10293

Merged
merged 3 commits into from
Sep 17, 2024
Merged
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
13 changes: 10 additions & 3 deletions libraries/ESP_NOW/src/ESP32_NOW_Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
*
*/

ESP_NOW_Serial_Class::ESP_NOW_Serial_Class(const uint8_t *mac_addr, uint8_t channel, wifi_interface_t iface, const uint8_t *lmk)
ESP_NOW_Serial_Class::ESP_NOW_Serial_Class(const uint8_t *mac_addr, uint8_t channel, wifi_interface_t iface, const uint8_t *lmk, bool remove_on_fail)
: ESP_NOW_Peer(mac_addr, channel, iface, lmk) {
tx_ring_buf = NULL;
rx_queue = NULL;
tx_sem = NULL;
queued_size = 0;
queued_buff = NULL;
resend_count = 0;
_remove_on_fail = remove_on_fail;
}

ESP_NOW_Serial_Class::~ESP_NOW_Serial_Class() {
Expand Down Expand Up @@ -264,9 +265,15 @@ void ESP_NOW_Serial_Class::onSent(bool success) {
//the data is lost in this case
vRingbufferReturnItem(tx_ring_buf, queued_buff);
queued_buff = NULL;
xSemaphoreGive(tx_sem);
end();
log_e(MACSTR " : RE-SEND_MAX[%u]", MAC2STR(addr()), resend_count);
//if we are not able to send the data and remove_on_fail is set, remove the peer
if (_remove_on_fail) {
xSemaphoreGive(tx_sem);
end();
return;
}
//log_d(MACSTR ": NEXT", MAC2STR(addr()));
checkForTxData();
}
}
}
3 changes: 2 additions & 1 deletion libraries/ESP_NOW/src/ESP32_NOW_Serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ class ESP_NOW_Serial_Class : public Stream, public ESP_NOW_Peer {
size_t queued_size;
uint8_t *queued_buff;
size_t resend_count;
bool _remove_on_fail;

bool checkForTxData();
size_t tryToSend();

public:
ESP_NOW_Serial_Class(const uint8_t *mac_addr, uint8_t channel, wifi_interface_t iface = WIFI_IF_AP, const uint8_t *lmk = NULL);
ESP_NOW_Serial_Class(const uint8_t *mac_addr, uint8_t channel, wifi_interface_t iface = WIFI_IF_AP, const uint8_t *lmk = NULL, bool remove_on_fail = false);
~ESP_NOW_Serial_Class();
size_t setRxBufferSize(size_t);
size_t setTxBufferSize(size_t);
Expand Down
Loading