Skip to content

Commit e489e71

Browse files
changing synchronization to timer disable
1 parent 9e05471 commit e489e71

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

Diff for: libraries/lwIpWrapper/src/CNetIf.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ void CLwipIf::task() {
126126
iface->task();
127127
}
128128

129-
arduino::lock();
130129
sys_check_timeouts();
131-
arduino::unlock();
132130
}
133131

134132
void CLwipIf::setDefaultIface(CNetIf* iface) {

Diff for: libraries/lwIpWrapper/src/lwipClient.cpp

+9-10
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ err_t lwipClient::recv_callback(struct tcp_pcb* tpcb, struct pbuf* p, err_t err)
239239

240240
return ERR_OK;
241241
}
242-
arduino::lock();
243242
if(this->tcp_info->state == TCP_CONNECTED || this->tcp_info->state == TCP_ACCEPTED) {
244243
if (this->tcp_info->pbuf_head == nullptr) {
245244
// no need to increment the references of the pbuf,
@@ -252,7 +251,6 @@ err_t lwipClient::recv_callback(struct tcp_pcb* tpcb, struct pbuf* p, err_t err)
252251

253252
ret_err = ERR_OK;
254253
}
255-
arduino::unlock();
256254

257255
return ret_err;
258256
}
@@ -262,7 +260,7 @@ size_t lwipClient::write(uint8_t b) {
262260
}
263261

264262
size_t lwipClient::write(const uint8_t* buffer, size_t size) {
265-
arduino::lock();
263+
CLwipIf::getInstance().syncTimer();
266264

267265
uint8_t* buffer_cursor = (uint8_t*)buffer;
268266
uint16_t bytes_to_send = 0;
@@ -286,7 +284,8 @@ size_t lwipClient::write(const uint8_t* buffer, size_t size) {
286284

287285
tcp_output(this->tcp_info->pcb);
288286

289-
arduino::unlock();
287+
CLwipIf::getInstance().enableTimer();
288+
290289
return buffer_cursor - buffer;
291290
}
292291

@@ -312,14 +311,14 @@ int lwipClient::read(uint8_t* buffer, size_t size) {
312311
* meaning that across different calls of this function a pbuf could be partially copied
313312
* we need to account that
314313
*/
315-
arduino::lock();
314+
CLwipIf::getInstance().syncTimer();
316315
uint16_t copied = pbuf_copy_partial(this->tcp_info->pbuf_head, buffer, size, this->tcp_info->pbuf_offset);
317316

318317
this->tcp_info->pbuf_head = free_pbuf_chain(this->tcp_info->pbuf_head, copied, &this->tcp_info->pbuf_offset);
319318

320319
// acknowledge the received data
321320
tcp_recved(this->tcp_info->pcb, copied);
322-
arduino::unlock();
321+
CLwipIf::getInstance().enableTimer();
323322

324323
return copied;
325324
}
@@ -331,9 +330,9 @@ int lwipClient::peek() {
331330
return -1;
332331
}
333332

334-
arduino::lock();
333+
CLwipIf::getInstance().syncTimer();
335334
b = pbuf_get_at(this->tcp_info->pbuf_head, 0); // TODO test this
336-
arduino::unlock();
335+
CLwipIf::getInstance().enableTimer();
337336

338337
return b;
339338
}
@@ -417,7 +416,7 @@ size_t lwipClient::read_until_token(
417416
if(buffer_size==0 || buffer==nullptr || this->tcp_info->pbuf_head==nullptr) {
418417
return 0; // TODO extend checks
419418
}
420-
arduino::lock();
419+
CLwipIf::getInstance().syncTimer();
421420
// TODO check that the buffer size is less than the token len
422421

423422
uint16_t offset=this->tcp_info->pbuf_offset;
@@ -456,7 +455,7 @@ size_t lwipClient::read_until_token(
456455

457456
// acknowledge the received data
458457
tcp_recved(this->tcp_info->pcb, copied);
459-
arduino::unlock();
458+
CLwipIf::getInstance().enableTimer();
460459

461460
return copied;
462461
}

0 commit comments

Comments
 (0)