@@ -15,16 +15,14 @@ ESP_NOW_Serial_Class::ESP_NOW_Serial_Class(const uint8_t *mac_addr, uint8_t chan
15
15
: ESP_NOW_Peer(mac_addr, channel, iface, lmk){
16
16
tx_ring_buf = NULL ;
17
17
rx_queue = NULL ;
18
- rx2_queue = NULL ;
19
18
tx_sem = NULL ;
20
- last_tx_result = false ;
21
19
queued_size = 0 ;
22
20
queued_buff = NULL ;
23
21
resend_count = 0 ;
24
22
}
25
23
26
24
ESP_NOW_Serial_Class::~ESP_NOW_Serial_Class (){
27
-
25
+ end ();
28
26
}
29
27
30
28
size_t ESP_NOW_Serial_Class::setTxBufferSize (size_t tx_queue_len){
@@ -57,22 +55,6 @@ size_t ESP_NOW_Serial_Class::setRxBufferSize(size_t rx_queue_len){
57
55
return rx_queue_len;
58
56
}
59
57
60
- size_t ESP_NOW_Serial_Class::setRx2BufferSize (size_t rx_queue_len){
61
- if (rx2_queue){
62
- if (!rx_queue_len){
63
- vQueueDelete (rx2_queue);
64
- rx_queue = NULL ;
65
- }
66
- return 0 ;
67
- } else if (rx_queue_len){
68
- rx2_queue = xQueueCreate (rx_queue_len, sizeof (uint8_t ));
69
- if (!rx2_queue){
70
- return 0 ;
71
- }
72
- }
73
- return rx_queue_len;
74
- }
75
-
76
58
bool ESP_NOW_Serial_Class::begin (unsigned long baud){
77
59
if (!ESP_NOW.begin () || !add ()){
78
60
return false ;
@@ -83,15 +65,13 @@ bool ESP_NOW_Serial_Class::begin(unsigned long baud){
83
65
xSemaphoreGive (tx_sem);
84
66
}
85
67
setRxBufferSize (1024 );// default if not preset
86
- setRx2BufferSize (0 );// default if not preset
87
68
setTxBufferSize (1024 );// default if not preset
88
69
return true ;
89
70
}
90
71
91
72
void ESP_NOW_Serial_Class::end (){
92
73
remove ();
93
74
setRxBufferSize (0 );
94
- setRx2BufferSize (0 );
95
75
setTxBufferSize (0 );
96
76
if (tx_sem != NULL ) {
97
77
vSemaphoreDelete (tx_sem);
@@ -158,47 +138,17 @@ void ESP_NOW_Serial_Class::flush(){
158
138
vRingbufferGetInfo (tx_ring_buf, NULL , NULL , NULL , NULL , &uxItemsWaiting);
159
139
}
160
140
}
161
- // Upper chars
162
- int ESP_NOW_Serial_Class::available2 (void ){
163
- if (rx2_queue == NULL ){
164
- return -1 ;
165
- }
166
- return uxQueueMessagesWaiting (rx2_queue);
167
- }
168
-
169
- int ESP_NOW_Serial_Class::read2 (void ){
170
- if (rx2_queue == NULL ){
171
- return -1 ;
172
- }
173
- uint8_t c = 0 ;
174
- if (xQueueReceive (rx2_queue, &c, 0 )) {
175
- return c;
176
- }
177
- return -1 ;
178
- }
179
141
180
142
// RX callback
181
143
void ESP_NOW_Serial_Class::_onReceive (const uint8_t * data, size_t len){
182
- if (rx_queue == NULL && rx2_queue == NULL ){
144
+ if (rx_queue == NULL ){
183
145
return ;
184
146
}
185
- log_v (MACSTR" , data lenght : %u" , MAC2STR (addr ()), len);
147
+ log_v (MACSTR " , data lenght : %u" , MAC2STR (addr ()), len);
186
148
for (uint32_t i=0 ; i<len; i++){
187
- if (rx2_queue != NULL && (data[i] & 0x80 )){
188
- // it's upper char and rx2_queue exists
189
- if (!xQueueSend (rx2_queue, data+i, 0 )){
190
- return ;
191
- }
192
- } else if (rx_queue != NULL ){
193
- // either normal char or rx2_queue does not exist
194
- if (!xQueueSend (rx_queue, data+i, 0 )){
195
- return ;
196
- }
197
- } else if (rx2_queue != NULL ){
198
- // we have disabled rx_queue and are forwarding all to rx2
199
- if (!xQueueSend (rx2_queue, data+i, 0 )){
200
- return ;
201
- }
149
+ if (!xQueueSend (rx_queue, data+i, 0 )){
150
+ log_e (" RX Overflow!" );
151
+ return ;
202
152
}
203
153
}
204
154
// Now trigger the ISR to read data from the ring buffer.
0 commit comments