From a55d412ba90f78481cf3ff0e975024b3c9b4f028 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 13 Sep 2022 13:47:47 +0200 Subject: [PATCH 01/11] fix: typo raised by spellcheck --- src/lwipopts_default.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lwipopts_default.h b/src/lwipopts_default.h index d7fae2d..f605098 100644 --- a/src/lwipopts_default.h +++ b/src/lwipopts_default.h @@ -51,7 +51,7 @@ a lot of data that needs to be copied, this should be set high. */ /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One per active UDP "connection". */ #define MEMP_NUM_UDP_PCB 6 -/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP +/* MEMP_NUM_TCP_PCB: the number of simultaneously active TCP connections. */ #define MEMP_NUM_TCP_PCB 10 /* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP @@ -60,7 +60,7 @@ a lot of data that needs to be copied, this should be set high. */ /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. */ #define MEMP_NUM_TCP_SEG 8 -/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active +/* MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active timeouts. */ #define MEMP_NUM_SYS_TIMEOUT 10 From b9cd0a34f9b5d9a8bfae37b22e101c2c7eea2b7f Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Tue, 13 Sep 2022 09:19:33 +0200 Subject: [PATCH 02/11] fix: set Ethernet Timer priority to 15 Aim is to have Ethernet Timer priority lower (higher value) than Systick (including FreeRTOS usecase) Signed-off-by: Alexandre Bourdiol --- src/utility/stm32_eth.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utility/stm32_eth.cpp b/src/utility/stm32_eth.cpp index 937a297..7b06955 100644 --- a/src/utility/stm32_eth.cpp +++ b/src/utility/stm32_eth.cpp @@ -67,6 +67,13 @@ #warning "Default timer used to call ethernet scheduler at regular interval: TIM14" #endif +/* Interrupt priority */ +#ifndef ETH_TIM_IRQ_PRIO + #define ETH_TIM_IRQ_PRIO 15 // Warning: it should be lower prio (higher value) than Systick +#endif +#ifndef ETH_TIM_IRQ_SUBPRIO + #define ETH_TIM_IRQ_SUBPRIO 0 +#endif /* Ethernet configuration: user parameters */ struct stm32_eth_config { ip_addr_t ipaddr; @@ -182,6 +189,7 @@ static void TIM_scheduler_Config(void) { /* Configure HardwareTimer */ EthTim = new HardwareTimer(DEFAULT_ETHERNET_TIMER); + EthTim->setInterruptPriority(ETH_TIM_IRQ_PRIO, ETH_TIM_IRQ_SUBPRIO); EthTim->setMode(1, TIMER_OUTPUT_COMPARE); /* Timer set to 1ms */ From aa551125b9132619d3d28a9196b7f8a4e7d7ff69 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 24 Nov 2022 11:48:54 +0100 Subject: [PATCH 03/11] ci: replace deprecated spellcheck by codespell --- .github/workflows/Continuous-Integration.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Continuous-Integration.yml b/.github/workflows/Continuous-Integration.yml index b324ceb..259d70f 100644 --- a/.github/workflows/Continuous-Integration.yml +++ b/.github/workflows/Continuous-Integration.yml @@ -31,14 +31,21 @@ jobs: run: | cat ${{ steps.Astyle.outputs.astyle-result }} exit 1 - spell-check: + codespell: + name: Check for spelling errors runs-on: ubuntu-latest - name: Spell check steps: - - uses: actions/checkout@main - - uses: arduino/actions/libraries/spell-check@master - # with: - # ignore-words-list: "./extras/codespell-ignore-words-list.txt" + - name: Checkout + uses: actions/checkout@main + + # See: https://github.com/codespell-project/actions-codespell/blob/master/README.md + - name: Spell check + uses: codespell-project/actions-codespell@master + with: + check_filenames: true + check_hidden: true + # In the event of a false positive, add the word in all lower case to this file: + # ignore_words_file: ./extras/codespell-ignore-words-list.txt lib_build: runs-on: ubuntu-latest name: Library compilation From 947471903b5099c6465ab2e474891decc0753059 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 28 Sep 2023 09:58:48 +0200 Subject: [PATCH 04/11] fix(client): setTimeout shadows Stream.setTimeout Rename it setConnectionTimeout to match Arduino Ethernet API. Fixes #72 Signed-off-by: Frederic Pillon --- keywords.txt | 1 + src/EthernetClient.cpp | 2 +- src/EthernetClient.h | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/keywords.txt b/keywords.txt index 367603a..e4af683 100644 --- a/keywords.txt +++ b/keywords.txt @@ -34,6 +34,7 @@ getSocketNumber KEYWORD2 localIP KEYWORD2 MACAddress KEYWORD2 maintain KEYWORD2 +setConnectionTimeout KEYWORD2 ####################################### # Constants (LITERAL1) diff --git a/src/EthernetClient.cpp b/src/EthernetClient.cpp index 4fd0a7f..b4ad99c 100644 --- a/src/EthernetClient.cpp +++ b/src/EthernetClient.cpp @@ -76,7 +76,7 @@ int EthernetClient::connect(IPAddress ip, uint16_t port) startTime = millis(); while (_tcp_client->state == TCP_NONE) { stm32_eth_scheduler(); - if ((_tcp_client->state == TCP_CLOSING) || ((millis() - startTime) >= _timeout)) { + if ((_tcp_client->state == TCP_CLOSING) || ((millis() - startTime) >= _connectionTimeout)) { stop(); return 0; } diff --git a/src/EthernetClient.h b/src/EthernetClient.h index c937a05..5afb160 100644 --- a/src/EthernetClient.h +++ b/src/EthernetClient.h @@ -52,9 +52,9 @@ class EthernetClient : public Client { { return (_tcp_client->pcb->remote_port); }; - void setTimeout(uint16_t timeout) + void setConnectionTimeout(uint16_t timeout) { - _timeout = timeout; + _connectionTimeout = timeout; } friend class EthernetServer; @@ -63,7 +63,7 @@ class EthernetClient : public Client { private: struct tcp_struct *_tcp_client; - uint16_t _timeout = 10000; + uint16_t _connectionTimeout = 10000; }; #endif From 6d46fb08c953119a9dd462fe790b0106bb54417e Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 28 Sep 2023 09:59:37 +0200 Subject: [PATCH 05/11] chore(keywords.txt): add missing keywords Signed-off-by: Frederic Pillon --- keywords.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/keywords.txt b/keywords.txt index e4af683..09e494c 100644 --- a/keywords.txt +++ b/keywords.txt @@ -24,7 +24,9 @@ peek KEYWORD2 flush KEYWORD2 stop KEYWORD2 connected KEYWORD2 +accept KEYWORD2 begin KEYWORD2 +beginMulticast KEYWORD2 beginPacket KEYWORD2 endPacket KEYWORD2 parsePacket KEYWORD2 @@ -32,11 +34,17 @@ remoteIP KEYWORD2 remotePort KEYWORD2 getSocketNumber KEYWORD2 localIP KEYWORD2 -MACAddress KEYWORD2 +localPort KEYWORD2 maintain KEYWORD2 +linkStatus KEYWORD2 +MACAddress KEYWORD2 +subnetMask KEYWORD2 +gatewayIP KEYWORD2 +dnsServerIP KEYWORD2 setConnectionTimeout KEYWORD2 ####################################### # Constants (LITERAL1) ####################################### - +LinkON LITERAL1 +LinkOFF LITERAL1 From df784287cd0e7468e88596c9517e0347609bc448 Mon Sep 17 00:00:00 2001 From: jeremyB01 <149951864+jeremyB01@users.noreply.github.com> Date: Mon, 6 Nov 2023 20:16:11 +0100 Subject: [PATCH 06/11] Fixing bug that caused large memory consumption Signed-off-by: jeremyB01 <149951864+jeremyB01@users.noreply.github.com> --- src/EthernetClient.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EthernetClient.cpp b/src/EthernetClient.cpp index b4ad99c..aa2606b 100644 --- a/src/EthernetClient.cpp +++ b/src/EthernetClient.cpp @@ -194,6 +194,7 @@ void EthernetClient::stop() if (status() != TCP_CLOSING) { tcp_connection_close(_tcp_client->pcb, _tcp_client); } + mem_free(_tcp_client); } uint8_t EthernetClient::connected() From c4b0663f8b88d0cb05fe5f2ea56fbdf755434151 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 7 Nov 2023 15:48:49 +0100 Subject: [PATCH 07/11] fix(doc): wiki link Signed-off-by: Frederic Pillon --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e2262d..b87f2b2 100644 --- a/README.md +++ b/README.md @@ -66,4 +66,4 @@ Call `Ethernet::schedule()` performs an update of the LwIP stack.
## Wiki -You can find information at https://github.com/stm32duino/wiki/wiki/STM32Ethernet +You can find information at https://github.com/stm32duino/Arduino_Core_STM32/wiki/STM32Ethernet From 566dc84252edf2ee76d13fdd6114302287c3fcdc Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 7 Nov 2023 11:19:53 +0100 Subject: [PATCH 08/11] fix(server): do not use same variable name Signed-off-by: Frederic Pillon --- src/EthernetServer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EthernetServer.cpp b/src/EthernetServer.cpp index 386ae9d..1355b88 100644 --- a/src/EthernetServer.cpp +++ b/src/EthernetServer.cpp @@ -93,10 +93,10 @@ size_t EthernetServer::write(const uint8_t *buffer, size_t size) accept(); - for (int n = 0; n < MAX_CLIENT; n++) { - if (_tcp_client[n] != NULL) { - if (_tcp_client[n]->pcb != NULL) { - EthernetClient client(_tcp_client[n]); + for (int i = 0; i < MAX_CLIENT; i++) { + if (_tcp_client[i] != NULL) { + if (_tcp_client[i]->pcb != NULL) { + EthernetClient client(_tcp_client[i]); uint8_t s = client.status(); if (s == TCP_ACCEPTED) { n += client.write(buffer, size); From 6b9664bac0db7f85563176135edd39f07e32a6b3 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 7 Nov 2023 11:21:06 +0100 Subject: [PATCH 09/11] feat(server): add bool operator Fixes #73. Signed-off-by: Frederic Pillon --- src/EthernetServer.cpp | 6 ++++++ src/EthernetServer.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/EthernetServer.cpp b/src/EthernetServer.cpp index 1355b88..81827d5 100644 --- a/src/EthernetServer.cpp +++ b/src/EthernetServer.cpp @@ -107,3 +107,9 @@ size_t EthernetServer::write(const uint8_t *buffer, size_t size) return n; } + +EthernetServer::operator bool() +{ + // server is listening for incoming clients + return ((_tcp_server.pcb != NULL) && (_tcp_server.pcb->state == LISTEN)); +} diff --git a/src/EthernetServer.h b/src/EthernetServer.h index 3a218d4..3205f6d 100644 --- a/src/EthernetServer.h +++ b/src/EthernetServer.h @@ -20,6 +20,7 @@ class EthernetServer : virtual void begin(uint16_t port); virtual size_t write(uint8_t); virtual size_t write(const uint8_t *buf, size_t size); + virtual operator bool(); using Print::write; }; From 88030146817040384e61df9e89651ac7ca13c23f Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 8 Nov 2023 14:42:28 +0100 Subject: [PATCH 10/11] feat(server): add end() Fixes #73. Signed-off-by: Frederic Pillon --- src/EthernetServer.cpp | 16 ++++++++++++++++ src/EthernetServer.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/EthernetServer.cpp b/src/EthernetServer.cpp index 81827d5..2082498 100644 --- a/src/EthernetServer.cpp +++ b/src/EthernetServer.cpp @@ -46,6 +46,22 @@ void EthernetServer::begin(uint16_t port) begin(); } +void EthernetServer::end(void) +{ + /* Free client */ + for (int n = 0; n < MAX_CLIENT; n++) { + if (_tcp_client[n] != NULL) { + EthernetClient client(_tcp_client[n]); + client.stop(); + _tcp_client[n] = NULL; + } + } + if (_tcp_server.pcb != NULL) { + tcp_close(_tcp_server.pcb); + _tcp_server.pcb = NULL; + } +} + void EthernetServer::accept() { /* Free client if disconnected */ diff --git a/src/EthernetServer.h b/src/EthernetServer.h index 3205f6d..10c306c 100644 --- a/src/EthernetServer.h +++ b/src/EthernetServer.h @@ -18,6 +18,7 @@ class EthernetServer : EthernetClient available(); virtual void begin(); virtual void begin(uint16_t port); + void end(void); virtual size_t write(uint8_t); virtual size_t write(const uint8_t *buf, size_t size); virtual operator bool(); From cd50f45d53fefd1b947b2a2552f672f328321a3f Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 9 Nov 2023 16:51:29 +0100 Subject: [PATCH 11/11] chore: bump library version Signed-off-by: Frederic Pillon --- library.json | 2 +- library.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index f4f202c..f8fe867 100755 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/stm32duino/STM32Ethernet" }, - "version": "1.3.0", + "version": "1.4.0", "frameworks": "arduino", "platforms": "ststm32", "build": { diff --git a/library.properties b/library.properties index 3a4aaee..a7e954a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=STM32duino STM32Ethernet -version=1.3.0 +version=1.4.0 author=Various maintainer=STMicroelectronics sentence=Enables network connection (local and Internet) using the STM32 Board.