@@ -5,7 +5,8 @@ extern "C" {
5
5
#include " Arduino.h"
6
6
7
7
#include " lwipClient.h"
8
-
8
+ #include " CNetIf.h"
9
+ #include " utils.h"
9
10
// FIXME understand hos to syncronize the interrupt thread and "userspace"
10
11
// TODO look into tcp_bind_netif for Ethernet and WiFiClient classes
11
12
// TODO generalize the functions for extracting and inserting data into pbufs, they may be reused in UDP
@@ -203,7 +204,7 @@ size_t lwipClient::write(uint8_t b) {
203
204
return write (&b, 1 );
204
205
}
205
206
206
- size_t lwipClient::write (const uint8_t * buf , size_t size) {
207
+ size_t lwipClient::write (const uint8_t * buffer , size_t size) {
207
208
arduino::lock ();
208
209
209
210
uint8_t * buffer_cursor = (uint8_t *)buffer;
@@ -244,23 +245,23 @@ int lwipClient::read() {
244
245
return res == 1 ? c : res;
245
246
}
246
247
247
- int lwipClient::read (uint8_t * buf , size_t size) {
248
- if (buffer_size ==0 || buffer==nullptr || this ->pbuf_head ==nullptr ) {
248
+ int lwipClient::read (uint8_t * buffer , size_t size) {
249
+ if (size ==0 || buffer==nullptr || this ->pbuf_head ==nullptr ) {
249
250
return 0 ; // TODO extend checks
250
251
}
251
252
// copy data from the lwip buffer to the app provided buffer
252
253
// TODO look into pbuf_get_contiguous(this->pbuf_head, buffer_cursor, len);
253
- // pbuf_get_contiguous: returns the pointer to the payload if buffer_size <= pbuf.len
254
+ // pbuf_get_contiguous: returns the pointer to the payload if size <= pbuf.len
254
255
// otherwise copies data in the user provided buffer. This can be used in a callback paradigm,
255
256
// in order to avoid memcpy data
256
257
257
258
/*
258
- * a chain of pbuf is not granted to have a size multiple of buffer_size length
259
+ * a chain of pbuf is not granted to have a size multiple of size length
259
260
* meaning that across different calls of this function a pbuf could be partially copied
260
261
* we need to account that
261
262
*/
262
263
arduino::lock ();
263
- uint16_t copied = pbuf_copy_partial (this ->pbuf_head , buffer, buffer_size , this ->pbuf_offset );
264
+ uint16_t copied = pbuf_copy_partial (this ->pbuf_head , buffer, size , this ->pbuf_offset );
264
265
265
266
this ->free_pbuf_chain (copied);
266
267
// __enable_irq();
0 commit comments