mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
lwip2: 3 sntp servers, autoip (169.254), esp-ping, espconn (#5444)
* lwip2: better handling of ipv4_addr/t type + 3 sntp servers * bump lwip2 version * Only with FEATURES=1: 3 sntp servers and AutoIP enabled (169.254 when dhcp server fails) * Only with FEATURES=1: 3 sntp servers and AutoIP enabled (169.254 when dhcp server fails) * local CI runner: select build type * new ipv4_addr/t definition makes things easier for IPAddress * update local CI runner * lwip2 changes * lwip2: port esp-ping and espconn
This commit is contained in:
parent
6d42a26cc2
commit
0db6ec4ba8
@ -152,11 +152,6 @@ class IPAddress: public Printable {
|
|||||||
IPAddress(const ipv4_addr* fw_addr) { setV4(); v4() = fw_addr->addr; }
|
IPAddress(const ipv4_addr* fw_addr) { setV4(); v4() = fw_addr->addr; }
|
||||||
IPAddress(const ip_addr_t& lwip_addr) { _ip = lwip_addr; }
|
IPAddress(const ip_addr_t& lwip_addr) { _ip = lwip_addr; }
|
||||||
|
|
||||||
#if LWIP_VERSION_MAJOR != 1
|
|
||||||
IPAddress(ipv4_addr fw_addr) { setV4(); v4() = fw_addr.addr; }
|
|
||||||
IPAddress(const ip_addr_t* lwip_addr) { _ip = *lwip_addr; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
operator ip_addr_t () const { return _ip; }
|
operator ip_addr_t () const { return _ip; }
|
||||||
operator const ip_addr_t*() const { return &_ip; }
|
operator const ip_addr_t*() const { return &_ip; }
|
||||||
operator ip_addr_t*() { return &_ip; }
|
operator ip_addr_t*() { return &_ip; }
|
||||||
|
@ -47,4 +47,37 @@ if [ "$branch" != "$branch" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
rm -rf arduino_ide arduino-nightly Arduino/libraries/ArduinoJson
|
rm -rf arduino_ide arduino-nightly Arduino/libraries/ArduinoJson
|
||||||
HOME=${TMPCI} TRAVIS_BUILD_DIR=${TMPCI} BUILD_TYPE=build tests/common.sh
|
|
||||||
|
while true; do
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
Which build?
|
||||||
|
1. main
|
||||||
|
2. debug even
|
||||||
|
3. debug odd
|
||||||
|
4. platformio
|
||||||
|
5. package
|
||||||
|
6. host
|
||||||
|
7. style
|
||||||
|
EOF
|
||||||
|
|
||||||
|
read ans
|
||||||
|
|
||||||
|
BUILD_TYPE=""
|
||||||
|
case "$ans" in
|
||||||
|
1) BUILD_TYPE=build;;
|
||||||
|
2) BUILD_TYPE=debug_even;;
|
||||||
|
3) BUILD_TYPE=debug_odd;;
|
||||||
|
4) BUILD_TYPE=platformio;;
|
||||||
|
5) BUILD_TYPE=package;;
|
||||||
|
6) BUILD_TYPE=host;;
|
||||||
|
7) BUILD_TYPE=style;;
|
||||||
|
esac
|
||||||
|
test -z "$BUILD_TYPE" || break
|
||||||
|
done
|
||||||
|
|
||||||
|
# use pip2 for python2 with python3 is around, platformio doesn't like it
|
||||||
|
cp tests/common.sh tests/common-custom.sh
|
||||||
|
sed -i 's,pip ,pip2 ,g' tests/common-custom.sh
|
||||||
|
|
||||||
|
HOME=${TMPCI} TRAVIS_BUILD_DIR=${TMPCI} BUILD_TYPE=$BUILD_TYPE tests/common-custom.sh
|
||||||
|
@ -26,23 +26,12 @@
|
|||||||
#define __IP_ADDR_H__
|
#define __IP_ADDR_H__
|
||||||
|
|
||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
|
#include "ipv4_addr.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ipv4_addr {
|
|
||||||
uint32 addr;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct ipv4_addr ipv4_addr_t;
|
|
||||||
|
|
||||||
struct ip_info {
|
|
||||||
struct ipv4_addr ip;
|
|
||||||
struct ipv4_addr netmask;
|
|
||||||
struct ipv4_addr gw;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if two address are on the same network.
|
* Determine if two address are on the same network.
|
||||||
*
|
*
|
||||||
|
61
tools/sdk/include/ipv4_addr.h
Normal file
61
tools/sdk/include/ipv4_addr.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* ESPRESSIF MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
|
||||||
|
* it is free of charge, to any person obtaining a copy of this software and associated
|
||||||
|
* documentation files (the "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
|
||||||
|
* to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or
|
||||||
|
* substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __IPV4_ADDR_H__
|
||||||
|
#define __IPV4_ADDR_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <lwip/init.h>
|
||||||
|
|
||||||
|
// ipv4_addr is necessary for lwIP-v2 because
|
||||||
|
// - espressif binary firmware is IPv4 only, under the name of ip_addr/_t
|
||||||
|
// - ip_addr/_t is different when IPv6 is enabled with lwIP-v2
|
||||||
|
// hence ipv4_addr/t is IPv4 version/copy of IPv4 ip_addr/_t
|
||||||
|
// when IPv6 is enabled so we can deal with IPv4 use from firmware API.
|
||||||
|
|
||||||
|
// official lwIP's definitions (1.4 or 2)
|
||||||
|
#include "lwip/ip_addr.h"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////
|
||||||
|
#if LWIP_VERSION_MAJOR == 1
|
||||||
|
|
||||||
|
#define ipv4_addr ip_addr
|
||||||
|
|
||||||
|
///////////////////////////////////////////////
|
||||||
|
#else // lwIP-v2
|
||||||
|
|
||||||
|
#define ipv4_addr ip4_addr
|
||||||
|
#define ipv4_addr_t ip4_addr_t
|
||||||
|
|
||||||
|
// defined in lwip-v1.4 sources only, used in fw
|
||||||
|
struct ip_info {
|
||||||
|
struct ipv4_addr ip;
|
||||||
|
struct ipv4_addr netmask;
|
||||||
|
struct ipv4_addr gw;
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////
|
||||||
|
#endif // lwIP-v2
|
||||||
|
|
||||||
|
#endif // __IPV4_ADDR_H__
|
@ -28,14 +28,7 @@
|
|||||||
#include "os_type.h"
|
#include "os_type.h"
|
||||||
#ifdef LWIP_OPEN_SRC
|
#ifdef LWIP_OPEN_SRC
|
||||||
|
|
||||||
#include "lwip/init.h"
|
#include "ipv4_addr.h"
|
||||||
#if LWIP_VERSION_MAJOR == 1
|
|
||||||
#define ipv4_addr ip_addr
|
|
||||||
#endif
|
|
||||||
#include "lwip/ip_addr.h"
|
|
||||||
#if LWIP_VERSION_MAJOR != 1
|
|
||||||
typedef struct ip4_addr ipv4_addr_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error LWIP_OPEN_SRC must be defined
|
#error LWIP_OPEN_SRC must be defined
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
|||||||
Subproject commit fab2c912f3e419ac0b218664f6ee9820e699f973
|
Subproject commit c434c6fab1cb7c670cd9a223e6667ec80a618d29
|
@ -90,15 +90,7 @@ typedef uint32_t sys_prot_t; // not really used
|
|||||||
ip4_addr3_16(ipaddr), \
|
ip4_addr3_16(ipaddr), \
|
||||||
ip4_addr4_16(ipaddr)
|
ip4_addr4_16(ipaddr)
|
||||||
|
|
||||||
// ipv4_addr / ip_info: do not exist in lwip2 (only in lwip1.4)
|
#include <ipv4_addr.h>
|
||||||
struct ipv4_addr {
|
|
||||||
uint32_t addr;
|
|
||||||
};
|
|
||||||
struct ip_info {
|
|
||||||
struct ipv4_addr ip;
|
|
||||||
struct ipv4_addr netmask;
|
|
||||||
struct ipv4_addr gw;
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
//// PROVIDED TO USER
|
//// PROVIDED TO USER
|
||||||
|
@ -39,6 +39,7 @@ extern "C"
|
|||||||
void (*phy_capture) (int netif_idx, const char* data, size_t len, int out, int success);
|
void (*phy_capture) (int netif_idx, const char* data, size_t len, int out, int success);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <sys/pgmspace.h>
|
||||||
|
|
||||||
#if UDEBUG && UDEBUGSTORE
|
#if UDEBUG && UDEBUGSTORE
|
||||||
#warning use 'doprint_allow=1' right after Serial is enabled
|
#warning use 'doprint_allow=1' right after Serial is enabled
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// generated by makefiles/make-lwip2-hash
|
// generated by makefiles/make-lwip2-hash
|
||||||
#ifndef LWIP_HASH_H
|
#ifndef LWIP_HASH_H
|
||||||
#define LWIP_HASH_H
|
#define LWIP_HASH_H
|
||||||
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.0"
|
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.0-4-gc434c6f"
|
||||||
#endif // LWIP_HASH_H
|
#endif // LWIP_HASH_H
|
||||||
|
@ -987,12 +987,12 @@
|
|||||||
* LWIP_AUTOIP==1: Enable AUTOIP module.
|
* LWIP_AUTOIP==1: Enable AUTOIP module.
|
||||||
*/
|
*/
|
||||||
#if !defined LWIP_AUTOIP || defined __DOXYGEN__
|
#if !defined LWIP_AUTOIP || defined __DOXYGEN__
|
||||||
#define LWIP_AUTOIP 0
|
#define LWIP_AUTOIP LWIP_FEATURES // 0
|
||||||
#endif
|
#endif
|
||||||
#if !LWIP_IPV4
|
#if !LWIP_IPV4
|
||||||
/* disable AUTOIP when IPv4 is disabled */
|
/* disable AUTOIP when IPv4 is disabled */
|
||||||
#undef LWIP_AUTOIP
|
#undef LWIP_AUTOIP
|
||||||
#define LWIP_AUTOIP 0
|
#define LWIP_AUTOIP 0
|
||||||
#endif /* !LWIP_IPV4 */
|
#endif /* !LWIP_IPV4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1000,7 +1000,7 @@
|
|||||||
* the same interface at the same time.
|
* the same interface at the same time.
|
||||||
*/
|
*/
|
||||||
#if !defined LWIP_DHCP_AUTOIP_COOP || defined __DOXYGEN__
|
#if !defined LWIP_DHCP_AUTOIP_COOP || defined __DOXYGEN__
|
||||||
#define LWIP_DHCP_AUTOIP_COOP 0
|
#define LWIP_DHCP_AUTOIP_COOP LWIP_FEATURES // 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3539,14 +3539,22 @@
|
|||||||
------------------ SNTP options ------------------
|
------------------ SNTP options ------------------
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#define SNTP_SERVER_DNS 1 // SNTP support DNS names through sntp_setservername / sntp_getservername
|
|
||||||
// if SNTP_SERVER_ADDRESS is defined, it always overrides user's config
|
// if SNTP_SERVER_ADDRESS is defined, it always overrides user's config
|
||||||
// so we do not define it. sntp server can come from dhcp server, or by
|
// so we do not define it. sntp server can come from dhcp server, or by
|
||||||
// user.
|
// user.
|
||||||
//#define SNTP_SERVER_ADDRESS "pool.ntp.org" // default
|
//#define SNTP_SERVER_ADDRESS "pool.ntp.org" // default
|
||||||
#define SNTP_GET_SERVERS_FROM_DHCP 3
|
//#define SNTP_GET_SERVERS_FROM_DHCP // implicitely enabled by LWIP_DHCP_GET_NTP_SRV
|
||||||
|
|
||||||
|
#define SNTP_SERVER_DNS 1 // enable SNTP support DNS names through sntp_setservername / sntp_getservername
|
||||||
|
|
||||||
#define SNTP_SET_SYSTEM_TIME_US(t,us) do { struct timeval tv = { t, us }; settimeofday(&tv, NULL); } while (0)
|
#define SNTP_SET_SYSTEM_TIME_US(t,us) do { struct timeval tv = { t, us }; settimeofday(&tv, NULL); } while (0)
|
||||||
|
|
||||||
|
#if LWIP_FEATURES
|
||||||
|
// lwip-1.4 had 3 possible SNTP servers (constant was harcoded)
|
||||||
|
#define SNTP_MAX_SERVERS 3
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
------------------- LOCAL FIXES ------------------
|
------------------- LOCAL FIXES ------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user