From 6b0a17d2ed9df619b51cf6a41ccb9f9351f273b7 Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Sat, 8 Jan 2022 00:08:13 -0500 Subject: [PATCH] v1.5.0 to fix the blocking issue in loop() ### Release v1.5.0 1. Workaround for core WiFi.status() bug, which does not detect WiFi lost. 2. Fix the blocking issue in loop(). Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18) 3. Configurable `WIFI_RECON_INTERVAL`. Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18#issuecomment-1006197561) 4. Update `Packages' Patches` --- CONTRIBUTING.md | 10 +- .../lwipstack/include/lwipstack/lwipopts.h | 347 ++++++++++++++++++ .../lwipstack/include/lwipstack/lwipopts.h | 347 ++++++++++++++++++ .../lwipstack/include/lwipstack/lwipopts.h | 347 ++++++++++++++++++ .../libraries/SocketWrapper/src/MbedUdp.cpp | 217 +++++++++++ .../libraries/SocketWrapper/src/MbedUdp.h | 105 ++++++ .../2.6.1/portenta_post_install.sh | 22 ++ README.md | 103 +++++- changelog.md | 9 + .../Portenta_H7_WiFi/Portenta_H7_WiFi.ino | 4 +- examples/Portenta_H7_WiFi/defines.h | 16 +- keywords.txt | 1 + library.json | 9 +- library.properties | 5 +- platformio/platformio.ini | 16 +- src/FlashIAPLimits.h | 5 +- src/WiFiManager_Portenta_H7_Lite.h | 82 ++++- src/WiFiManager_Portenta_H7_Lite_Debug.h | 15 +- 18 files changed, 1604 insertions(+), 56 deletions(-) create mode 100644 Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h create mode 100644 Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h create mode 100644 Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h create mode 100644 Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.cpp create mode 100644 Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.h create mode 100644 Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bf94a68..a12cadf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,8 +14,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p Please ensure to specify the following: -* Arduino IDE version (e.g. 1.8.16) or Platform.io version -* `ArduinoCore-mbed` Core Version (e.g. `ArduinoCore-mbed` mbed_portenta core v2.5.2) +* Arduino IDE version (e.g. 1.8.19) or Platform.io version +* `ArduinoCore-mbed` Core Version (e.g. `ArduinoCore-mbed` mbed_portenta core v2.6.1) * `Portenta_H7` Board type (e.g. Portenta_H7 Rev2 ABX00042, etc.) * Contextual information (e.g. what you were trying to achieve) * Simplest possible steps to reproduce @@ -27,11 +27,11 @@ Please ensure to specify the following: ### Example ``` -Arduino IDE version: 1.8.16 -`ArduinoCore-mbed` mbed_portenta core v2.5.2 +Arduino IDE version: 1.8.19 +`ArduinoCore-mbed` mbed_portenta core v2.6.1 Portenta_H7 Rev2 ABX00042 OS: Ubuntu 20.04 LTS -Linux xy-Inspiron-3593 5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux +Linux xy-Inspiron-3593 5.4.0-92-generic #103-Ubuntu SMP Fri Nov 26 16:13:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Context: I encountered a crash while using TimerInterrupt. diff --git a/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h b/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h new file mode 100644 index 0000000..84c18cf --- /dev/null +++ b/Packages_Patches/arduino/hardware/mbed_portenta/2.4.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h @@ -0,0 +1,347 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LWIPOPTS_H +#define LWIPOPTS_H + +// Workaround for Linux timeval +#if defined (TOOLCHAIN_GCC) +#define LWIP_TIMEVAL_PRIVATE 0 +#include +#endif +#include "nsapi_types.h" +#include "mbed_retarget.h" + +// KH fix +#include +///////////////////////// + +// Operating System +#define NO_SYS 0 + +#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED +#error "Either IPv4 or IPv6 must be enabled." +#endif + +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED + +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED + +#define LWIP_PROVIDE_ERRNO 0 + +// On dual stack configuration how long to wait for both or preferred stack +// addresses before completing bring up. +#if LWIP_IPV4 && LWIP_IPV6 +#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE +#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define PREF_ADDR_TIMEOUT 0 +#else +#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define BOTH_ADDR_TIMEOUT 0 +#endif +#else +#define PREF_ADDR_TIMEOUT 0 +#define BOTH_ADDR_TIMEOUT 0 +#endif + + +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT + +#define LINK_TIMEOUT 60 + +#define PREF_IPV4 1 +#define PREF_IPV6 2 + +#if MBED_CONF_LWIP_IP_VER_PREF == 6 +#define IP_VERSION_PREF PREF_IPV6 +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 +#define IP_VERSION_PREF PREF_IPV4 +#else +#error "Either IPv4 or IPv6 must be preferred." +#endif + +#undef LWIP_DEBUG +#if MBED_CONF_LWIP_DEBUG_ENABLED +#define LWIP_DEBUG 1 +#endif + +#if NO_SYS == 0 +#include "cmsis_os2.h" + +#define SYS_LIGHTWEIGHT_PROT 1 + +#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED + +#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT + +// Thread stacks use 8-byte alignment +#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) + +#ifdef LWIP_DEBUG +// For LWIP debug, double the stack +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) +#elif MBED_DEBUG +// When debug is enabled on the build increase stack 25 percent +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) +#else +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) +#endif + +// Thread priority (osPriorityNormal by default) +#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) + +#ifdef LWIP_DEBUG +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) +#else +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) +#endif + +#define MEMP_NUM_SYS_TIMEOUT 16 + +#define sys_msleep(ms) sys_msleep(ms) + +#endif + +// 32-bit alignment +#define MEM_ALIGNMENT 4 + +#define LWIP_RAM_HEAP_POINTER lwip_ram_heap + +// Number of simultaneously queued TCP segments. +#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG + +// TCP Maximum segment size. +#define TCP_MSS MBED_CONF_LWIP_TCP_MSS + +// TCP sender buffer space (bytes). +#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF + +// TCP sender buffer space (bytes). +#define TCP_WND MBED_CONF_LWIP_TCP_WND + +#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX + +#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX + +// Number of pool pbufs. +// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) +#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE + +#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#undef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) +#else +#ifndef PBUF_POOL_BUFSIZE +#if LWIP_IPV6 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#elif LWIP_IPV4 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#endif +#endif +#endif + +#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE + +// One tcp_pcb_listen is needed for each TCP server. +// Each requires 72 bytes of RAM. +#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX + +// One is tcp_pcb needed for each TCPSocket. +// Each requires 196 bytes of RAM. +#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX + +// One udp_pcb is needed for each UDPSocket. +// Each requires 84 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX + +// Number of non-pool pbufs. +// Each requires 92 bytes of RAM. +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF + +// Each netbuf requires 64 bytes of RAM. +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF + +// One netconn is needed for each UDPSocket or TCPSocket. +// Each requires 236 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX + +#if MBED_CONF_LWIP_TCP_ENABLED +#define LWIP_TCP 1 +#define TCP_OVERSIZE 0 +#define LWIP_TCP_KEEPALIVE 1 + +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT + +#else +#define LWIP_TCP 0 +#endif + +#define LWIP_DNS 1 +// Only DNS address storage is enabled +#define LWIP_FULL_DNS 0 +#define LWIP_SOCKET 0 + +#define SO_REUSE 1 + +// Support Multicast +#include "stdlib.h" +#define LWIP_IGMP LWIP_IPV4 +#define LWIP_RAND() lwip_get_random() + +#define LWIP_COMPAT_SOCKETS 0 +#define LWIP_POSIX_SOCKETS_IO_NAMES 0 + +#define LWIP_BROADCAST_PING 1 + +// Fragmentation on, as per IPv4 default +#define LWIP_IPV6_FRAG LWIP_IPV6 + +// Queuing, default is "disabled", as per IPv4 default (so actually queues 1) +#define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING + +// Debug Options +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF + +#define ETHARP_DEBUG LWIP_DBG_OFF +#define UDP_LPC_EMAC LWIP_DBG_OFF + +#ifdef LWIP_DEBUG +#define MEMP_OVERFLOW_CHECK 1 +#define MEMP_SANITY_CHECK 1 +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#else +#define LWIP_NOASSERT 1 +#define LWIP_STATS 0 +#endif + +#define TRACE_TO_ASCII_HEX_DUMP 0 + +#define LWIP_PLATFORM_BYTESWAP 1 + +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 + +// Interface type configuration + +#if MBED_CONF_LWIP_ETHERNET_ENABLED +#define LWIP_ARP 1 +#define LWIP_ETHERNET 1 +#define LWIP_DHCP LWIP_IPV4 +#else +#define LWIP_ARP 0 +#define LWIP_ETHERNET 0 +#endif // MBED_CONF_LWIP_ETHERNET_ENABLED + +#if MBED_CONF_LWIP_L3IP_ENABLED +#define LWIP_L3IP 1 +#else +#define LWIP_L3IP 0 +#endif + +//Maximum size of network interface name +#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE +// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED +// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. + +// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration +#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED + +#define PPP_SUPPORT 1 + +#if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED +#error LWIP: IPv4 PPP enabled but not IPv4 +#endif +#undef LWIP +#define PPP_IPV4_SUPPORT 1 +#endif + +#if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED +#error LWIP: IPv6 PPP enabled but not IPv6 +#endif +#undef LWIP +#define PPP_IPV6_SUPPORT 1 +// Later to be dynamic for use for multiple interfaces +#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 +#endif + +#endif + +#define LWIP_NETBUF_RECVINFO MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED + +// Make sure we default these to off, so +// LWIP doesn't default to on +#ifndef LWIP_ARP +#define LWIP_ARP 0 +#endif + +// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 +#define LWIP_CHECKSUM_ON_COPY 0 + +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 + +#define DNS_TABLE_SIZE 2 +#define DNS_MAX_NAME_LENGTH 128 + +#include "lwip_random.h" +#include "lwip_tcp_isn.h" +#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn +#ifdef MBEDTLS_MD5_C +#define LWIP_USE_EXTERNAL_MBEDTLS 1 +#else +#define LWIP_USE_EXTERNAL_MBEDTLS 0 +#endif + +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS + +#endif /* LWIPOPTS_H_ */ diff --git a/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h b/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h new file mode 100644 index 0000000..84c18cf --- /dev/null +++ b/Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h @@ -0,0 +1,347 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LWIPOPTS_H +#define LWIPOPTS_H + +// Workaround for Linux timeval +#if defined (TOOLCHAIN_GCC) +#define LWIP_TIMEVAL_PRIVATE 0 +#include +#endif +#include "nsapi_types.h" +#include "mbed_retarget.h" + +// KH fix +#include +///////////////////////// + +// Operating System +#define NO_SYS 0 + +#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED +#error "Either IPv4 or IPv6 must be enabled." +#endif + +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED + +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED + +#define LWIP_PROVIDE_ERRNO 0 + +// On dual stack configuration how long to wait for both or preferred stack +// addresses before completing bring up. +#if LWIP_IPV4 && LWIP_IPV6 +#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE +#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define PREF_ADDR_TIMEOUT 0 +#else +#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define BOTH_ADDR_TIMEOUT 0 +#endif +#else +#define PREF_ADDR_TIMEOUT 0 +#define BOTH_ADDR_TIMEOUT 0 +#endif + + +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT + +#define LINK_TIMEOUT 60 + +#define PREF_IPV4 1 +#define PREF_IPV6 2 + +#if MBED_CONF_LWIP_IP_VER_PREF == 6 +#define IP_VERSION_PREF PREF_IPV6 +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 +#define IP_VERSION_PREF PREF_IPV4 +#else +#error "Either IPv4 or IPv6 must be preferred." +#endif + +#undef LWIP_DEBUG +#if MBED_CONF_LWIP_DEBUG_ENABLED +#define LWIP_DEBUG 1 +#endif + +#if NO_SYS == 0 +#include "cmsis_os2.h" + +#define SYS_LIGHTWEIGHT_PROT 1 + +#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED + +#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT + +// Thread stacks use 8-byte alignment +#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) + +#ifdef LWIP_DEBUG +// For LWIP debug, double the stack +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) +#elif MBED_DEBUG +// When debug is enabled on the build increase stack 25 percent +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) +#else +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) +#endif + +// Thread priority (osPriorityNormal by default) +#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) + +#ifdef LWIP_DEBUG +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) +#else +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) +#endif + +#define MEMP_NUM_SYS_TIMEOUT 16 + +#define sys_msleep(ms) sys_msleep(ms) + +#endif + +// 32-bit alignment +#define MEM_ALIGNMENT 4 + +#define LWIP_RAM_HEAP_POINTER lwip_ram_heap + +// Number of simultaneously queued TCP segments. +#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG + +// TCP Maximum segment size. +#define TCP_MSS MBED_CONF_LWIP_TCP_MSS + +// TCP sender buffer space (bytes). +#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF + +// TCP sender buffer space (bytes). +#define TCP_WND MBED_CONF_LWIP_TCP_WND + +#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX + +#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX + +// Number of pool pbufs. +// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) +#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE + +#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#undef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) +#else +#ifndef PBUF_POOL_BUFSIZE +#if LWIP_IPV6 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#elif LWIP_IPV4 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#endif +#endif +#endif + +#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE + +// One tcp_pcb_listen is needed for each TCP server. +// Each requires 72 bytes of RAM. +#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX + +// One is tcp_pcb needed for each TCPSocket. +// Each requires 196 bytes of RAM. +#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX + +// One udp_pcb is needed for each UDPSocket. +// Each requires 84 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX + +// Number of non-pool pbufs. +// Each requires 92 bytes of RAM. +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF + +// Each netbuf requires 64 bytes of RAM. +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF + +// One netconn is needed for each UDPSocket or TCPSocket. +// Each requires 236 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX + +#if MBED_CONF_LWIP_TCP_ENABLED +#define LWIP_TCP 1 +#define TCP_OVERSIZE 0 +#define LWIP_TCP_KEEPALIVE 1 + +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT + +#else +#define LWIP_TCP 0 +#endif + +#define LWIP_DNS 1 +// Only DNS address storage is enabled +#define LWIP_FULL_DNS 0 +#define LWIP_SOCKET 0 + +#define SO_REUSE 1 + +// Support Multicast +#include "stdlib.h" +#define LWIP_IGMP LWIP_IPV4 +#define LWIP_RAND() lwip_get_random() + +#define LWIP_COMPAT_SOCKETS 0 +#define LWIP_POSIX_SOCKETS_IO_NAMES 0 + +#define LWIP_BROADCAST_PING 1 + +// Fragmentation on, as per IPv4 default +#define LWIP_IPV6_FRAG LWIP_IPV6 + +// Queuing, default is "disabled", as per IPv4 default (so actually queues 1) +#define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING + +// Debug Options +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF + +#define ETHARP_DEBUG LWIP_DBG_OFF +#define UDP_LPC_EMAC LWIP_DBG_OFF + +#ifdef LWIP_DEBUG +#define MEMP_OVERFLOW_CHECK 1 +#define MEMP_SANITY_CHECK 1 +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#else +#define LWIP_NOASSERT 1 +#define LWIP_STATS 0 +#endif + +#define TRACE_TO_ASCII_HEX_DUMP 0 + +#define LWIP_PLATFORM_BYTESWAP 1 + +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 + +// Interface type configuration + +#if MBED_CONF_LWIP_ETHERNET_ENABLED +#define LWIP_ARP 1 +#define LWIP_ETHERNET 1 +#define LWIP_DHCP LWIP_IPV4 +#else +#define LWIP_ARP 0 +#define LWIP_ETHERNET 0 +#endif // MBED_CONF_LWIP_ETHERNET_ENABLED + +#if MBED_CONF_LWIP_L3IP_ENABLED +#define LWIP_L3IP 1 +#else +#define LWIP_L3IP 0 +#endif + +//Maximum size of network interface name +#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE +// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED +// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. + +// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration +#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED + +#define PPP_SUPPORT 1 + +#if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED +#error LWIP: IPv4 PPP enabled but not IPv4 +#endif +#undef LWIP +#define PPP_IPV4_SUPPORT 1 +#endif + +#if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED +#error LWIP: IPv6 PPP enabled but not IPv6 +#endif +#undef LWIP +#define PPP_IPV6_SUPPORT 1 +// Later to be dynamic for use for multiple interfaces +#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 +#endif + +#endif + +#define LWIP_NETBUF_RECVINFO MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED + +// Make sure we default these to off, so +// LWIP doesn't default to on +#ifndef LWIP_ARP +#define LWIP_ARP 0 +#endif + +// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 +#define LWIP_CHECKSUM_ON_COPY 0 + +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 + +#define DNS_TABLE_SIZE 2 +#define DNS_MAX_NAME_LENGTH 128 + +#include "lwip_random.h" +#include "lwip_tcp_isn.h" +#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn +#ifdef MBEDTLS_MD5_C +#define LWIP_USE_EXTERNAL_MBEDTLS 1 +#else +#define LWIP_USE_EXTERNAL_MBEDTLS 0 +#endif + +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS + +#endif /* LWIPOPTS_H_ */ diff --git a/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h b/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h new file mode 100644 index 0000000..84c18cf --- /dev/null +++ b/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h @@ -0,0 +1,347 @@ +/* Copyright (C) 2012 mbed.org, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LWIPOPTS_H +#define LWIPOPTS_H + +// Workaround for Linux timeval +#if defined (TOOLCHAIN_GCC) +#define LWIP_TIMEVAL_PRIVATE 0 +#include +#endif +#include "nsapi_types.h" +#include "mbed_retarget.h" + +// KH fix +#include +///////////////////////// + +// Operating System +#define NO_SYS 0 + +#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED +#error "Either IPv4 or IPv6 must be enabled." +#endif + +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED + +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED + +#define LWIP_PROVIDE_ERRNO 0 + +// On dual stack configuration how long to wait for both or preferred stack +// addresses before completing bring up. +#if LWIP_IPV4 && LWIP_IPV6 +#if MBED_CONF_LWIP_ADDR_TIMEOUT_MODE +#define BOTH_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define PREF_ADDR_TIMEOUT 0 +#else +#define PREF_ADDR_TIMEOUT MBED_CONF_LWIP_ADDR_TIMEOUT +#define BOTH_ADDR_TIMEOUT 0 +#endif +#else +#define PREF_ADDR_TIMEOUT 0 +#define BOTH_ADDR_TIMEOUT 0 +#endif + + +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT + +#define LINK_TIMEOUT 60 + +#define PREF_IPV4 1 +#define PREF_IPV6 2 + +#if MBED_CONF_LWIP_IP_VER_PREF == 6 +#define IP_VERSION_PREF PREF_IPV6 +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 +#define IP_VERSION_PREF PREF_IPV4 +#else +#error "Either IPv4 or IPv6 must be preferred." +#endif + +#undef LWIP_DEBUG +#if MBED_CONF_LWIP_DEBUG_ENABLED +#define LWIP_DEBUG 1 +#endif + +#if NO_SYS == 0 +#include "cmsis_os2.h" + +#define SYS_LIGHTWEIGHT_PROT 1 + +#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED + +#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT + +// Thread stacks use 8-byte alignment +#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) + +#ifdef LWIP_DEBUG +// For LWIP debug, double the stack +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) +#elif MBED_DEBUG +// When debug is enabled on the build increase stack 25 percent +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8) +#else +#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8) +#endif + +// Thread priority (osPriorityNormal by default) +#define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) + +#ifdef LWIP_DEBUG +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) +#else +#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8) +#endif + +#define MEMP_NUM_SYS_TIMEOUT 16 + +#define sys_msleep(ms) sys_msleep(ms) + +#endif + +// 32-bit alignment +#define MEM_ALIGNMENT 4 + +#define LWIP_RAM_HEAP_POINTER lwip_ram_heap + +// Number of simultaneously queued TCP segments. +#define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG + +// TCP Maximum segment size. +#define TCP_MSS MBED_CONF_LWIP_TCP_MSS + +// TCP sender buffer space (bytes). +#define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF + +// TCP sender buffer space (bytes). +#define TCP_WND MBED_CONF_LWIP_TCP_WND + +#define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX + +#define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX + +// Number of pool pbufs. +// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) +#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE + +#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#undef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(MBED_CONF_LWIP_PBUF_POOL_BUFSIZE) +#else +#ifndef PBUF_POOL_BUFSIZE +#if LWIP_IPV6 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#elif LWIP_IPV4 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+20+20+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#endif +#endif +#endif + +#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE + +// One tcp_pcb_listen is needed for each TCP server. +// Each requires 72 bytes of RAM. +#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX + +// One is tcp_pcb needed for each TCPSocket. +// Each requires 196 bytes of RAM. +#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX + +// One udp_pcb is needed for each UDPSocket. +// Each requires 84 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX + +// Number of non-pool pbufs. +// Each requires 92 bytes of RAM. +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF + +// Each netbuf requires 64 bytes of RAM. +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF + +// One netconn is needed for each UDPSocket or TCPSocket. +// Each requires 236 bytes of RAM (total rounded to multiple of 512). +#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX + +#if MBED_CONF_LWIP_TCP_ENABLED +#define LWIP_TCP 1 +#define TCP_OVERSIZE 0 +#define LWIP_TCP_KEEPALIVE 1 + +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT + +#else +#define LWIP_TCP 0 +#endif + +#define LWIP_DNS 1 +// Only DNS address storage is enabled +#define LWIP_FULL_DNS 0 +#define LWIP_SOCKET 0 + +#define SO_REUSE 1 + +// Support Multicast +#include "stdlib.h" +#define LWIP_IGMP LWIP_IPV4 +#define LWIP_RAND() lwip_get_random() + +#define LWIP_COMPAT_SOCKETS 0 +#define LWIP_POSIX_SOCKETS_IO_NAMES 0 + +#define LWIP_BROADCAST_PING 1 + +// Fragmentation on, as per IPv4 default +#define LWIP_IPV6_FRAG LWIP_IPV6 + +// Queuing, default is "disabled", as per IPv4 default (so actually queues 1) +#define LWIP_ND6_QUEUEING MBED_CONF_ND6_QUEUEING + +// Debug Options +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF + +#define ETHARP_DEBUG LWIP_DBG_OFF +#define UDP_LPC_EMAC LWIP_DBG_OFF + +#ifdef LWIP_DEBUG +#define MEMP_OVERFLOW_CHECK 1 +#define MEMP_SANITY_CHECK 1 +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#else +#define LWIP_NOASSERT 1 +#define LWIP_STATS 0 +#endif + +#define TRACE_TO_ASCII_HEX_DUMP 0 + +#define LWIP_PLATFORM_BYTESWAP 1 + +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 + +// Interface type configuration + +#if MBED_CONF_LWIP_ETHERNET_ENABLED +#define LWIP_ARP 1 +#define LWIP_ETHERNET 1 +#define LWIP_DHCP LWIP_IPV4 +#else +#define LWIP_ARP 0 +#define LWIP_ETHERNET 0 +#endif // MBED_CONF_LWIP_ETHERNET_ENABLED + +#if MBED_CONF_LWIP_L3IP_ENABLED +#define LWIP_L3IP 1 +#else +#define LWIP_L3IP 0 +#endif + +//Maximum size of network interface name +#define INTERFACE_NAME_MAX_SIZE NSAPI_INTERFACE_NAME_MAX_SIZE +// Note generic macro name used rather than MBED_CONF_LWIP_PPP_ENABLED +// to allow users like PPPCellularInterface to detect that nsapi_ppp.h is available. + +// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration +#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED + +#define PPP_SUPPORT 1 + +#if MBED_CONF_PPP_IPV4_ENABLED || MBED_CONF_LWIP_IPV4_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV4_ENABLED +#error LWIP: IPv4 PPP enabled but not IPv4 +#endif +#undef LWIP +#define PPP_IPV4_SUPPORT 1 +#endif + +#if MBED_CONF_PPP_IPV6_ENABLED || MBED_CONF_LWIP_IPV6_ENABLED +#define LWIP 0x11991199 +#if (MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && !MBED_CONF_LWIP_IPV6_ENABLED +#error LWIP: IPv6 PPP enabled but not IPv6 +#endif +#undef LWIP +#define PPP_IPV6_SUPPORT 1 +// Later to be dynamic for use for multiple interfaces +#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 +#endif + +#endif + +#define LWIP_NETBUF_RECVINFO MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED + +// Make sure we default these to off, so +// LWIP doesn't default to on +#ifndef LWIP_ARP +#define LWIP_ARP 0 +#endif + +// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914 +#define LWIP_CHECKSUM_ON_COPY 0 + +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 + +#define DNS_TABLE_SIZE 2 +#define DNS_MAX_NAME_LENGTH 128 + +#include "lwip_random.h" +#include "lwip_tcp_isn.h" +#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn +#ifdef MBEDTLS_MD5_C +#define LWIP_USE_EXTERNAL_MBEDTLS 1 +#else +#define LWIP_USE_EXTERNAL_MBEDTLS 0 +#endif + +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS + +#endif /* LWIPOPTS_H_ */ diff --git a/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.cpp b/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.cpp new file mode 100644 index 0000000..2a1b0fc --- /dev/null +++ b/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.cpp @@ -0,0 +1,217 @@ +#include "MbedUdp.h" + +arduino::MbedUDP::MbedUDP() { + _packet_buffer = new uint8_t[WIFI_UDP_BUFFER_SIZE]; + _current_packet = NULL; + _current_packet_size = 0; + // if this allocation fails then ::begin will fail +} + +arduino::MbedUDP::~MbedUDP() { + delete[] _packet_buffer; +} + +uint8_t arduino::MbedUDP::begin(uint16_t port) { + // success = 1, fail = 0 + + nsapi_error_t rt = _socket.open(getNetwork()); + if (rt != NSAPI_ERROR_OK) { + return 0; + } + + if (_socket.bind(port) < 0) { + return 0; //Failed to bind UDP Socket to port + } + + if (!_packet_buffer) { + return 0; + } + + _socket.set_blocking(false); + _socket.set_timeout(0); + + return 1; +} + +uint8_t arduino::MbedUDP::beginMulticast(IPAddress ip, uint16_t port) { + // success = 1, fail = 0 + if (begin(port) != 1) { + return 0; + } + + SocketAddress socketAddress = SocketHelpers::socketAddressFromIpAddress(ip, port); + + if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK) { + printf("Error joining the multicast group\n"); + return 0; + } + + return 1; +} + +void arduino::MbedUDP::stop() { + _socket.close(); +} + +int arduino::MbedUDP::beginPacket(IPAddress ip, uint16_t port) { + _host = SocketHelpers::socketAddressFromIpAddress(ip, port); + //If IP is null and port is 0 the initialization failed + txBuffer.clear(); + return (_host.get_ip_address() == nullptr && _host.get_port() == 0) ? 0 : 1; +} + +int arduino::MbedUDP::beginPacket(const char *host, uint16_t port) { + _host = SocketAddress(host, port); + txBuffer.clear(); + getNetwork()->gethostbyname(host, &_host); + //If IP is null and port is 0 the initialization failed + return (_host.get_ip_address() == nullptr && _host.get_port() == 0) ? 0 : 1; +} + +int arduino::MbedUDP::endPacket() { + _socket.set_blocking(true); + _socket.set_timeout(1000); + + size_t size = txBuffer.available(); + uint8_t buffer[size]; + for (int i = 0; i < size; i++) { + buffer[i] = txBuffer.read_char(); + } + + nsapi_size_or_error_t ret = _socket.sendto(_host, buffer, size); + _socket.set_blocking(false); + _socket.set_timeout(0); + if (ret < 0) { + return 0; + } + return size; +} + +// Write a single byte into the packet +size_t arduino::MbedUDP::write(uint8_t byte) { + return write(&byte, 1); +} + +// Write size bytes from buffer into the packet +size_t arduino::MbedUDP::write(const uint8_t *buffer, size_t size) { + for (int i = 0; i _packet_buffer + _current_packet_size) { + // try reading the next packet... + if (parsePacket() > 0) { + // if so, read first byte of next packet; + return read(); + } else { + // no new data... not sure what to return here now + return -1; + } + } + + return _current_packet[0]; +} + +// Read up to len bytes from the current packet and place them into buffer +// Returns the number of bytes read, or 0 if none are available +int arduino::MbedUDP::read(unsigned char *buffer, size_t len) { + // Q: does Arduino read() function handle fragmentation? I won't for now... + if (_current_packet == NULL) { + if (parsePacket() == 0) return 0; + } + + // how much data do we have in the current packet? + int offset = _current_packet - _packet_buffer; + if (offset < 0) { + return 0; + } + + int max_bytes = _current_packet_size - offset; + if (max_bytes < 0) { + return 0; + } + + // at the end of the packet? + if (max_bytes == 0) { + // try read next packet... + if (parsePacket() > 0) { + return read(buffer, len); + } else { + return 0; + } + } + + if (len > (size_t)max_bytes) len = max_bytes; + + // copy to target buffer + memcpy(buffer, _current_packet, len); + + _current_packet += len; + + return len; +} + +IPAddress arduino::MbedUDP::remoteIP() { + nsapi_addr_t address = _remoteHost.get_addr(); + return IPAddress(address.bytes[0], address.bytes[1], address.bytes[2], address.bytes[3]); +} + +uint16_t arduino::MbedUDP::remotePort() { + return _remoteHost.get_port(); +} + +void arduino::MbedUDP::flush() { + // TODO: a real check to ensure transmission has been completed +} + +int arduino::MbedUDP::peek() { + if (_current_packet_size < 1) { + return -1; + } + + return _current_packet[0]; +} diff --git a/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.h b/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.h new file mode 100644 index 0000000..7f81ede --- /dev/null +++ b/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/libraries/SocketWrapper/src/MbedUdp.h @@ -0,0 +1,105 @@ +/* + MbedUdp.h - UDP implementation using mbed Sockets + Copyright (c) 2021 Arduino SA. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef MBEDUDP_H +#define MBEDUDP_H + +#include "Arduino.h" +#include "SocketHelpers.h" +#include "api/Udp.h" + +#include "netsocket/SocketAddress.h" +#include "netsocket/UDPSocket.h" + +#ifndef WIFI_UDP_BUFFER_SIZE +#define WIFI_UDP_BUFFER_SIZE 508 +#endif + +namespace arduino { + +class MbedUDP : public UDP { +private: + UDPSocket _socket; // Mbed OS socket + SocketAddress _host; // Host to be used to send data + SocketAddress _remoteHost; // Remote host that sent incoming packets + + uint8_t* _packet_buffer; // Raw packet buffer (contains data we got from the UDPSocket) + + // The Arduino APIs allow you to iterate through this buffer, so we need to be able to iterate over the current packet + // these two variables are used to cache the state of the current packet + uint8_t* _current_packet; + size_t _current_packet_size; + + RingBufferN txBuffer; + +protected: + virtual NetworkInterface* getNetwork() = 0; + +public: + MbedUDP(); // Constructor + ~MbedUDP(); + virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual uint8_t beginMulticast(IPAddress, uint16_t); // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop(); // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port); + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char* host, uint16_t port); + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket(); + // Write a single byte into the packet + virtual size_t write(uint8_t); + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t* buffer, size_t size); + + using Print::write; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket(); + // Number of bytes remaining in the current packet + virtual int available(); + // Read a single byte from the current packet + virtual int read(); + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len); + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) { + return read((unsigned char*)buffer, len); + }; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek(); + virtual void flush(); // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP(); + // // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort(); + + friend class MbedSocketClass; +}; + +} + +#endif diff --git a/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh b/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh new file mode 100644 index 0000000..7fe71d6 --- /dev/null +++ b/Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +portenta_h7_rules () { + echo "" + echo "# Portenta H7 bootloader mode UDEV rules" + echo "" +cat < /etc/udev/rules.d/49-portenta_h7.rules + +# reload udev rules +echo "Reload rules..." +udevadm trigger +udevadm control --reload-rules diff --git a/README.md b/README.md index 015eb4a..1c2376e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ ## Table of Contents * [Important Notes for Portenta_H7](#important-notes-for-portenta_h7) + * [LittleFS](#littlefs) + * [WiFi Status bug](#WiFi-status-bug) * [Why do we need this WiFiManager_Portenta_H7_Lite library](#why-do-we-need-this-WiFiManager_Portenta_H7_Lite-library) * [Features](#features) * [Currently supported Boards](#currently-supported-boards) @@ -43,6 +45,9 @@ * [12.1 Enable auto-scan of WiFi networks for selection in Configuration Portal](#121-enable-auto-scan-of-wifi-networks-for-selection-in-configuration-portal) * [12.2 Disable manually input SSIDs](#122-disable-manually-input-ssids) * [12.3 Select maximum number of SSIDs in the list](#123-select-maximum-number-of-ssids-in-the-list) + * [13. To avoid blocking in loop when WiFi is lost](#13-To-avoid-blocking-in-loop-when-wifi-is-lost) + * [13.1 Max times to try WiFi per loop](#131-max-times-to-try-wifi-per-loop) + * [13.2 Interval between reconnection WiFi if lost](#132-interval-between-reconnection-wifi-if-lost) * [Examples](#examples) * [ 1. Portenta_H7_WiFi](examples/Portenta_H7_WiFi) * [ 2. Portenta_H7_WiFi_MQTT](examples/Portenta_H7_WiFi_MQTT) @@ -83,12 +88,30 @@ ### Important Notes for Portenta_H7 +#### LittleFS + The LittleFS of the new **Portenta_H7** board currently tested OK with only **maximum 8 files**. The files, from 9 and up, somehow strangely can't be written and / or read. This is possibly a bug in the [`ArduinoCore-mbed mbed_portenta core`](https://github.com/arduino/ArduinoCore-mbed). The same behaviour is observed from core v2.0.0 up to v2.5.2. If LittleFS size is reduced to 1024KB, test is OK with only **maximum 4 files**. -Beware and keep cheking for updates. +Beware and keep checking for updates. + +#### WiFi Status bug + +The current `mbed_portenta core v2.6.1` has bug that once WiFi is connected, `WiFi.status()` always reports `WL_CONNECTED` even if WiFi is lost. + +The current workaround for this `WiFi.status()` bug is to use it with `WiFi.RSSI()`, such as + +``` +bool WiFiConnected() +{ + return ( (WiFi.status() == WL_CONNECTED) && (WiFi.RSSI() != 0) ); +} +``` + +This not-100%-perfect workaround is working only whenever the **WiFi is totally powered down (RSSI == 0)**, but still better than nothing. +Will post an issue in the core soon. --- --- @@ -147,13 +170,13 @@ This [**WiFiManager_Portenta_H7_Lite** library](https://github.com/khoih-prog/Wi ## Prerequisites -1. [`Arduino IDE 1.8.16+` for Arduino](https://www.arduino.cc/en/Main/Software) -2. [`ArduinoCore-mbed mbed_portenta core 2.5.2+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino **Portenta_H7** boards, such as **Portenta_H7 Rev2 ABX00042, etc.**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) +1. [`Arduino IDE 1.8.19+` for Arduino](https://www.arduino.cc/en/Main/Software) +2. [`ArduinoCore-mbed mbed_portenta core 2.6.1+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino **Portenta_H7** boards, such as **Portenta_H7 Rev2 ABX00042, etc.**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) 3. [`Functional-VLPP library v1.0.2+`](https://github.com/khoih-prog/functional-vlpp) to use server's lambda function. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/Functional-Vlpp.svg?)](https://www.ardu-badge.com/Functional-Vlpp) -4. [`WiFiWebServer library v1.4.2+`](https://github.com/khoih-prog/WiFiWebServer). To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/WiFiWebServer.svg?)](https://www.ardu-badge.com/WiFiWebServer) -5. [`LittleFS_Portenta_H7 v1.0.2+`](https://github.com/khoih-prog/LittleFS_Portenta_H7). To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/LittleFS_Portenta_H7.svg?)](https://www.ardu-badge.com/LittleFS_Portenta_H7) +4. [`WiFiWebServer library v1.5.3+`](https://github.com/khoih-prog/WiFiWebServer). To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/WiFiWebServer.svg?)](https://www.ardu-badge.com/WiFiWebServer) +5. [`LittleFS_Portenta_H7 v1.1.0+`](https://github.com/khoih-prog/LittleFS_Portenta_H7). To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/LittleFS_Portenta_H7.svg?)](https://www.ardu-badge.com/LittleFS_Portenta_H7) 6. [`DoubleResetDetector_Generic v1.7.3+`](https://github.com/khoih-prog/DoubleResetDetector_Generic). To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/DoubleResetDetector_Generic.svg?)](https://www.ardu-badge.com/DoubleResetDetector_Generic) --- @@ -187,12 +210,12 @@ You can also use this link [![arduino-library-badge](https://www.ardu-badge.com/ #### 1. For Portenta_H7 boards using Arduino IDE in Linux - **To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.)**, you have to copy the file [portenta_post_install.sh](Packages_Patches/arduino/hardware/mbed_portenta/2.5.2/portenta_post_install.sh) into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/2.5.2/portenta_post_install.sh). + **To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.)**, you have to copy the file [portenta_post_install.sh](Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh) into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh). Then run the following command using `sudo` ``` -$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/2.5.2 +$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/2.6.1 $ chmod 755 portenta_post_install.sh $ sudo ./portenta_post_install.sh ``` @@ -205,9 +228,9 @@ This will create the file `/etc/udev/rules.d/49-portenta_h7.rules` as follows: SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666" ``` -Supposing the ArduinoCore-mbed core version is 2.5.2. Now only one file must be copied into the directory: +Supposing the ArduinoCore-mbed core version is 2.6.1. Now only one file must be copied into the directory: -- `~/.arduino15/packages/arduino/hardware/mbed_portenta/2.5.2/portenta_post_install.sh` +- `~/.arduino15/packages/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh` Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz @@ -445,6 +468,39 @@ The maximum number of SSIDs in the list is selectable from 2 to 15 (for ESP8266/ #define MAX_SSID_IN_LIST 8 ``` +#### 13. To avoid blocking in loop when WiFi is lost + + +#### 13.1 Max times to try WiFi per loop + +To define max times to try WiFi per loop() iteration. To avoid blocking issue in loop() + +Default is 1 if not defined, and minimum is forced to be 1. + +To use, uncomment in `defines.h`. + +Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18#issue-1094004380) + +``` +#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 2 +``` + +#### 13.2 Interval between reconnection WiFi if lost + +Default is no interval between reconnection WiFi times if lost WiFi. Max permitted interval will be 10mins. + +Uncomment to use. Be careful, WiFi reconnection will be delayed if using this method. + +Only use whenever urgent tasks in loop() can't be delayed. But if so, it's better you have to rewrite your code, e.g. using higher priority tasks. + +Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18#issuecomment-1006197561) + +``` +#define WIFI_RECON_INTERVAL 30000 // 30s +``` + + + --- --- @@ -916,9 +972,21 @@ void loop() // Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank" // Default is false (if not defined) => must input 2 sets of SSID/PWD -#define REQUIRE_ONE_SET_SSID_PW false +#define REQUIRE_ONE_SET_SSID_PW true //false + +// Max times to try WiFi per loop() iteration. To avoid blocking issue in loop() +// Default 1 if not defined, and minimum 1. +//#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 2 -#define USE_DYNAMIC_PARAMETERS true //false +// Default no interval between recon WiFi if lost +// Max permitted interval will be 10mins +// Uncomment to use. Be careful, WiFi reconnect will be delayed if using this method +// Only use whenever urgent tasks in loop() can't be delayed. But if so, it's better you have to rewrite your code, e.g. using higher priority tasks. +#define WIFI_RECON_INTERVAL 30000 + +///////////////////////////////////////////// + +#define USE_DYNAMIC_PARAMETERS true ///////////////////////////////////////////// @@ -1113,7 +1181,7 @@ This is the terminal output when running [**Portenta_H7_WiFi**](examples/Portent ``` Start Portenta_H7_WiFi on PORTENTA_H7_M7 with Portenta_H7 WiFi -WiFiManager_Portenta_H7_Lite v1.4.1 +WiFiManager_Portenta_H7_Lite v1.5.0 [WG] Hostname=Portenta-Controller Flash Size: (KB) = 2048.00 FlashIAP Start Address: = 0x80A0000 @@ -1158,7 +1226,7 @@ FFFFFFFFF FFFFF ``` Start Portenta_H7_WiFi on PORTENTA_H7_M7 with Portenta_H7 WiFi -WiFiManager_Portenta_H7_Lite v1.4.1 +WiFiManager_Portenta_H7_Lite v1.5.0 [WG] Hostname=Portenta-Controller Flash Size: (KB) = 2048.00 FlashIAP Start Address: = 0x80A0000 @@ -1222,7 +1290,7 @@ This is the terminal output when running [**Portenta_H7_WiFi_MQTT**](examples/Po ``` Start Portenta_H7_WiFi_MQTT on PORTENTA_H7_M7 with Portenta_H7 WiFi -WiFiManager_Portenta_H7_Lite v1.4.1 +WiFiManager_Portenta_H7_Lite v1.5.0 [WG] Hostname=Portenta-MQTT Flash Size: (KB) = 2048.00 FlashIAP Start Address: = 0x80A0000 @@ -1266,7 +1334,7 @@ NNNN NNNNN NNNNN NNNNN NNNNN NNNNN NNNNN NN ``` Start Portenta_H7_WiFi_MQTT on PORTENTA_H7_M7 with Portenta_H7 WiFi -WiFiManager_Portenta_H7_Lite v1.4.1 +WiFiManager_Portenta_H7_Lite v1.5.0 [WG] Hostname=Portenta-MQTT Flash Size: (KB) = 2048.00 FlashIAP Start Address: = 0x80A0000 @@ -1394,6 +1462,8 @@ Submit issues to: [WiFiManager_Portenta_H7_Lite issues](https://github.com/khoih 20. Enforce WiFi Password minimum length of 8 chars 21. Enable **scan of WiFi networks** for selection in Configuration Portal 22. Add `LibraryPatches` for [**Adafruit_MQTT_Library**](https://github.com/adafruit/Adafruit_MQTT_Library) to fix compiler error for Portenta_H7, RP2040-based and many other boards. +23. Fix the blocking issue in loop() with configurable `WIFI_RECON_INTERVAL` +24. Workaround for core WiFi.status() bug, which does not detect WiFi lost. --- --- @@ -1404,11 +1474,12 @@ Please help contribute to this project and add your name here. 1. Again thanks to [Michael H. "bizprof"](https://github.com/bizprof) for the impressive feature being usd in this library : - `Enable scan of WiFi networks for selection in Configuration Portal`. Check [PR for v1.3.0 - Enable scan of WiFi networks #10](https://github.com/khoih-prog/WiFiManager_NINA_Lite/pull/10) - +2. Thanks to [tomtobback](https://github.com/tomtobback) to report issue [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18) leading to version v1.5.0 to fix the blocking issue in loop() with `WIFI_RECON_INTERVAL`. +
bizprof
⭐️⭐️ Michael H. "bizprof"

