mirror of
https://github.com/khoih-prog/AsyncHTTPRequest_Generic.git
synced 2025-07-29 18:07:15 +02:00
Update Packages' Patches
This commit is contained in:
@ -21,8 +21,8 @@
|
||||
|
||||
// Workaround for Linux timeval
|
||||
#if defined (TOOLCHAIN_GCC)
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include "nsapi_types.h"
|
||||
#include "mbed_retarget.h"
|
||||
@ -35,7 +35,7 @@
|
||||
#define NO_SYS 0
|
||||
|
||||
#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#endif
|
||||
|
||||
#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED
|
||||
@ -47,16 +47,16 @@
|
||||
// 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
|
||||
#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
|
||||
#define PREF_ADDR_TIMEOUT 0
|
||||
#define BOTH_ADDR_TIMEOUT 0
|
||||
#endif
|
||||
|
||||
|
||||
@ -68,52 +68,52 @@
|
||||
#define PREF_IPV6 2
|
||||
|
||||
#if MBED_CONF_LWIP_IP_VER_PREF == 6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#elif MBED_CONF_LWIP_IP_VER_PREF == 4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#else
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#endif
|
||||
|
||||
#undef LWIP_DEBUG
|
||||
#if MBED_CONF_LWIP_DEBUG_ENABLED
|
||||
#define LWIP_DEBUG 1
|
||||
#define LWIP_DEBUG 1
|
||||
#endif
|
||||
|
||||
#if NO_SYS == 0
|
||||
#include "cmsis_os2.h"
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
|
||||
#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
|
||||
#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))
|
||||
// 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
|
||||
#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)
|
||||
// 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
|
||||
#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 MEMP_NUM_SYS_TIMEOUT 16
|
||||
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
|
||||
#endif
|
||||
|
||||
@ -143,16 +143,16 @@
|
||||
#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)
|
||||
#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
|
||||
#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
|
||||
@ -181,14 +181,14 @@
|
||||
#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 LWIP_TCP 1
|
||||
#define TCP_OVERSIZE 0
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
|
||||
#else
|
||||
#define LWIP_TCP 0
|
||||
#define LWIP_TCP 0
|
||||
#endif
|
||||
|
||||
#define LWIP_DNS 1
|
||||
@ -251,13 +251,13 @@
|
||||
#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
|
||||
#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
|
||||
#define LWIP_NOASSERT 1
|
||||
#define LWIP_STATS 0
|
||||
#endif
|
||||
|
||||
#define TRACE_TO_ASCII_HEX_DUMP 0
|
||||
@ -269,18 +269,18 @@
|
||||
// Interface type configuration
|
||||
|
||||
#if MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#else
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#endif // MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
|
||||
#if MBED_CONF_LWIP_L3IP_ENABLED
|
||||
#define LWIP_L3IP 1
|
||||
#define LWIP_L3IP 1
|
||||
#else
|
||||
#define LWIP_L3IP 0
|
||||
#define LWIP_L3IP 0
|
||||
#endif
|
||||
|
||||
//Maximum size of network interface name
|
||||
@ -291,27 +291,27 @@
|
||||
// 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
|
||||
#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_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
|
||||
#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
|
||||
|
||||
@ -320,7 +320,7 @@
|
||||
// Make sure we default these to off, so
|
||||
// LWIP doesn't default to on
|
||||
#ifndef LWIP_ARP
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ARP 0
|
||||
#endif
|
||||
|
||||
// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914
|
||||
@ -337,9 +337,9 @@
|
||||
#include "lwip_tcp_isn.h"
|
||||
#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn
|
||||
#ifdef MBEDTLS_MD5_C
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#else
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#endif
|
||||
|
||||
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS
|
||||
|
@ -2,272 +2,272 @@
|
||||
|
||||
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
|
||||
_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;
|
||||
delete[] _packet_buffer;
|
||||
}
|
||||
|
||||
uint8_t arduino::MbedUDP::begin(uint16_t port)
|
||||
{
|
||||
// success = 1, fail = 0
|
||||
// success = 1, fail = 0
|
||||
|
||||
nsapi_error_t rt = _socket.open(getNetwork());
|
||||
nsapi_error_t rt = _socket.open(getNetwork());
|
||||
|
||||
if (rt != NSAPI_ERROR_OK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (rt != NSAPI_ERROR_OK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_socket.bind(port) < 0)
|
||||
{
|
||||
return 0; //Failed to bind UDP Socket to port
|
||||
}
|
||||
if (_socket.bind(port) < 0)
|
||||
{
|
||||
return 0; //Failed to bind UDP Socket to port
|
||||
}
|
||||
|
||||
if (!_packet_buffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!_packet_buffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
_socket.set_blocking(false);
|
||||
_socket.set_timeout(0);
|
||||
_socket.set_blocking(false);
|
||||
_socket.set_timeout(0);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t arduino::MbedUDP::beginMulticast(IPAddress ip, uint16_t port)
|
||||
{
|
||||
// success = 1, fail = 0
|
||||
if (begin(port) != 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// success = 1, fail = 0
|
||||
if (begin(port) != 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SocketAddress socketAddress = SocketHelpers::socketAddressFromIpAddress(ip, port);
|
||||
SocketAddress socketAddress = SocketHelpers::socketAddressFromIpAddress(ip, port);
|
||||
|
||||
if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK)
|
||||
{
|
||||
printf("Error joining the multicast group\n");
|
||||
return 0;
|
||||
}
|
||||
if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK)
|
||||
{
|
||||
printf("Error joining the multicast group\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void arduino::MbedUDP::stop()
|
||||
{
|
||||
_socket.close();
|
||||
_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;
|
||||
_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;
|
||||
_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);
|
||||
_socket.set_blocking(true);
|
||||
_socket.set_timeout(1000);
|
||||
|
||||
size_t size = txBuffer.available();
|
||||
uint8_t buffer[size];
|
||||
size_t size = txBuffer.available();
|
||||
uint8_t buffer[size];
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
buffer[i] = txBuffer.read_char();
|
||||
}
|
||||
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);
|
||||
nsapi_size_or_error_t ret = _socket.sendto(_host, buffer, size);
|
||||
_socket.set_blocking(false);
|
||||
_socket.set_timeout(0);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (ret < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
return size;
|
||||
}
|
||||
|
||||
// Write a single byte into the packet
|
||||
size_t arduino::MbedUDP::write(uint8_t byte)
|
||||
{
|
||||
return write(&byte, 1);
|
||||
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 < size; i++)
|
||||
{
|
||||
if (txBuffer.availableForStore())
|
||||
{
|
||||
txBuffer.store_char(buffer[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
if (txBuffer.availableForStore())
|
||||
{
|
||||
txBuffer.store_char(buffer[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
return size;
|
||||
}
|
||||
|
||||
int arduino::MbedUDP::parsePacket()
|
||||
{
|
||||
nsapi_size_or_error_t ret = _socket.recvfrom(&_remoteHost, _packet_buffer, WIFI_UDP_BUFFER_SIZE);
|
||||
nsapi_size_or_error_t ret = _socket.recvfrom(&_remoteHost, _packet_buffer, WIFI_UDP_BUFFER_SIZE);
|
||||
|
||||
if (ret == NSAPI_ERROR_WOULD_BLOCK)
|
||||
{
|
||||
// no data
|
||||
return 0;
|
||||
}
|
||||
else if (ret == NSAPI_ERROR_NO_SOCKET)
|
||||
{
|
||||
// socket was not created correctly.
|
||||
return -1;
|
||||
}
|
||||
// error codes below zero are errors
|
||||
else if (ret <= 0)
|
||||
{
|
||||
// something else went wrong, need some tracing info...
|
||||
return -1;
|
||||
}
|
||||
if (ret == NSAPI_ERROR_WOULD_BLOCK)
|
||||
{
|
||||
// no data
|
||||
return 0;
|
||||
}
|
||||
else if (ret == NSAPI_ERROR_NO_SOCKET)
|
||||
{
|
||||
// socket was not created correctly.
|
||||
return -1;
|
||||
}
|
||||
// error codes below zero are errors
|
||||
else if (ret <= 0)
|
||||
{
|
||||
// something else went wrong, need some tracing info...
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set current packet states
|
||||
_current_packet = _packet_buffer;
|
||||
_current_packet_size = ret;
|
||||
// set current packet states
|
||||
_current_packet = _packet_buffer;
|
||||
_current_packet_size = ret;
|
||||
|
||||
return _current_packet_size;
|
||||
return _current_packet_size;
|
||||
}
|
||||
|
||||
int arduino::MbedUDP::available()
|
||||
{
|
||||
return _current_packet_size;
|
||||
return _current_packet_size;
|
||||
}
|
||||
|
||||
// Read a single byte from the current packet
|
||||
int arduino::MbedUDP::read()
|
||||
{
|
||||
// no current packet...
|
||||
if (_current_packet == NULL)
|
||||
{
|
||||
// try reading the next frame, if there is no data return
|
||||
if (parsePacket() == 0)
|
||||
return -1;
|
||||
}
|
||||
// no current packet...
|
||||
if (_current_packet == NULL)
|
||||
{
|
||||
// try reading the next frame, if there is no data return
|
||||
if (parsePacket() == 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
_current_packet++;
|
||||
_current_packet++;
|
||||
|
||||
// check for overflow
|
||||
if (_current_packet > _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;
|
||||
}
|
||||
}
|
||||
// check for overflow
|
||||
if (_current_packet > _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];
|
||||
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;
|
||||
}
|
||||
// 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;
|
||||
// how much data do we have in the current packet?
|
||||
int offset = _current_packet - _packet_buffer;
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int max_bytes = _current_packet_size - offset;
|
||||
int max_bytes = _current_packet_size - offset;
|
||||
|
||||
if (max_bytes < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
if (len > (size_t)max_bytes)
|
||||
len = max_bytes;
|
||||
|
||||
// copy to target buffer
|
||||
memcpy(buffer, _current_packet, len);
|
||||
// copy to target buffer
|
||||
memcpy(buffer, _current_packet, len);
|
||||
|
||||
_current_packet += len;
|
||||
_current_packet += len;
|
||||
|
||||
return 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]);
|
||||
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();
|
||||
return _remoteHost.get_port();
|
||||
}
|
||||
|
||||
void arduino::MbedUDP::flush()
|
||||
{
|
||||
// TODO: a real check to ensure transmission has been completed
|
||||
// TODO: a real check to ensure transmission has been completed
|
||||
}
|
||||
|
||||
int arduino::MbedUDP::peek()
|
||||
{
|
||||
if (_current_packet_size < 1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (_current_packet_size < 1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _current_packet[0];
|
||||
return _current_packet[0];
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "netsocket/UDPSocket.h"
|
||||
|
||||
#ifndef WIFI_UDP_BUFFER_SIZE
|
||||
#define WIFI_UDP_BUFFER_SIZE 508
|
||||
#define WIFI_UDP_BUFFER_SIZE 508
|
||||
#endif
|
||||
|
||||
namespace arduino
|
||||
@ -33,74 +33,76 @@ 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
|
||||
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)
|
||||
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;
|
||||
// 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<WIFI_UDP_BUFFER_SIZE> txBuffer;
|
||||
RingBufferN<WIFI_UDP_BUFFER_SIZE> txBuffer;
|
||||
|
||||
protected:
|
||||
virtual NetworkInterface* getNetwork() = 0;
|
||||
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
|
||||
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
|
||||
// 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);
|
||||
// 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;
|
||||
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
|
||||
// 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();
|
||||
// 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;
|
||||
friend class MbedSocketClass;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
// Workaround for Linux timeval
|
||||
#if defined (TOOLCHAIN_GCC)
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include "nsapi_types.h"
|
||||
#include "mbed_retarget.h"
|
||||
@ -35,7 +35,7 @@
|
||||
#define NO_SYS 0
|
||||
|
||||
#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#endif
|
||||
|
||||
#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED
|
||||
@ -47,16 +47,16 @@
|
||||
// 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
|
||||
#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
|
||||
#define PREF_ADDR_TIMEOUT 0
|
||||
#define BOTH_ADDR_TIMEOUT 0
|
||||
#endif
|
||||
|
||||
|
||||
@ -68,52 +68,52 @@
|
||||
#define PREF_IPV6 2
|
||||
|
||||
#if MBED_CONF_LWIP_IP_VER_PREF == 6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#elif MBED_CONF_LWIP_IP_VER_PREF == 4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#else
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#endif
|
||||
|
||||
#undef LWIP_DEBUG
|
||||
#if MBED_CONF_LWIP_DEBUG_ENABLED
|
||||
#define LWIP_DEBUG 1
|
||||
#define LWIP_DEBUG 1
|
||||
#endif
|
||||
|
||||
#if NO_SYS == 0
|
||||
#include "cmsis_os2.h"
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
|
||||
#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
|
||||
#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))
|
||||
// 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
|
||||
#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)
|
||||
// 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
|
||||
#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 MEMP_NUM_SYS_TIMEOUT 16
|
||||
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
|
||||
#endif
|
||||
|
||||
@ -143,16 +143,16 @@
|
||||
#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)
|
||||
#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
|
||||
#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
|
||||
@ -181,14 +181,14 @@
|
||||
#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 LWIP_TCP 1
|
||||
#define TCP_OVERSIZE 0
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
|
||||
#else
|
||||
#define LWIP_TCP 0
|
||||
#define LWIP_TCP 0
|
||||
#endif
|
||||
|
||||
#define LWIP_DNS 1
|
||||
@ -251,13 +251,13 @@
|
||||
#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
|
||||
#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
|
||||
#define LWIP_NOASSERT 1
|
||||
#define LWIP_STATS 0
|
||||
#endif
|
||||
|
||||
#define TRACE_TO_ASCII_HEX_DUMP 0
|
||||
@ -269,18 +269,18 @@
|
||||
// Interface type configuration
|
||||
|
||||
#if MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#else
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#endif // MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
|
||||
#if MBED_CONF_LWIP_L3IP_ENABLED
|
||||
#define LWIP_L3IP 1
|
||||
#define LWIP_L3IP 1
|
||||
#else
|
||||
#define LWIP_L3IP 0
|
||||
#define LWIP_L3IP 0
|
||||
#endif
|
||||
|
||||
//Maximum size of network interface name
|
||||
@ -291,27 +291,27 @@
|
||||
// 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
|
||||
#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_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
|
||||
#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
|
||||
|
||||
@ -320,7 +320,7 @@
|
||||
// Make sure we default these to off, so
|
||||
// LWIP doesn't default to on
|
||||
#ifndef LWIP_ARP
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ARP 0
|
||||
#endif
|
||||
|
||||
// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914
|
||||
@ -337,9 +337,9 @@
|
||||
#include "lwip_tcp_isn.h"
|
||||
#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn
|
||||
#ifdef MBEDTLS_MD5_C
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#else
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#endif
|
||||
|
||||
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS
|
||||
|
@ -2,272 +2,272 @@
|
||||
|
||||
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
|
||||
_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;
|
||||
delete[] _packet_buffer;
|
||||
}
|
||||
|
||||
uint8_t arduino::MbedUDP::begin(uint16_t port)
|
||||
{
|
||||
// success = 1, fail = 0
|
||||
// success = 1, fail = 0
|
||||
|
||||
nsapi_error_t rt = _socket.open(getNetwork());
|
||||
nsapi_error_t rt = _socket.open(getNetwork());
|
||||
|
||||
if (rt != NSAPI_ERROR_OK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (rt != NSAPI_ERROR_OK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_socket.bind(port) < 0)
|
||||
{
|
||||
return 0; //Failed to bind UDP Socket to port
|
||||
}
|
||||
if (_socket.bind(port) < 0)
|
||||
{
|
||||
return 0; //Failed to bind UDP Socket to port
|
||||
}
|
||||
|
||||
if (!_packet_buffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!_packet_buffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
_socket.set_blocking(false);
|
||||
_socket.set_timeout(0);
|
||||
_socket.set_blocking(false);
|
||||
_socket.set_timeout(0);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t arduino::MbedUDP::beginMulticast(IPAddress ip, uint16_t port)
|
||||
{
|
||||
// success = 1, fail = 0
|
||||
if (begin(port) != 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// success = 1, fail = 0
|
||||
if (begin(port) != 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SocketAddress socketAddress = SocketHelpers::socketAddressFromIpAddress(ip, port);
|
||||
SocketAddress socketAddress = SocketHelpers::socketAddressFromIpAddress(ip, port);
|
||||
|
||||
if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK)
|
||||
{
|
||||
printf("Error joining the multicast group\n");
|
||||
return 0;
|
||||
}
|
||||
if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK)
|
||||
{
|
||||
printf("Error joining the multicast group\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void arduino::MbedUDP::stop()
|
||||
{
|
||||
_socket.close();
|
||||
_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;
|
||||
_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;
|
||||
_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);
|
||||
_socket.set_blocking(true);
|
||||
_socket.set_timeout(1000);
|
||||
|
||||
size_t size = txBuffer.available();
|
||||
uint8_t buffer[size];
|
||||
size_t size = txBuffer.available();
|
||||
uint8_t buffer[size];
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
buffer[i] = txBuffer.read_char();
|
||||
}
|
||||
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);
|
||||
nsapi_size_or_error_t ret = _socket.sendto(_host, buffer, size);
|
||||
_socket.set_blocking(false);
|
||||
_socket.set_timeout(0);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (ret < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
return size;
|
||||
}
|
||||
|
||||
// Write a single byte into the packet
|
||||
size_t arduino::MbedUDP::write(uint8_t byte)
|
||||
{
|
||||
return write(&byte, 1);
|
||||
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 < size; i++)
|
||||
{
|
||||
if (txBuffer.availableForStore())
|
||||
{
|
||||
txBuffer.store_char(buffer[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
if (txBuffer.availableForStore())
|
||||
{
|
||||
txBuffer.store_char(buffer[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
return size;
|
||||
}
|
||||
|
||||
int arduino::MbedUDP::parsePacket()
|
||||
{
|
||||
nsapi_size_or_error_t ret = _socket.recvfrom(&_remoteHost, _packet_buffer, WIFI_UDP_BUFFER_SIZE);
|
||||
nsapi_size_or_error_t ret = _socket.recvfrom(&_remoteHost, _packet_buffer, WIFI_UDP_BUFFER_SIZE);
|
||||
|
||||
if (ret == NSAPI_ERROR_WOULD_BLOCK)
|
||||
{
|
||||
// no data
|
||||
return 0;
|
||||
}
|
||||
else if (ret == NSAPI_ERROR_NO_SOCKET)
|
||||
{
|
||||
// socket was not created correctly.
|
||||
return -1;
|
||||
}
|
||||
// error codes below zero are errors
|
||||
else if (ret <= 0)
|
||||
{
|
||||
// something else went wrong, need some tracing info...
|
||||
return -1;
|
||||
}
|
||||
if (ret == NSAPI_ERROR_WOULD_BLOCK)
|
||||
{
|
||||
// no data
|
||||
return 0;
|
||||
}
|
||||
else if (ret == NSAPI_ERROR_NO_SOCKET)
|
||||
{
|
||||
// socket was not created correctly.
|
||||
return -1;
|
||||
}
|
||||
// error codes below zero are errors
|
||||
else if (ret <= 0)
|
||||
{
|
||||
// something else went wrong, need some tracing info...
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set current packet states
|
||||
_current_packet = _packet_buffer;
|
||||
_current_packet_size = ret;
|
||||
// set current packet states
|
||||
_current_packet = _packet_buffer;
|
||||
_current_packet_size = ret;
|
||||
|
||||
return _current_packet_size;
|
||||
return _current_packet_size;
|
||||
}
|
||||
|
||||
int arduino::MbedUDP::available()
|
||||
{
|
||||
return _current_packet_size;
|
||||
return _current_packet_size;
|
||||
}
|
||||
|
||||
// Read a single byte from the current packet
|
||||
int arduino::MbedUDP::read()
|
||||
{
|
||||
// no current packet...
|
||||
if (_current_packet == NULL)
|
||||
{
|
||||
// try reading the next frame, if there is no data return
|
||||
if (parsePacket() == 0)
|
||||
return -1;
|
||||
}
|
||||
// no current packet...
|
||||
if (_current_packet == NULL)
|
||||
{
|
||||
// try reading the next frame, if there is no data return
|
||||
if (parsePacket() == 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
_current_packet++;
|
||||
_current_packet++;
|
||||
|
||||
// check for overflow
|
||||
if (_current_packet > _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;
|
||||
}
|
||||
}
|
||||
// check for overflow
|
||||
if (_current_packet > _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];
|
||||
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;
|
||||
}
|
||||
// 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;
|
||||
// how much data do we have in the current packet?
|
||||
int offset = _current_packet - _packet_buffer;
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int max_bytes = _current_packet_size - offset;
|
||||
int max_bytes = _current_packet_size - offset;
|
||||
|
||||
if (max_bytes < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
if (len > (size_t)max_bytes)
|
||||
len = max_bytes;
|
||||
|
||||
// copy to target buffer
|
||||
memcpy(buffer, _current_packet, len);
|
||||
// copy to target buffer
|
||||
memcpy(buffer, _current_packet, len);
|
||||
|
||||
_current_packet += len;
|
||||
_current_packet += len;
|
||||
|
||||
return 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]);
|
||||
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();
|
||||
return _remoteHost.get_port();
|
||||
}
|
||||
|
||||
void arduino::MbedUDP::flush()
|
||||
{
|
||||
// TODO: a real check to ensure transmission has been completed
|
||||
// TODO: a real check to ensure transmission has been completed
|
||||
}
|
||||
|
||||
int arduino::MbedUDP::peek()
|
||||
{
|
||||
if (_current_packet_size < 1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (_current_packet_size < 1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _current_packet[0];
|
||||
return _current_packet[0];
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "netsocket/UDPSocket.h"
|
||||
|
||||
#ifndef WIFI_UDP_BUFFER_SIZE
|
||||
#define WIFI_UDP_BUFFER_SIZE 508
|
||||
#define WIFI_UDP_BUFFER_SIZE 508
|
||||
#endif
|
||||
|
||||
namespace arduino
|
||||
@ -33,74 +33,76 @@ 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
|
||||
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)
|
||||
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;
|
||||
// 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<WIFI_UDP_BUFFER_SIZE> txBuffer;
|
||||
RingBufferN<WIFI_UDP_BUFFER_SIZE> txBuffer;
|
||||
|
||||
protected:
|
||||
virtual NetworkInterface* getNetwork() = 0;
|
||||
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
|
||||
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
|
||||
// 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);
|
||||
// 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;
|
||||
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
|
||||
// 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();
|
||||
// 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;
|
||||
friend class MbedSocketClass;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
// Workaround for Linux timeval
|
||||
#if defined (TOOLCHAIN_GCC)
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include "nsapi_types.h"
|
||||
#include "mbed_retarget.h"
|
||||
@ -35,7 +35,7 @@
|
||||
#define NO_SYS 0
|
||||
|
||||
#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#endif
|
||||
|
||||
#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED
|
||||
@ -47,16 +47,16 @@
|
||||
// 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
|
||||
#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
|
||||
#define PREF_ADDR_TIMEOUT 0
|
||||
#define BOTH_ADDR_TIMEOUT 0
|
||||
#endif
|
||||
|
||||
|
||||
@ -68,52 +68,52 @@
|
||||
#define PREF_IPV6 2
|
||||
|
||||
#if MBED_CONF_LWIP_IP_VER_PREF == 6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#elif MBED_CONF_LWIP_IP_VER_PREF == 4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#else
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#endif
|
||||
|
||||
#undef LWIP_DEBUG
|
||||
#if MBED_CONF_LWIP_DEBUG_ENABLED
|
||||
#define LWIP_DEBUG 1
|
||||
#define LWIP_DEBUG 1
|
||||
#endif
|
||||
|
||||
#if NO_SYS == 0
|
||||
#include "cmsis_os2.h"
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
|
||||
#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
|
||||
#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))
|
||||
// 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
|
||||
#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)
|
||||
// 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
|
||||
#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 MEMP_NUM_SYS_TIMEOUT 16
|
||||
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
|
||||
#endif
|
||||
|
||||
@ -143,16 +143,16 @@
|
||||
#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)
|
||||
#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
|
||||
#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
|
||||
@ -181,14 +181,14 @@
|
||||
#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 LWIP_TCP 1
|
||||
#define TCP_OVERSIZE 0
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
|
||||
#else
|
||||
#define LWIP_TCP 0
|
||||
#define LWIP_TCP 0
|
||||
#endif
|
||||
|
||||
#define LWIP_DNS 1
|
||||
@ -251,13 +251,13 @@
|
||||
#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
|
||||
#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
|
||||
#define LWIP_NOASSERT 1
|
||||
#define LWIP_STATS 0
|
||||
#endif
|
||||
|
||||
#define TRACE_TO_ASCII_HEX_DUMP 0
|
||||
@ -269,18 +269,18 @@
|
||||
// Interface type configuration
|
||||
|
||||
#if MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#else
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#endif // MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
|
||||
#if MBED_CONF_LWIP_L3IP_ENABLED
|
||||
#define LWIP_L3IP 1
|
||||
#define LWIP_L3IP 1
|
||||
#else
|
||||
#define LWIP_L3IP 0
|
||||
#define LWIP_L3IP 0
|
||||
#endif
|
||||
|
||||
//Maximum size of network interface name
|
||||
@ -291,27 +291,27 @@
|
||||
// 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
|
||||
#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_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
|
||||
#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
|
||||
|
||||
@ -320,7 +320,7 @@
|
||||
// Make sure we default these to off, so
|
||||
// LWIP doesn't default to on
|
||||
#ifndef LWIP_ARP
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ARP 0
|
||||
#endif
|
||||
|
||||
// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914
|
||||
@ -337,9 +337,9 @@
|
||||
#include "lwip_tcp_isn.h"
|
||||
#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn
|
||||
#ifdef MBEDTLS_MD5_C
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#else
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#endif
|
||||
|
||||
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS
|
||||
|
@ -2,272 +2,272 @@
|
||||
|
||||
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
|
||||
_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;
|
||||
delete[] _packet_buffer;
|
||||
}
|
||||
|
||||
uint8_t arduino::MbedUDP::begin(uint16_t port)
|
||||
{
|
||||
// success = 1, fail = 0
|
||||
// success = 1, fail = 0
|
||||
|
||||
nsapi_error_t rt = _socket.open(getNetwork());
|
||||
nsapi_error_t rt = _socket.open(getNetwork());
|
||||
|
||||
if (rt != NSAPI_ERROR_OK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (rt != NSAPI_ERROR_OK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_socket.bind(port) < 0)
|
||||
{
|
||||
return 0; //Failed to bind UDP Socket to port
|
||||
}
|
||||
if (_socket.bind(port) < 0)
|
||||
{
|
||||
return 0; //Failed to bind UDP Socket to port
|
||||
}
|
||||
|
||||
if (!_packet_buffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!_packet_buffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
_socket.set_blocking(false);
|
||||
_socket.set_timeout(0);
|
||||
_socket.set_blocking(false);
|
||||
_socket.set_timeout(0);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t arduino::MbedUDP::beginMulticast(IPAddress ip, uint16_t port)
|
||||
{
|
||||
// success = 1, fail = 0
|
||||
if (begin(port) != 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// success = 1, fail = 0
|
||||
if (begin(port) != 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SocketAddress socketAddress = SocketHelpers::socketAddressFromIpAddress(ip, port);
|
||||
SocketAddress socketAddress = SocketHelpers::socketAddressFromIpAddress(ip, port);
|
||||
|
||||
if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK)
|
||||
{
|
||||
printf("Error joining the multicast group\n");
|
||||
return 0;
|
||||
}
|
||||
if (_socket.join_multicast_group(socketAddress) != NSAPI_ERROR_OK)
|
||||
{
|
||||
printf("Error joining the multicast group\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void arduino::MbedUDP::stop()
|
||||
{
|
||||
_socket.close();
|
||||
_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;
|
||||
_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;
|
||||
_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);
|
||||
_socket.set_blocking(true);
|
||||
_socket.set_timeout(1000);
|
||||
|
||||
size_t size = txBuffer.available();
|
||||
uint8_t buffer[size];
|
||||
size_t size = txBuffer.available();
|
||||
uint8_t buffer[size];
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
buffer[i] = txBuffer.read_char();
|
||||
}
|
||||
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);
|
||||
nsapi_size_or_error_t ret = _socket.sendto(_host, buffer, size);
|
||||
_socket.set_blocking(false);
|
||||
_socket.set_timeout(0);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (ret < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
return size;
|
||||
}
|
||||
|
||||
// Write a single byte into the packet
|
||||
size_t arduino::MbedUDP::write(uint8_t byte)
|
||||
{
|
||||
return write(&byte, 1);
|
||||
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 < size; i++)
|
||||
{
|
||||
if (txBuffer.availableForStore())
|
||||
{
|
||||
txBuffer.store_char(buffer[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
if (txBuffer.availableForStore())
|
||||
{
|
||||
txBuffer.store_char(buffer[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
return size;
|
||||
}
|
||||
|
||||
int arduino::MbedUDP::parsePacket()
|
||||
{
|
||||
nsapi_size_or_error_t ret = _socket.recvfrom(&_remoteHost, _packet_buffer, WIFI_UDP_BUFFER_SIZE);
|
||||
nsapi_size_or_error_t ret = _socket.recvfrom(&_remoteHost, _packet_buffer, WIFI_UDP_BUFFER_SIZE);
|
||||
|
||||
if (ret == NSAPI_ERROR_WOULD_BLOCK)
|
||||
{
|
||||
// no data
|
||||
return 0;
|
||||
}
|
||||
else if (ret == NSAPI_ERROR_NO_SOCKET)
|
||||
{
|
||||
// socket was not created correctly.
|
||||
return -1;
|
||||
}
|
||||
// error codes below zero are errors
|
||||
else if (ret <= 0)
|
||||
{
|
||||
// something else went wrong, need some tracing info...
|
||||
return -1;
|
||||
}
|
||||
if (ret == NSAPI_ERROR_WOULD_BLOCK)
|
||||
{
|
||||
// no data
|
||||
return 0;
|
||||
}
|
||||
else if (ret == NSAPI_ERROR_NO_SOCKET)
|
||||
{
|
||||
// socket was not created correctly.
|
||||
return -1;
|
||||
}
|
||||
// error codes below zero are errors
|
||||
else if (ret <= 0)
|
||||
{
|
||||
// something else went wrong, need some tracing info...
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set current packet states
|
||||
_current_packet = _packet_buffer;
|
||||
_current_packet_size = ret;
|
||||
// set current packet states
|
||||
_current_packet = _packet_buffer;
|
||||
_current_packet_size = ret;
|
||||
|
||||
return _current_packet_size;
|
||||
return _current_packet_size;
|
||||
}
|
||||
|
||||
int arduino::MbedUDP::available()
|
||||
{
|
||||
return _current_packet_size;
|
||||
return _current_packet_size;
|
||||
}
|
||||
|
||||
// Read a single byte from the current packet
|
||||
int arduino::MbedUDP::read()
|
||||
{
|
||||
// no current packet...
|
||||
if (_current_packet == NULL)
|
||||
{
|
||||
// try reading the next frame, if there is no data return
|
||||
if (parsePacket() == 0)
|
||||
return -1;
|
||||
}
|
||||
// no current packet...
|
||||
if (_current_packet == NULL)
|
||||
{
|
||||
// try reading the next frame, if there is no data return
|
||||
if (parsePacket() == 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
_current_packet++;
|
||||
_current_packet++;
|
||||
|
||||
// check for overflow
|
||||
if (_current_packet > _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;
|
||||
}
|
||||
}
|
||||
// check for overflow
|
||||
if (_current_packet > _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];
|
||||
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;
|
||||
}
|
||||
// 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;
|
||||
// how much data do we have in the current packet?
|
||||
int offset = _current_packet - _packet_buffer;
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int max_bytes = _current_packet_size - offset;
|
||||
int max_bytes = _current_packet_size - offset;
|
||||
|
||||
if (max_bytes < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
if (len > (size_t)max_bytes)
|
||||
len = max_bytes;
|
||||
|
||||
// copy to target buffer
|
||||
memcpy(buffer, _current_packet, len);
|
||||
// copy to target buffer
|
||||
memcpy(buffer, _current_packet, len);
|
||||
|
||||
_current_packet += len;
|
||||
_current_packet += len;
|
||||
|
||||
return 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]);
|
||||
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();
|
||||
return _remoteHost.get_port();
|
||||
}
|
||||
|
||||
void arduino::MbedUDP::flush()
|
||||
{
|
||||
// TODO: a real check to ensure transmission has been completed
|
||||
// TODO: a real check to ensure transmission has been completed
|
||||
}
|
||||
|
||||
int arduino::MbedUDP::peek()
|
||||
{
|
||||
if (_current_packet_size < 1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (_current_packet_size < 1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _current_packet[0];
|
||||
return _current_packet[0];
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "netsocket/UDPSocket.h"
|
||||
|
||||
#ifndef WIFI_UDP_BUFFER_SIZE
|
||||
#define WIFI_UDP_BUFFER_SIZE 508
|
||||
#define WIFI_UDP_BUFFER_SIZE 508
|
||||
#endif
|
||||
|
||||
namespace arduino
|
||||
@ -33,74 +33,76 @@ 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
|
||||
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)
|
||||
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;
|
||||
// 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<WIFI_UDP_BUFFER_SIZE> txBuffer;
|
||||
RingBufferN<WIFI_UDP_BUFFER_SIZE> txBuffer;
|
||||
|
||||
protected:
|
||||
virtual NetworkInterface* getNetwork() = 0;
|
||||
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
|
||||
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
|
||||
// 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);
|
||||
// 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;
|
||||
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
|
||||
// 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();
|
||||
// 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;
|
||||
friend class MbedSocketClass;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
// Workaround for Linux timeval
|
||||
#if defined (TOOLCHAIN_GCC)
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include "nsapi_types.h"
|
||||
#include "mbed_retarget.h"
|
||||
@ -35,7 +35,7 @@
|
||||
#define NO_SYS 0
|
||||
|
||||
#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#endif
|
||||
|
||||
#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED
|
||||
@ -47,16 +47,16 @@
|
||||
// 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
|
||||
#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
|
||||
#define PREF_ADDR_TIMEOUT 0
|
||||
#define BOTH_ADDR_TIMEOUT 0
|
||||
#endif
|
||||
|
||||
|
||||
@ -68,52 +68,52 @@
|
||||
#define PREF_IPV6 2
|
||||
|
||||
#if MBED_CONF_LWIP_IP_VER_PREF == 6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#elif MBED_CONF_LWIP_IP_VER_PREF == 4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#else
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#endif
|
||||
|
||||
#undef LWIP_DEBUG
|
||||
#if MBED_CONF_LWIP_DEBUG_ENABLED
|
||||
#define LWIP_DEBUG 1
|
||||
#define LWIP_DEBUG 1
|
||||
#endif
|
||||
|
||||
#if NO_SYS == 0
|
||||
#include "cmsis_os2.h"
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
|
||||
#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
|
||||
#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))
|
||||
// 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
|
||||
#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)
|
||||
// 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
|
||||
#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 MEMP_NUM_SYS_TIMEOUT 16
|
||||
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
|
||||
#endif
|
||||
|
||||
@ -143,16 +143,16 @@
|
||||
#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)
|
||||
#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
|
||||
#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
|
||||
@ -181,14 +181,14 @@
|
||||
#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 LWIP_TCP 1
|
||||
#define TCP_OVERSIZE 0
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
|
||||
#else
|
||||
#define LWIP_TCP 0
|
||||
#define LWIP_TCP 0
|
||||
#endif
|
||||
|
||||
#define LWIP_DNS 1
|
||||
@ -251,13 +251,13 @@
|
||||
#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
|
||||
#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
|
||||
#define LWIP_NOASSERT 1
|
||||
#define LWIP_STATS 0
|
||||
#endif
|
||||
|
||||
#define TRACE_TO_ASCII_HEX_DUMP 0
|
||||
@ -269,18 +269,18 @@
|
||||
// Interface type configuration
|
||||
|
||||
#if MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#else
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#endif // MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
|
||||
#if MBED_CONF_LWIP_L3IP_ENABLED
|
||||
#define LWIP_L3IP 1
|
||||
#define LWIP_L3IP 1
|
||||
#else
|
||||
#define LWIP_L3IP 0
|
||||
#define LWIP_L3IP 0
|
||||
#endif
|
||||
|
||||
//Maximum size of network interface name
|
||||
@ -291,27 +291,27 @@
|
||||
// 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
|
||||
#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_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
|
||||
#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
|
||||
|
||||
@ -320,7 +320,7 @@
|
||||
// Make sure we default these to off, so
|
||||
// LWIP doesn't default to on
|
||||
#ifndef LWIP_ARP
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ARP 0
|
||||
#endif
|
||||
|
||||
// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914
|
||||
@ -337,9 +337,9 @@
|
||||
#include "lwip_tcp_isn.h"
|
||||
#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn
|
||||
#ifdef MBEDTLS_MD5_C
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#else
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#endif
|
||||
|
||||
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
// Workaround for Linux timeval
|
||||
#if defined (TOOLCHAIN_GCC)
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include "nsapi_types.h"
|
||||
#include "mbed_retarget.h"
|
||||
@ -35,7 +35,7 @@
|
||||
#define NO_SYS 0
|
||||
|
||||
#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#endif
|
||||
|
||||
#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED
|
||||
@ -47,16 +47,16 @@
|
||||
// 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
|
||||
#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
|
||||
#define PREF_ADDR_TIMEOUT 0
|
||||
#define BOTH_ADDR_TIMEOUT 0
|
||||
#endif
|
||||
|
||||
|
||||
@ -68,52 +68,52 @@
|
||||
#define PREF_IPV6 2
|
||||
|
||||
#if MBED_CONF_LWIP_IP_VER_PREF == 6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#elif MBED_CONF_LWIP_IP_VER_PREF == 4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#else
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#endif
|
||||
|
||||
#undef LWIP_DEBUG
|
||||
#if MBED_CONF_LWIP_DEBUG_ENABLED
|
||||
#define LWIP_DEBUG 1
|
||||
#define LWIP_DEBUG 1
|
||||
#endif
|
||||
|
||||
#if NO_SYS == 0
|
||||
#include "cmsis_os2.h"
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
|
||||
#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
|
||||
#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))
|
||||
// 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
|
||||
#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)
|
||||
// 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
|
||||
#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 MEMP_NUM_SYS_TIMEOUT 16
|
||||
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
|
||||
#endif
|
||||
|
||||
@ -143,16 +143,16 @@
|
||||
#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)
|
||||
#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
|
||||
#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
|
||||
@ -181,14 +181,14 @@
|
||||
#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 LWIP_TCP 1
|
||||
#define TCP_OVERSIZE 0
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
|
||||
#else
|
||||
#define LWIP_TCP 0
|
||||
#define LWIP_TCP 0
|
||||
#endif
|
||||
|
||||
#define LWIP_DNS 1
|
||||
@ -251,13 +251,13 @@
|
||||
#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
|
||||
#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
|
||||
#define LWIP_NOASSERT 1
|
||||
#define LWIP_STATS 0
|
||||
#endif
|
||||
|
||||
#define TRACE_TO_ASCII_HEX_DUMP 0
|
||||
@ -269,18 +269,18 @@
|
||||
// Interface type configuration
|
||||
|
||||
#if MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#else
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#endif // MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
|
||||
#if MBED_CONF_LWIP_L3IP_ENABLED
|
||||
#define LWIP_L3IP 1
|
||||
#define LWIP_L3IP 1
|
||||
#else
|
||||
#define LWIP_L3IP 0
|
||||
#define LWIP_L3IP 0
|
||||
#endif
|
||||
|
||||
//Maximum size of network interface name
|
||||
@ -291,27 +291,27 @@
|
||||
// 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
|
||||
#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_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
|
||||
#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
|
||||
|
||||
@ -320,7 +320,7 @@
|
||||
// Make sure we default these to off, so
|
||||
// LWIP doesn't default to on
|
||||
#ifndef LWIP_ARP
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ARP 0
|
||||
#endif
|
||||
|
||||
// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914
|
||||
@ -337,9 +337,9 @@
|
||||
#include "lwip_tcp_isn.h"
|
||||
#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn
|
||||
#ifdef MBEDTLS_MD5_C
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#else
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#endif
|
||||
|
||||
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
// Workaround for Linux timeval
|
||||
#if defined (TOOLCHAIN_GCC)
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include "nsapi_types.h"
|
||||
#include "mbed_retarget.h"
|
||||
@ -35,7 +35,7 @@
|
||||
#define NO_SYS 0
|
||||
|
||||
#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#endif
|
||||
|
||||
#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED
|
||||
@ -47,16 +47,16 @@
|
||||
// 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
|
||||
#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
|
||||
#define PREF_ADDR_TIMEOUT 0
|
||||
#define BOTH_ADDR_TIMEOUT 0
|
||||
#endif
|
||||
|
||||
|
||||
@ -68,52 +68,52 @@
|
||||
#define PREF_IPV6 2
|
||||
|
||||
#if MBED_CONF_LWIP_IP_VER_PREF == 6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#elif MBED_CONF_LWIP_IP_VER_PREF == 4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#else
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#endif
|
||||
|
||||
#undef LWIP_DEBUG
|
||||
#if MBED_CONF_LWIP_DEBUG_ENABLED
|
||||
#define LWIP_DEBUG 1
|
||||
#define LWIP_DEBUG 1
|
||||
#endif
|
||||
|
||||
#if NO_SYS == 0
|
||||
#include "cmsis_os2.h"
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
|
||||
#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
|
||||
#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))
|
||||
// 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
|
||||
#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)
|
||||
// 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
|
||||
#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 MEMP_NUM_SYS_TIMEOUT 16
|
||||
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
|
||||
#endif
|
||||
|
||||
@ -143,16 +143,16 @@
|
||||
#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)
|
||||
#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
|
||||
#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
|
||||
@ -181,14 +181,14 @@
|
||||
#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 LWIP_TCP 1
|
||||
#define TCP_OVERSIZE 0
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
|
||||
#else
|
||||
#define LWIP_TCP 0
|
||||
#define LWIP_TCP 0
|
||||
#endif
|
||||
|
||||
#define LWIP_DNS 1
|
||||
@ -251,13 +251,13 @@
|
||||
#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
|
||||
#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
|
||||
#define LWIP_NOASSERT 1
|
||||
#define LWIP_STATS 0
|
||||
#endif
|
||||
|
||||
#define TRACE_TO_ASCII_HEX_DUMP 0
|
||||
@ -269,18 +269,18 @@
|
||||
// Interface type configuration
|
||||
|
||||
#if MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#else
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#endif // MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
|
||||
#if MBED_CONF_LWIP_L3IP_ENABLED
|
||||
#define LWIP_L3IP 1
|
||||
#define LWIP_L3IP 1
|
||||
#else
|
||||
#define LWIP_L3IP 0
|
||||
#define LWIP_L3IP 0
|
||||
#endif
|
||||
|
||||
//Maximum size of network interface name
|
||||
@ -291,27 +291,27 @@
|
||||
// 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
|
||||
#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_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
|
||||
#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
|
||||
|
||||
@ -320,7 +320,7 @@
|
||||
// Make sure we default these to off, so
|
||||
// LWIP doesn't default to on
|
||||
#ifndef LWIP_ARP
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ARP 0
|
||||
#endif
|
||||
|
||||
// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914
|
||||
@ -337,9 +337,9 @@
|
||||
#include "lwip_tcp_isn.h"
|
||||
#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn
|
||||
#ifdef MBEDTLS_MD5_C
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#else
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#endif
|
||||
|
||||
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
// Workaround for Linux timeval
|
||||
#if defined (TOOLCHAIN_GCC)
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include "nsapi_types.h"
|
||||
#include "mbed_retarget.h"
|
||||
@ -35,7 +35,7 @@
|
||||
#define NO_SYS 0
|
||||
|
||||
#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#endif
|
||||
|
||||
#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED
|
||||
@ -47,16 +47,16 @@
|
||||
// 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
|
||||
#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
|
||||
#define PREF_ADDR_TIMEOUT 0
|
||||
#define BOTH_ADDR_TIMEOUT 0
|
||||
#endif
|
||||
|
||||
|
||||
@ -68,52 +68,52 @@
|
||||
#define PREF_IPV6 2
|
||||
|
||||
#if MBED_CONF_LWIP_IP_VER_PREF == 6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#elif MBED_CONF_LWIP_IP_VER_PREF == 4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#else
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#endif
|
||||
|
||||
#undef LWIP_DEBUG
|
||||
#if MBED_CONF_LWIP_DEBUG_ENABLED
|
||||
#define LWIP_DEBUG 1
|
||||
#define LWIP_DEBUG 1
|
||||
#endif
|
||||
|
||||
#if NO_SYS == 0
|
||||
#include "cmsis_os2.h"
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
|
||||
#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
|
||||
#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))
|
||||
// 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
|
||||
#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)
|
||||
// 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
|
||||
#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 MEMP_NUM_SYS_TIMEOUT 16
|
||||
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
|
||||
#endif
|
||||
|
||||
@ -143,16 +143,16 @@
|
||||
#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)
|
||||
#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
|
||||
#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
|
||||
@ -181,14 +181,14 @@
|
||||
#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 LWIP_TCP 1
|
||||
#define TCP_OVERSIZE 0
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
|
||||
#else
|
||||
#define LWIP_TCP 0
|
||||
#define LWIP_TCP 0
|
||||
#endif
|
||||
|
||||
#define LWIP_DNS 1
|
||||
@ -251,13 +251,13 @@
|
||||
#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
|
||||
#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
|
||||
#define LWIP_NOASSERT 1
|
||||
#define LWIP_STATS 0
|
||||
#endif
|
||||
|
||||
#define TRACE_TO_ASCII_HEX_DUMP 0
|
||||
@ -269,18 +269,18 @@
|
||||
// Interface type configuration
|
||||
|
||||
#if MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#else
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#endif // MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
|
||||
#if MBED_CONF_LWIP_L3IP_ENABLED
|
||||
#define LWIP_L3IP 1
|
||||
#define LWIP_L3IP 1
|
||||
#else
|
||||
#define LWIP_L3IP 0
|
||||
#define LWIP_L3IP 0
|
||||
#endif
|
||||
|
||||
//Maximum size of network interface name
|
||||
@ -291,27 +291,27 @@
|
||||
// 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
|
||||
#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_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
|
||||
#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
|
||||
|
||||
@ -320,7 +320,7 @@
|
||||
// Make sure we default these to off, so
|
||||
// LWIP doesn't default to on
|
||||
#ifndef LWIP_ARP
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ARP 0
|
||||
#endif
|
||||
|
||||
// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914
|
||||
@ -337,9 +337,9 @@
|
||||
#include "lwip_tcp_isn.h"
|
||||
#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn
|
||||
#ifdef MBEDTLS_MD5_C
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#else
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#endif
|
||||
|
||||
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
// Workaround for Linux timeval
|
||||
#if defined (TOOLCHAIN_GCC)
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include "nsapi_types.h"
|
||||
#include "mbed_retarget.h"
|
||||
@ -35,7 +35,7 @@
|
||||
#define NO_SYS 0
|
||||
|
||||
#if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#error "Either IPv4 or IPv6 must be enabled."
|
||||
#endif
|
||||
|
||||
#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED
|
||||
@ -47,16 +47,16 @@
|
||||
// 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
|
||||
#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
|
||||
#define PREF_ADDR_TIMEOUT 0
|
||||
#define BOTH_ADDR_TIMEOUT 0
|
||||
#endif
|
||||
|
||||
|
||||
@ -68,52 +68,52 @@
|
||||
#define PREF_IPV6 2
|
||||
|
||||
#if MBED_CONF_LWIP_IP_VER_PREF == 6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#define IP_VERSION_PREF PREF_IPV6
|
||||
#elif MBED_CONF_LWIP_IP_VER_PREF == 4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#define IP_VERSION_PREF PREF_IPV4
|
||||
#else
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#error "Either IPv4 or IPv6 must be preferred."
|
||||
#endif
|
||||
|
||||
#undef LWIP_DEBUG
|
||||
#if MBED_CONF_LWIP_DEBUG_ENABLED
|
||||
#define LWIP_DEBUG 1
|
||||
#define LWIP_DEBUG 1
|
||||
#endif
|
||||
|
||||
#if NO_SYS == 0
|
||||
#include "cmsis_os2.h"
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
#define LWIP_RAW MBED_CONF_LWIP_RAW_SOCKET_ENABLED
|
||||
|
||||
#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT
|
||||
#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))
|
||||
// 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
|
||||
#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)
|
||||
// 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
|
||||
#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 MEMP_NUM_SYS_TIMEOUT 16
|
||||
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
#define sys_msleep(ms) sys_msleep(ms)
|
||||
|
||||
#endif
|
||||
|
||||
@ -143,16 +143,16 @@
|
||||
#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)
|
||||
#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
|
||||
#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
|
||||
@ -181,14 +181,14 @@
|
||||
#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 LWIP_TCP 1
|
||||
#define TCP_OVERSIZE 0
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT
|
||||
|
||||
#else
|
||||
#define LWIP_TCP 0
|
||||
#define LWIP_TCP 0
|
||||
#endif
|
||||
|
||||
#define LWIP_DNS 1
|
||||
@ -251,13 +251,13 @@
|
||||
#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
|
||||
#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
|
||||
#define LWIP_NOASSERT 1
|
||||
#define LWIP_STATS 0
|
||||
#endif
|
||||
|
||||
#define TRACE_TO_ASCII_HEX_DUMP 0
|
||||
@ -269,18 +269,18 @@
|
||||
// Interface type configuration
|
||||
|
||||
#if MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#define LWIP_ARP 1
|
||||
#define LWIP_ETHERNET 1
|
||||
#define LWIP_DHCP LWIP_IPV4
|
||||
#else
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
#endif // MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
|
||||
#if MBED_CONF_LWIP_L3IP_ENABLED
|
||||
#define LWIP_L3IP 1
|
||||
#define LWIP_L3IP 1
|
||||
#else
|
||||
#define LWIP_L3IP 0
|
||||
#define LWIP_L3IP 0
|
||||
#endif
|
||||
|
||||
//Maximum size of network interface name
|
||||
@ -291,27 +291,27 @@
|
||||
// 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
|
||||
#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_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
|
||||
#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
|
||||
|
||||
@ -320,7 +320,7 @@
|
||||
// Make sure we default these to off, so
|
||||
// LWIP doesn't default to on
|
||||
#ifndef LWIP_ARP
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ARP 0
|
||||
#endif
|
||||
|
||||
// Checksum-on-copy disabled due to https://savannah.nongnu.org/bugs/?50914
|
||||
@ -337,9 +337,9 @@
|
||||
#include "lwip_tcp_isn.h"
|
||||
#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn
|
||||
#ifdef MBEDTLS_MD5_C
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 1
|
||||
#else
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#endif
|
||||
|
||||
#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS
|
||||
|
@ -58,7 +58,7 @@ compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
# this can be overridden in boards.txt
|
||||
build.extra_flags=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
|
@ -58,7 +58,7 @@ compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
# this can be overridden in boards.txt
|
||||
build.extra_flags=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
|
@ -58,7 +58,7 @@ compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
# this can be overridden in boards.txt
|
||||
build.extra_flags=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
|
@ -58,7 +58,7 @@ compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
# this can be overridden in boards.txt
|
||||
build.extra_flags=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
|
@ -70,19 +70,19 @@ void loop( void ) ;
|
||||
|
||||
// The following headers are for C++ only compilation
|
||||
#ifdef __cplusplus
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#endif
|
||||
|
||||
#include "delay.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "Uart.h"
|
||||
#include "Uart.h"
|
||||
#endif
|
||||
|
||||
// Include board variant
|
||||
@ -96,7 +96,7 @@ void loop( void ) ;
|
||||
#ifndef __cplusplus
|
||||
// undefine stdlib's abs if encountered
|
||||
#ifdef abs
|
||||
#undef abs
|
||||
#undef abs
|
||||
#endif // abs
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
@ -110,13 +110,13 @@ void loop( void ) ;
|
||||
template<class T, class L>
|
||||
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (b < a) ? b : a;
|
||||
return (b < a) ? b : a;
|
||||
}
|
||||
|
||||
template<class T, class L>
|
||||
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (a < b) ? b : a;
|
||||
return (a < b) ? b : a;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -138,13 +138,13 @@ auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
#define bit(b) (1UL << (b))
|
||||
|
||||
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
#endif
|
||||
|
||||
// Allows publishing the Beta core under samd-beta / arduino organization
|
||||
#ifndef ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#endif
|
||||
|
||||
// USB Device
|
||||
@ -154,7 +154,7 @@ auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
#include "USB/USB_host.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "USB/CDC.h"
|
||||
#include "USB/CDC.h"
|
||||
#endif
|
||||
|
||||
#endif // Arduino_h
|
||||
|
@ -58,7 +58,7 @@ compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
# this can be overridden in boards.txt
|
||||
build.extra_flags=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
|
@ -70,19 +70,19 @@ void loop( void ) ;
|
||||
|
||||
// The following headers are for C++ only compilation
|
||||
#ifdef __cplusplus
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#endif
|
||||
|
||||
#include "delay.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "Uart.h"
|
||||
#include "Uart.h"
|
||||
#endif
|
||||
|
||||
// Include board variant
|
||||
@ -96,7 +96,7 @@ void loop( void ) ;
|
||||
#ifndef __cplusplus
|
||||
// undefine stdlib's abs if encountered
|
||||
#ifdef abs
|
||||
#undef abs
|
||||
#undef abs
|
||||
#endif // abs
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
@ -110,13 +110,13 @@ void loop( void ) ;
|
||||
template<class T, class L>
|
||||
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (b < a) ? b : a;
|
||||
return (b < a) ? b : a;
|
||||
}
|
||||
|
||||
template<class T, class L>
|
||||
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (a < b) ? b : a;
|
||||
return (a < b) ? b : a;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -138,13 +138,13 @@ auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
#define bit(b) (1UL << (b))
|
||||
|
||||
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
#endif
|
||||
|
||||
// Allows publishing the Beta core under samd-beta / arduino organization
|
||||
#ifndef ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#endif
|
||||
|
||||
// USB Device
|
||||
@ -154,7 +154,7 @@ auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
#include "USB/USB_host.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "USB/CDC.h"
|
||||
#include "USB/CDC.h"
|
||||
#endif
|
||||
|
||||
#endif // Arduino_h
|
||||
|
@ -58,7 +58,7 @@ compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
# this can be overridden in boards.txt
|
||||
build.extra_flags=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
|
@ -75,19 +75,19 @@ void loop( void ) ;
|
||||
|
||||
// The following headers are for C++ only compilation
|
||||
#ifdef __cplusplus
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#endif
|
||||
|
||||
#include "delay.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "Uart.h"
|
||||
#include "Uart.h"
|
||||
#endif
|
||||
|
||||
// Include board variant
|
||||
@ -101,7 +101,7 @@ void loop( void ) ;
|
||||
#ifndef __cplusplus
|
||||
// undefine stdlib's abs if encountered
|
||||
#ifdef abs
|
||||
#undef abs
|
||||
#undef abs
|
||||
#endif // abs
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
@ -115,13 +115,13 @@ void loop( void ) ;
|
||||
template<class T, class L>
|
||||
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (b < a) ? b : a;
|
||||
return (b < a) ? b : a;
|
||||
}
|
||||
|
||||
template<class T, class L>
|
||||
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (a < b) ? b : a;
|
||||
return (a < b) ? b : a;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -143,13 +143,13 @@ auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
#define bit(b) (1UL << (b))
|
||||
|
||||
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
#endif
|
||||
|
||||
// Allows publishing the Beta core under samd-beta / arduino organization
|
||||
#ifndef ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#endif
|
||||
|
||||
// USB Device
|
||||
@ -159,7 +159,7 @@ auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
#include "USB/USB_host.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "USB/CDC.h"
|
||||
#include "USB/CDC.h"
|
||||
#endif
|
||||
|
||||
#endif // Arduino_h
|
||||
|
@ -75,19 +75,19 @@ void loop( void ) ;
|
||||
|
||||
// The following headers are for C++ only compilation
|
||||
#ifdef __cplusplus
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#endif
|
||||
|
||||
#include "delay.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "Uart.h"
|
||||
#include "Uart.h"
|
||||
#endif
|
||||
|
||||
// Include board variant
|
||||
@ -101,7 +101,7 @@ void loop( void ) ;
|
||||
#ifndef __cplusplus
|
||||
// undefine stdlib's abs if encountered
|
||||
#ifdef abs
|
||||
#undef abs
|
||||
#undef abs
|
||||
#endif // abs
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
@ -115,13 +115,13 @@ void loop( void ) ;
|
||||
template<class T, class L>
|
||||
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (b < a) ? b : a;
|
||||
return (b < a) ? b : a;
|
||||
}
|
||||
|
||||
template<class T, class L>
|
||||
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (a < b) ? b : a;
|
||||
return (a < b) ? b : a;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -143,13 +143,13 @@ auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
#define bit(b) (1UL << (b))
|
||||
|
||||
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
#endif
|
||||
|
||||
// Allows publishing the Beta core under samd-beta / arduino organization
|
||||
#ifndef ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#endif
|
||||
|
||||
// USB Device
|
||||
@ -159,7 +159,7 @@ auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
#include "USB/USB_host.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "USB/CDC.h"
|
||||
#include "USB/CDC.h"
|
||||
#endif
|
||||
|
||||
#endif // Arduino_h
|
||||
|
@ -58,7 +58,7 @@ compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
# this can be overridden in boards.txt
|
||||
build.extra_flags=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
|
@ -75,19 +75,19 @@ void loop( void ) ;
|
||||
|
||||
// The following headers are for C++ only compilation
|
||||
#ifdef __cplusplus
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#include "WCharacter.h"
|
||||
#include "WString.h"
|
||||
#include "Tone.h"
|
||||
#include "WMath.h"
|
||||
#include "HardwareSerial.h"
|
||||
#include "pulse.h"
|
||||
#include <bits/stl_algobase.h>
|
||||
#endif
|
||||
|
||||
#include "delay.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "Uart.h"
|
||||
#include "Uart.h"
|
||||
#endif
|
||||
|
||||
// Include board variant
|
||||
@ -101,7 +101,7 @@ void loop( void ) ;
|
||||
#ifndef __cplusplus
|
||||
// undefine stdlib's abs if encountered
|
||||
#ifdef abs
|
||||
#undef abs
|
||||
#undef abs
|
||||
#endif // abs
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
@ -115,13 +115,13 @@ void loop( void ) ;
|
||||
template<class T, class L>
|
||||
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (b < a) ? b : a;
|
||||
return (b < a) ? b : a;
|
||||
}
|
||||
|
||||
template<class T, class L>
|
||||
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
{
|
||||
return (a < b) ? b : a;
|
||||
return (a < b) ? b : a;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -143,13 +143,13 @@ auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
#define bit(b) (1UL << (b))
|
||||
|
||||
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
// Interrupts
|
||||
#define digitalPinToInterrupt(P) ( P )
|
||||
#endif
|
||||
|
||||
// Allows publishing the Beta core under samd-beta / arduino organization
|
||||
#ifndef ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#define ARDUINO_ARCH_SAMD
|
||||
#endif
|
||||
|
||||
// USB Device
|
||||
@ -159,7 +159,7 @@ auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
|
||||
#include "USB/USB_host.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "USB/CDC.h"
|
||||
#include "USB/CDC.h"
|
||||
#endif
|
||||
|
||||
#endif // Arduino_h
|
||||
|
@ -58,7 +58,7 @@ compiler.size.cmd=arm-none-eabi-size
|
||||
compiler.define=-DARDUINO=
|
||||
compiler.readelf.cmd=arm-none-eabi-readelf
|
||||
|
||||
# this can be overriden in boards.txt
|
||||
# this can be overridden in boards.txt
|
||||
build.extra_flags=
|
||||
|
||||
# These can be overridden in platform.local.txt
|
||||
|
Reference in New Issue
Block a user