Skip to content

Commit 80b70aa

Browse files
author
fpr
committed
Code cleaned.
Required comments added. Documentation updated. Signed-off-by: fpr <[email protected]>
1 parent 0442f1f commit 80b70aa

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

cores/arduino/stm32/ethernet.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
22
******************************************************************************
3-
* @file digital_io.h
3+
* @file ethernet.h
44
* @author WI6LABS
55
* @version V1.0.0
6-
* @date 01-August-2016
7-
* @brief Header for digital_io module
6+
* @date 14-June-2017
7+
* @brief Header for ethernet background task for LwIP stack.
88
******************************************************************************
99
* @attention
1010
*
@@ -49,6 +49,8 @@
4949
/* Exported macro ------------------------------------------------------------*/
5050
/* Exported functions ------------------------------------------------------- */
5151

52+
/* This function is defined by the NativeEthernet library and it is used as
53+
background task inside the main loop. */
5254
__weak void stm32_eth_scheduler(void)
5355
{
5456
/* NOTE : This function should not be modified. It is defined in the Ethernet

libraries/NativeEthernet/README.adoc

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ http://git.savannah.gnu.org/cgit/lwip.git
1313
EthernetClass::maintain() in no more required to renew IP address from DHCP.
1414
It is done automatically by the LwIP stack in a background task.
1515

16-
An Idle task is required to handle timer and data reception. Be careful to not
17-
lock the system in a loop where LwIP could never be updated.
16+
An Idle task is required by the LwIP stack to handle timer and data reception.
17+
This idle task is called inside the main loop in background by the function
18+
stm32_eth_scheduler(). Be careful to not lock the system inside the function
19+
loop() where LwIP could never be updated. Call EthernetUDP::parsePacket() or
20+
EthernetClient::available() performs an update of the LwIP stack.
1821

1922
== License ==
2023

libraries/NativeEthernet/src/EthernetClient.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ bool EthernetClient::operator==(const EthernetClient& rhs) {
192192
return _tcp_client == rhs._tcp_client && _tcp_client->pcb == rhs._tcp_client->pcb;
193193
}
194194

195+
/* This function is not a function defined by Arduino. This is a function
196+
specific to the W5100 architecture. To keep the compatibility we leave it and
197+
returns always 0. */
195198
uint8_t EthernetClient::getSocketNumber() {
196199
return 0;
197200
}

libraries/NativeEthernet/src/NativeEthernet.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dn
4545
void EthernetClass::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)
4646
{
4747
stm32_eth_init(mac, local_ip.raw_address(), gateway.raw_address(), subnet.raw_address());
48+
/* If there is a local DHCP informs it of our manual IP configuration to
49+
prevent IP conflict */
4850
stm32_DHCP_manual_config();
4951
_dnsServerAddress = dns_server;
5052
}

libraries/NativeEthernet/src/utility/stm32_eth.c

+1-8
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,7 @@ struct pbuf *stm32_new_data(struct pbuf *p, const uint8_t *buffer, size_t size)
593593

594594
if(q != NULL) {
595595
if(ERR_OK == pbuf_copy(q, p)) {
596-
err_t err = pbuf_take_at(q, (uint8_t *)buffer, size, p->tot_len);
597-
if(ERR_OK == /*pbuf_take_at(q, (uint8_t *)buffer, size, p->tot_len)*/err) {
596+
if(ERR_OK == pbuf_take_at(q, (uint8_t *)buffer, size, p->tot_len)) {
598597
pbuf_free(p);
599598
p = q;
600599
return p;
@@ -742,9 +741,6 @@ err_t tcp_connected_callback(void *arg, struct tcp_pcb *tpcb, err_t err)
742741
/* initialize LwIP tcp_sent callback function */
743742
tcp_sent(tpcb, tcp_sent_callback);
744743

745-
/* initialize LwIP tcp_poll callback function */
746-
// tcp_poll(tpcb, tcp_poll_callback, 1);
747-
748744
/* initialize LwIP tcp_err callback function */
749745
tcp_err(tpcb, tcp_err_callback);
750746

@@ -814,9 +810,6 @@ err_t tcp_accept_callback(void *arg, struct tcp_pcb *newpcb, err_t err)
814810
/* initialize LwIP tcp_sent callback function */
815811
tcp_sent(newpcb, tcp_sent_callback);
816812

817-
/* initialize lwip tcp_poll callback function for newpcb */
818-
// tcp_poll(newpcb, tcp_echoserver_poll, 0);
819-
820813
ret_err = ERR_OK;
821814
} else {
822815
/* close tcp connection */

0 commit comments

Comments
 (0)