tomtobback
tomtobback

diff --git a/changelog.md b/changelog.md index e0989bc..cd2b8c6 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ ## Table of Contents * [Changelog](#changelog) + * [Release v1.5.0](#release-v150) * [Release v1.4.1](#release-v141) * [Initial Release v1.4.0](#initial-release-v140) @@ -20,6 +21,14 @@ ## Changelog +### Release v1.5.0 + +1. Workaround for core WiFi.status() bug, which does not detect WiFi lost. +2. Fix the blocking issue in loop(). Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18) +3. Configurable `WIFI_RECON_INTERVAL`. Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18#issuecomment-1006197561) +4. Update `Packages' Patches` + + ### Release v1.4.1 1. Update `platform.ini` and `library.json` to use original `khoih-prog` instead of `khoih.prog` after PIO fix diff --git a/examples/Portenta_H7_WiFi/Portenta_H7_WiFi.ino b/examples/Portenta_H7_WiFi/Portenta_H7_WiFi.ino index 56eb169..4817d70 100644 --- a/examples/Portenta_H7_WiFi/Portenta_H7_WiFi.ino +++ b/examples/Portenta_H7_WiFi/Portenta_H7_WiFi.ino @@ -23,7 +23,9 @@ void heartBeatPrint() { static int num = 1; - if (WiFi.status() == WL_CONNECTED) + // Must use with WiFi.RSSI() to fix bug in the mbed_portenta core + //if ( (WiFi.status() == WL_CONNECTED) && (WiFi.RSSI() != 0) ) + if ( WiFiManager_Portenta_H7->WiFiConnected() ) Serial.print(F("H")); // H means connected to WiFi else Serial.print(F("F")); // F means not connected to WiFi diff --git a/examples/Portenta_H7_WiFi/defines.h b/examples/Portenta_H7_WiFi/defines.h index 4c15200..29b5be7 100644 --- a/examples/Portenta_H7_WiFi/defines.h +++ b/examples/Portenta_H7_WiFi/defines.h @@ -84,9 +84,21 @@ // Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank" // Default is false (if not defined) => must input 2 sets of SSID/PWD -#define REQUIRE_ONE_SET_SSID_PW false +#define REQUIRE_ONE_SET_SSID_PW true //false -#define USE_DYNAMIC_PARAMETERS true //false +// Max times to try WiFi per loop() iteration. To avoid blocking issue in loop() +// Default 1 if not defined, and minimum 1. +//#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 2 + +// Default no interval between recon WiFi if lost +// Max permitted interval will be 10mins +// Uncomment to use. Be careful, WiFi reconnect will be delayed if using this method +// Only use whenever urgent tasks in loop() can't be delayed. But if so, it's better you have to rewrite your code, e.g. using higher priority tasks. +#define WIFI_RECON_INTERVAL 30000 + +///////////////////////////////////////////// + +#define USE_DYNAMIC_PARAMETERS true ///////////////////////////////////////////// diff --git a/keywords.txt b/keywords.txt index 995a716..02c97e2 100644 --- a/keywords.txt +++ b/keywords.txt @@ -41,6 +41,7 @@ setCustomsHeadElement KEYWORD2 getCustomsHeadElement KEYWORD2 setCORSHeader KEYWORD2 getCORSHeader KEYWORD2 +WiFiConnected KEYWORD2 ####################################### # Constants (LITERAL1) diff --git a/library.json b/library.json index 18be41a..9eee5cc 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "WiFiManager_Portenta_H7_Lite", - "version": "1.4.1", + "version": "1.5.0", "keywords": "wifi, wi-fi, multi-wifi, config-portal, Double-Reset, dynamic-params, LittleFS, LittleFS-Portenta, Credentials, littlefs-mbed, posix, file-system, mbed, mbed-portenta, portenta-h7, portentah7, portenta-h7-m7, portenta-h7-m4, portentah7-m7, portentah7-m4", "description": "Library to configure MultiWiFi/Credentials at runtime for Portenta_H7 boards, using built-in WiFi (Murata) modules/shields. You can also specify DHCP HostName, static AP and STA IP. Use much less memory compared to full-fledge WiFiManager. Config Portal will be auto-adjusted to match the number of dynamic custom parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Credentials are saved in LittleFS. New powerful-yet-simple-to-use feature to enable adding dynamic custom parameters from sketch and input using the same Config Portal. DoubleDetectDetector as well as Virtual Switches feature permits entering Config Portal as requested.", "authors": @@ -27,7 +27,7 @@ { "owner": "khoih-prog", "name": "WiFiWebServer", - "version": "^1.4.1", + "version": "^1.5.3", "platforms": ["*"] }, { @@ -39,7 +39,7 @@ { "owner": "khoih-prog", "name": "LittleFS_Portenta_H7", - "version": "^1.0.2", + "version": "^1.1.0", "platforms": ["mbed_portenta"] }, { @@ -52,5 +52,6 @@ "license": "MIT", "frameworks": "*", "platforms": "mbed_portenta", - "examples": "examples/*/*/*.ino" + "examples": "examples/*/*/*.ino", + "headers": "WiFiManager_Portenta_H7_Lite.h" } diff --git a/library.properties b/library.properties index fe4f9ac..bec2b19 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiManager_Portenta_H7_Lite -version=1.4.1 +version=1.5.0 author=Khoi Hoang maintainer=Khoi Hoang license=MIT @@ -7,5 +7,6 @@ sentence=Light-Weight MultiWiFi/Credentials Manager for Portenta_H7 boards using paragraph=Library to configure MultiWiFi/Credentials at runtime for Portenta_H7 boards, using Portenta WiFi (Murata) modules/shields. You can also specify DHCP HostName, static AP and STA IP. Use much less memory compared to full-fledge WiFiManager. Config Portal will be auto-adjusted to match the number of dynamic custom parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Credentials are saved in LittleFS. New powerful-yet-simple-to-use feature to enable adding dynamic custom parameters from sketch and input using the same Config Portal. DoubleDetectDetector as well as Virtual Switches feature permits entering Config Portal as requested. category=Communication url=https://github.com/khoih-prog/WiFiManager_Portenta_H7_Lite -architectures=* +architectures=mbed,mbed_portenta depends=Functional-VLPP,WiFiWebServer,DoubleResetDetector_Generic,LittleFS_Portenta_H7 +includes=WiFiManager_Portenta_H7_Lite.h diff --git a/platformio/platformio.ini b/platformio/platformio.ini index 27206c1..d823b22 100644 --- a/platformio/platformio.ini +++ b/platformio/platformio.ini @@ -41,15 +41,15 @@ lib_compat_mode = strict lib_deps = ; PlatformIO 4.x - WiFiWebServer@>=1.4.2 - DoubleResetDetector_Generic@>=1.7.3 - LittleFS_Portenta_H7@>=1.0.2 - Functional-Vlpp@>=1.0.2 +; WiFiWebServer@>=1.5.3 +; DoubleResetDetector_Generic@>=1.7.3 +; LittleFS_Portenta_H7@>=1.1.0 +; Functional-Vlpp@>=1.0.2 ; PlatformIO 5.x -; khoih-prog/WiFiWebServer@>=1.4.2 -; khoih-prog/DoubleResetDetector_Generic@>=1.7.3 -; khoih-prog/LittleFS_Portenta_H7@>=1.0.2 -; khoih-prog/Functional-Vlpp@>=1.0.2 + khoih-prog/WiFiWebServer@>=1.5.3 + khoih-prog/DoubleResetDetector_Generic@>=1.7.3 + khoih-prog/LittleFS_Portenta_H7@>=1.1.0 + khoih-prog/Functional-Vlpp@>=1.0.2 build_flags = ; set your debug output (default=Serial) diff --git a/src/FlashIAPLimits.h b/src/FlashIAPLimits.h index 0edcb6a..571e3d6 100644 --- a/src/FlashIAPLimits.h +++ b/src/FlashIAPLimits.h @@ -9,12 +9,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_Portenta_H7_Lite Licensed under MIT license - Version: 1.4.1 + Version: 1.5.0 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.4.0 K Hoang 11/09/2021 Add support to Portenta_H7 using Arduino mbed_portenta core - 1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json` + 1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json` + 1.5.0 K Hoang 08/01/2022 Workaround for core WiFi.status() bug. Fix the blocking issue in loop(). *****************************************************************************************************************************/ #pragma once diff --git a/src/WiFiManager_Portenta_H7_Lite.h b/src/WiFiManager_Portenta_H7_Lite.h index 564dbb2..e0a8fd8 100644 --- a/src/WiFiManager_Portenta_H7_Lite.h +++ b/src/WiFiManager_Portenta_H7_Lite.h @@ -8,12 +8,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_Portenta_H7_Lite Licensed under MIT license - Version: 1.4.1 + Version: 1.5.0 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.4.0 K Hoang 11/09/2021 Add support to Portenta_H7 using Arduino mbed_portenta core - 1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json` + 1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json` + 1.5.0 K Hoang 08/01/2022 Workaround for core WiFi.status() bug. Fix the blocking issue in loop(). ********************************************************************************************************************************/ #ifndef WiFiManager_Portenta_H7_Lite_h @@ -38,7 +39,7 @@ #error This code is intended to run on the MBED ARDUINO_PORTENTA_H7 platform! Please check your Tools->Board setting. #endif -#define WIFI_MANAGER_PORTENTA_H7_LITE_VERSION "WiFiManager_Portenta_H7_Lite v1.4.1" +#define WIFI_MANAGER_PORTENTA_H7_LITE_VERSION "WiFiManager_Portenta_H7_Lite v1.5.0" #include @@ -423,6 +424,17 @@ class WiFiManager_Portenta_H7_Lite #endif #endif + +#if !defined(WIFI_RECON_INTERVAL) + #define WIFI_RECON_INTERVAL 0 // default 0s between reconnecting WiFi +#else + #if (WIFI_RECON_INTERVAL < 0) + #define WIFI_RECON_INTERVAL 0 + #elif (WIFI_RECON_INTERVAL > 600000) + #define WIFI_RECON_INTERVAL 600000 // Max 10min + #endif +#endif + void run() { static int retryTimes = 0; @@ -434,6 +446,10 @@ class WiFiManager_Portenta_H7_Lite static unsigned long checkstatus_timeout = 0; #define WIFI_STATUS_CHECK_INTERVAL 5000L + static uint32_t curMillis; + + curMillis = millis(); + //// New DRD //// // Call the double reset detector loop method every so often, // so that it can recognise when the timeout expires. @@ -442,9 +458,9 @@ class WiFiManager_Portenta_H7_Lite drd->loop(); //// New DRD //// - if ( !configuration_mode && (millis() > checkstatus_timeout) ) + if ( !configuration_mode && (curMillis > checkstatus_timeout) ) { - if (WiFi.status() == WL_CONNECTED) + if ( WiFiConnected() ) { wifi_connected = true; } @@ -462,7 +478,7 @@ class WiFiManager_Portenta_H7_Lite } } - checkstatus_timeout = millis() + WIFI_STATUS_CHECK_INTERVAL; + checkstatus_timeout = curMillis + WIFI_STATUS_CHECK_INTERVAL; } // Lost connection in running. Give chance to reconfig. @@ -503,12 +519,31 @@ class WiFiManager_Portenta_H7_Lite // Not in config mode, try reconnecting before forcing to config mode if ( !wifi_connected ) { + + +#if (WIFI_RECON_INTERVAL > 0) + + static uint32_t lastMillis = 0; + + if ( (lastMillis == 0) || (curMillis - lastMillis) > WIFI_RECON_INTERVAL ) + { + lastMillis = curMillis; + + WG_LOGERROR(F("r:WLost.ReconW")); + + if (connectMultiWiFi(RETRY_TIMES_RECONNECT_WIFI)) + { + WG_LOGERROR(F("r:WOK")); + } + } +#else WG_LOGERROR(F("r:WLost.ReconW")); if (connectMultiWiFi(RETRY_TIMES_RECONNECT_WIFI)) { WG_LOGERROR(F("r:WOK")); } +#endif } } } @@ -518,7 +553,7 @@ class WiFiManager_Portenta_H7_Lite WG_LOGERROR(F("r:gotWBack")); } } - + ////////////////////////////////////////////// void setHostname() @@ -753,6 +788,11 @@ class WiFiManager_Portenta_H7_Lite return _CORS_Header; } #endif + + bool WiFiConnected() + { + return ( (WiFi.status() == WL_CONNECTED) && (WiFi.RSSI() != 0) ); + } ////////////////////////////////////// @@ -1446,12 +1486,23 @@ class WiFiManager_Portenta_H7_Lite ////////////////////////////////////////////// +// Max times to try WiFi per loop() iteration. To avoid blocking issue in loop() +// Default 1 and minimum 1. +#if !defined(MAX_NUM_WIFI_RECON_TRIES_PER_LOOP) + #define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 1 +#else + #if (MAX_NUM_WIFI_RECON_TRIES_PER_LOOP < 1) + #define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 1 + #endif +#endif + + // New connection logic from v1.2.0 bool connectMultiWiFi(int retry_time) { int sleep_time = 250; int index = 0; int new_index = 0; - uint8_t status = WL_IDLE_STATUS; + //uint8_t status = WL_IDLE_STATUS; static int lastConnectedIndex = 255; @@ -1504,16 +1555,20 @@ class WiFiManager_Portenta_H7_Lite uint8_t numIndexTried = 0; - while ( !wifi_connected && (numIndexTried++ < NUM_WIFI_CREDENTIALS) ) + uint8_t numWiFiReconTries = 0; + + while ( !wifi_connected && (numIndexTried++ < NUM_WIFI_CREDENTIALS) && (numWiFiReconTries++ < MAX_NUM_WIFI_RECON_TRIES_PER_LOOP) ) { while ( 0 < retry_time ) { WG_LOGDEBUG1(F("Remaining retry_time="), retry_time); - status = WiFi.begin(WIFI_GENERIC_config.WiFi_Creds[index].wifi_ssid, WIFI_GENERIC_config.WiFi_Creds[index].wifi_pw); + WiFi.begin(WIFI_GENERIC_config.WiFi_Creds[index].wifi_ssid, WIFI_GENERIC_config.WiFi_Creds[index].wifi_pw); + + //delay(3000); // Need restart WiFi at beginning of each cycle - if (status == WL_CONNECTED) + if ( WiFiConnected() ) { wifi_connected = true; lastConnectedIndex = index; @@ -1528,7 +1583,7 @@ class WiFiManager_Portenta_H7_Lite } } - if (status == WL_CONNECTED) + if ( WiFiConnected() ) { break; } @@ -1548,7 +1603,8 @@ class WiFiManager_Portenta_H7_Lite index = new_index; } - //WiFi.end(); + // Must have for Portenta_H7 to reconnect after WiFi lost + WiFi.end(); } } diff --git a/src/WiFiManager_Portenta_H7_Lite_Debug.h b/src/WiFiManager_Portenta_H7_Lite_Debug.h index d784e28..358bd6a 100644 --- a/src/WiFiManager_Portenta_H7_Lite_Debug.h +++ b/src/WiFiManager_Portenta_H7_Lite_Debug.h @@ -9,12 +9,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_Portenta_H7_Lite Licensed under MIT license - Version: 1.4.1 + Version: 1.5.0 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.4.0 K Hoang 11/09/2021 Add support to Portenta_H7 using Arduino mbed_portenta core - 1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json` + 1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json` + 1.5.0 K Hoang 08/01/2022 Workaround for core WiFi.status() bug. Fix the blocking issue in loop(). ********************************************************************************************************************************/ #ifndef WiFiManager_Portenta_H7_Lite_Debug_h @@ -47,6 +48,8 @@ const char WG_MARK[] = "[WG] "; // Error waitResponse message #define ERROR_RESPONSE ":Error waitResponse" +////////////////////////////////////////// + #define WG_LOGERROR0(x) if(_WIFI_GENERIC_LOGLEVEL_>0) { WG_PRINT(x); } #define WG_LOGERROR(x) if(_WIFI_GENERIC_LOGLEVEL_>0) { WG_PRINT_MARK; WG_PRINTLN(x); } #define WG_LOGERROR1(x,y) if(_WIFI_GENERIC_LOGLEVEL_>0) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINTLN(y); } @@ -54,6 +57,8 @@ const char WG_MARK[] = "[WG] "; #define WG_LOGERROR3(x,y,z,w) if(_WIFI_GENERIC_LOGLEVEL_>0) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINT(y); WG_PRINT(z); WG_PRINTLN(w); } #define WG_LOGERROR5(x,y,z,w,xx,yy) if(_WIFI_GENERIC_LOGLEVEL_>0) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINT(y); WG_PRINT(z); WG_PRINT(w); WG_PRINT(xx); WG_PRINTLN(yy); } +////////////////////////////////////////// + #define WG_LOGWARN0(x) if(_WIFI_GENERIC_LOGLEVEL_>1) { WG_PRINT(x); } #define WG_LOGWARN(x) if(_WIFI_GENERIC_LOGLEVEL_>1) { WG_PRINT_MARK; WG_PRINTLN(x); } #define WG_LOGWARN1(x,y) if(_WIFI_GENERIC_LOGLEVEL_>1) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINTLN(y); } @@ -61,6 +66,8 @@ const char WG_MARK[] = "[WG] "; #define WG_LOGWARN3(x,y,z,w) if(_WIFI_GENERIC_LOGLEVEL_>1) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINT(y); WG_PRINT(z); WG_PRINTLN(w); } #define WG_LOGWARN5(x,y,z,w,xx,yy) if(_WIFI_GENERIC_LOGLEVEL_>1) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINT(y); WG_PRINT(z); WG_PRINT(w); WG_PRINT(xx); WG_PRINTLN(yy); } +////////////////////////////////////////// + #define WG_LOGINFO0(x) if(_WIFI_GENERIC_LOGLEVEL_>2) { WG_PRINT(x); } #define WG_LOGINFO(x) if(_WIFI_GENERIC_LOGLEVEL_>2) { WG_PRINT_MARK; WG_PRINTLN(x); } #define WG_LOGINFO1(x,y) if(_WIFI_GENERIC_LOGLEVEL_>2) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINTLN(y); } @@ -68,6 +75,8 @@ const char WG_MARK[] = "[WG] "; #define WG_LOGINFO3(x,y,z,w) if(_WIFI_GENERIC_LOGLEVEL_>3) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINT(y); WG_PRINT(z); WG_PRINTLN(w); } #define WG_LOGINFO5(x,y,z,w,xx,yy) if(_WIFI_GENERIC_LOGLEVEL_>2) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINT(y); WG_PRINT(z); WG_PRINT(w); WG_PRINT(xx); WG_PRINTLN(yy); } +////////////////////////////////////////// + #define WG_LOGDEBUG0(x) if(_WIFI_GENERIC_LOGLEVEL_>3) { WG_PRINT(x); } #define WG_LOGDEBUG(x) if(_WIFI_GENERIC_LOGLEVEL_>3) { WG_PRINT_MARK; WG_PRINTLN(x); } #define WG_LOGDEBUG1(x,y) if(_WIFI_GENERIC_LOGLEVEL_>3) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINTLN(y); } @@ -75,6 +84,6 @@ const char WG_MARK[] = "[WG] "; #define WG_LOGDEBUG3(x,y,z,w) if(_WIFI_GENERIC_LOGLEVEL_>3) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINT(y); WG_PRINT(z); WG_PRINTLN(w); } #define WG_LOGDEBUG5(x,y,z,w,xx,yy) if(_WIFI_GENERIC_LOGLEVEL_>3) { WG_PRINT_MARK; WG_PRINT(x); WG_PRINT(y); WG_PRINT(z); WG_PRINT(w); WG_PRINT(xx); WG_PRINTLN(yy); } -////// +////////////////////////////////////////// #endif //WiFiManager_Portenta_H7_Lite_Debug_h