mirror of
https://github.com/espressif/arduino-esp32
synced 2024-09-21 02:18:29 +00:00
change(esp_now_serial): No teardown on retry limit (#10293)
* change(ESP_NOW_Serial): No teardown on retry limit After max retries is met once the ESP_NOW_Serial_Class performs "end()". This removes the peer from ESP_NOW. Further messages to and from ESP_NOW_Serial are not received or sent. Peer should stay in ESP_NOW to re-establish connection even with data loss. This change will "retry and drop" the data piece by piece instead of aborting the connection. * feat(espnow): Add remove on fail parameter * feat(espnow): By default keep the peer when sending fails --------- Co-authored-by: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
This commit is contained in:
parent
e989445b62
commit
c55f5aa506
@ -11,7 +11,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
@ -19,6 +19,7 @@ ESP_NOW_Serial_Class::ESP_NOW_Serial_Class(const uint8_t *mac_addr, uint8_t chan
|
||||
queued_size = 0;
|
||||
queued_buff = NULL;
|
||||
resend_count = 0;
|
||||
_remove_on_fail = remove_on_fail;
|
||||
}
|
||||
|
||||
ESP_NOW_Serial_Class::~ESP_NOW_Serial_Class() {
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,13 @@ private:
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user