mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
time: import IANA timezone definitions, expose SNTP API (#6373)
* time: import IANA timezone definitions - `configTime("timezone", "ntp servers...")` added - timezone definitions by country/cities (TZ.h) - script to update timezone definitions - updated example * fix former configTime non-matching signature * +include * example: add scheduled function in callback * crlf fix * +missing license for napt * SNTP: expose configuration helpers * update submodule * update precompiled libraries * optional: change SNTP startup delay * makes SNTP_UPDATE_DELAY a weak function update example fix for lwip1.4 * on the proper use of polledTimeout api... thanks @mcspr :] * improve update script (per review) * update lwIP submodule * update submodule * hide harmless shell message * update the release process by asking first to update TZ.h [ci skip] * minor update in release documentation * update in release documentation * update in release documentation * clarify release documentation * fix release documentation - sorry for the noise :( * fixes per review * example style * useless variable in example * update lwip2 submodule reference, to include espressif missing declaration fixes
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Submodule tools/sdk/lwip2/builder updated: ffa962483c...354887a25f
@ -1,130 +1,130 @@
|
||||
|
||||
// adapted from dhcpserver.c distributed in esp8266 sdk 2.0.0
|
||||
// same license may apply
|
||||
|
||||
#ifndef __DHCPS_H__
|
||||
#define __DHCPS_H__
|
||||
|
||||
#include "glue.h" // for UDEBUG
|
||||
|
||||
#define USE_DNS
|
||||
|
||||
typedef struct dhcps_state{
|
||||
sint16_t state;
|
||||
} dhcps_state;
|
||||
|
||||
typedef struct dhcps_msg {
|
||||
uint8_t op, htype, hlen, hops;
|
||||
uint8_t xid[4];
|
||||
uint16_t secs, flags;
|
||||
uint8_t ciaddr[4];
|
||||
uint8_t yiaddr[4];
|
||||
uint8_t siaddr[4];
|
||||
uint8_t giaddr[4];
|
||||
uint8_t chaddr[16];
|
||||
uint8_t sname[64];
|
||||
uint8_t file[128];
|
||||
uint8_t options[312];
|
||||
}dhcps_msg;
|
||||
|
||||
#ifndef LWIP_OPEN_SRC
|
||||
struct dhcps_lease {
|
||||
bool enable;
|
||||
struct ipv4_addr start_ip;
|
||||
struct ipv4_addr end_ip;
|
||||
};
|
||||
|
||||
enum dhcps_offer_option{
|
||||
OFFER_START = 0x00,
|
||||
OFFER_ROUTER = 0x01,
|
||||
OFFER_END
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
DHCPS_TYPE_DYNAMIC,
|
||||
DHCPS_TYPE_STATIC
|
||||
} dhcps_type_t;
|
||||
|
||||
typedef enum {
|
||||
DHCPS_STATE_ONLINE,
|
||||
DHCPS_STATE_OFFLINE
|
||||
} dhcps_state_t;
|
||||
|
||||
struct dhcps_pool{
|
||||
struct ipv4_addr ip;
|
||||
uint8 mac[6];
|
||||
uint32 lease_timer;
|
||||
dhcps_type_t type;
|
||||
dhcps_state_t state;
|
||||
|
||||
};
|
||||
|
||||
typedef struct _list_node{
|
||||
void *pnode;
|
||||
struct _list_node *pnext;
|
||||
}list_node;
|
||||
|
||||
extern uint32 dhcps_lease_time;
|
||||
#define DHCPS_LEASE_TIMER dhcps_lease_time //0x05A0
|
||||
#define DHCPS_MAX_LEASE 0x64
|
||||
#define BOOTP_BROADCAST 0x8000
|
||||
|
||||
#define DHCP_REQUEST 1
|
||||
#define DHCP_REPLY 2
|
||||
#define DHCP_HTYPE_ETHERNET 1
|
||||
#define DHCP_HLEN_ETHERNET 6
|
||||
#define DHCP_MSG_LEN 236
|
||||
|
||||
#define DHCPS_SERVER_PORT 67
|
||||
#define DHCPS_CLIENT_PORT 68
|
||||
|
||||
#define DHCPDISCOVER 1
|
||||
#define DHCPOFFER 2
|
||||
#define DHCPREQUEST 3
|
||||
#define DHCPDECLINE 4
|
||||
#define DHCPACK 5
|
||||
#define DHCPNAK 6
|
||||
#define DHCPRELEASE 7
|
||||
|
||||
#define DHCP_OPTION_SUBNET_MASK 1
|
||||
#define DHCP_OPTION_ROUTER 3
|
||||
#define DHCP_OPTION_DNS_SERVER 6
|
||||
#define DHCP_OPTION_REQ_IPADDR 50
|
||||
#define DHCP_OPTION_LEASE_TIME 51
|
||||
#define DHCP_OPTION_MSG_TYPE 53
|
||||
#define DHCP_OPTION_SERVER_ID 54
|
||||
#define DHCP_OPTION_INTERFACE_MTU 26
|
||||
#define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31
|
||||
#define DHCP_OPTION_BROADCAST_ADDRESS 28
|
||||
#define DHCP_OPTION_REQ_LIST 55
|
||||
#define DHCP_OPTION_END 255
|
||||
|
||||
//#define USE_CLASS_B_NET 1
|
||||
#define DHCPS_DEBUG UDEBUG
|
||||
#define MAX_STATION_NUM 8
|
||||
|
||||
#define DHCPS_STATE_OFFER 1
|
||||
#define DHCPS_STATE_DECLINE 2
|
||||
#define DHCPS_STATE_ACK 3
|
||||
#define DHCPS_STATE_NAK 4
|
||||
#define DHCPS_STATE_IDLE 5
|
||||
#define DHCPS_STATE_RELEASE 6
|
||||
|
||||
#define dhcps_router_enabled(offer) ((offer & OFFER_ROUTER) != 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void dhcps_set_dns (int num, const ipv4_addr_t* dns);
|
||||
|
||||
void dhcps_start(struct ip_info *info);
|
||||
void dhcps_stop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// adapted from dhcpserver.c distributed in esp8266 sdk 2.0.0
|
||||
// same license may apply
|
||||
|
||||
#ifndef __DHCPS_H__
|
||||
#define __DHCPS_H__
|
||||
|
||||
#include "glue.h" // for UDEBUG
|
||||
|
||||
#define USE_DNS
|
||||
|
||||
typedef struct dhcps_state{
|
||||
sint16_t state;
|
||||
} dhcps_state;
|
||||
|
||||
typedef struct dhcps_msg {
|
||||
uint8_t op, htype, hlen, hops;
|
||||
uint8_t xid[4];
|
||||
uint16_t secs, flags;
|
||||
uint8_t ciaddr[4];
|
||||
uint8_t yiaddr[4];
|
||||
uint8_t siaddr[4];
|
||||
uint8_t giaddr[4];
|
||||
uint8_t chaddr[16];
|
||||
uint8_t sname[64];
|
||||
uint8_t file[128];
|
||||
uint8_t options[312];
|
||||
}dhcps_msg;
|
||||
|
||||
#ifndef LWIP_OPEN_SRC
|
||||
struct dhcps_lease {
|
||||
bool enable;
|
||||
struct ipv4_addr start_ip;
|
||||
struct ipv4_addr end_ip;
|
||||
};
|
||||
|
||||
enum dhcps_offer_option{
|
||||
OFFER_START = 0x00,
|
||||
OFFER_ROUTER = 0x01,
|
||||
OFFER_END
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
DHCPS_TYPE_DYNAMIC,
|
||||
DHCPS_TYPE_STATIC
|
||||
} dhcps_type_t;
|
||||
|
||||
typedef enum {
|
||||
DHCPS_STATE_ONLINE,
|
||||
DHCPS_STATE_OFFLINE
|
||||
} dhcps_state_t;
|
||||
|
||||
struct dhcps_pool{
|
||||
struct ipv4_addr ip;
|
||||
uint8 mac[6];
|
||||
uint32 lease_timer;
|
||||
dhcps_type_t type;
|
||||
dhcps_state_t state;
|
||||
|
||||
};
|
||||
|
||||
typedef struct _list_node{
|
||||
void *pnode;
|
||||
struct _list_node *pnext;
|
||||
}list_node;
|
||||
|
||||
extern uint32 dhcps_lease_time;
|
||||
#define DHCPS_LEASE_TIMER dhcps_lease_time //0x05A0
|
||||
#define DHCPS_MAX_LEASE 0x64
|
||||
#define BOOTP_BROADCAST 0x8000
|
||||
|
||||
#define DHCP_REQUEST 1
|
||||
#define DHCP_REPLY 2
|
||||
#define DHCP_HTYPE_ETHERNET 1
|
||||
#define DHCP_HLEN_ETHERNET 6
|
||||
#define DHCP_MSG_LEN 236
|
||||
|
||||
#define DHCPS_SERVER_PORT 67
|
||||
#define DHCPS_CLIENT_PORT 68
|
||||
|
||||
#define DHCPDISCOVER 1
|
||||
#define DHCPOFFER 2
|
||||
#define DHCPREQUEST 3
|
||||
#define DHCPDECLINE 4
|
||||
#define DHCPACK 5
|
||||
#define DHCPNAK 6
|
||||
#define DHCPRELEASE 7
|
||||
|
||||
#define DHCP_OPTION_SUBNET_MASK 1
|
||||
#define DHCP_OPTION_ROUTER 3
|
||||
#define DHCP_OPTION_DNS_SERVER 6
|
||||
#define DHCP_OPTION_REQ_IPADDR 50
|
||||
#define DHCP_OPTION_LEASE_TIME 51
|
||||
#define DHCP_OPTION_MSG_TYPE 53
|
||||
#define DHCP_OPTION_SERVER_ID 54
|
||||
#define DHCP_OPTION_INTERFACE_MTU 26
|
||||
#define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31
|
||||
#define DHCP_OPTION_BROADCAST_ADDRESS 28
|
||||
#define DHCP_OPTION_REQ_LIST 55
|
||||
#define DHCP_OPTION_END 255
|
||||
|
||||
//#define USE_CLASS_B_NET 1
|
||||
#define DHCPS_DEBUG UDEBUG
|
||||
#define MAX_STATION_NUM 8
|
||||
|
||||
#define DHCPS_STATE_OFFER 1
|
||||
#define DHCPS_STATE_DECLINE 2
|
||||
#define DHCPS_STATE_ACK 3
|
||||
#define DHCPS_STATE_NAK 4
|
||||
#define DHCPS_STATE_IDLE 5
|
||||
#define DHCPS_STATE_RELEASE 6
|
||||
|
||||
#define dhcps_router_enabled(offer) ((offer & OFFER_ROUTER) != 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void dhcps_set_dns (int num, const ipv4_addr_t* dns);
|
||||
|
||||
void dhcps_start(struct ip_info *info);
|
||||
void dhcps_stop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -8,3 +8,4 @@ typedef unsigned long u32_t;
|
||||
typedef signed long s32_t;
|
||||
typedef unsigned long mem_ptr_t;
|
||||
#define LWIP_ERR_T s32_t
|
||||
typedef uint32_t sys_prot_t;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// generated by makefiles/make-lwip2-hash
|
||||
#ifndef LWIP_HASH_H
|
||||
#define LWIP_HASH_H
|
||||
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.2-8-g7958710"
|
||||
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.2-16-ge23a07e"
|
||||
#endif // LWIP_HASH_H
|
||||
|
@ -1,3 +1,40 @@
|
||||
/**
|
||||
* @file
|
||||
* Network Address and Port Translation
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016-2019 NeoCat <neocat@neocat.jp>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: NeoCat <neocat@neocat.jp>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LWIP_NAPT_H__
|
||||
#define __LWIP_NAPT_H__
|
||||
|
||||
|
@ -3545,6 +3545,9 @@
|
||||
#error LWIP_FEATURES must be defined
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TCP_RANDOM_PORT: randomize port instead of simply increasing
|
||||
@ -3561,27 +3564,34 @@
|
||||
// so we do not define it. sntp server can come from dhcp server, or by
|
||||
// user.
|
||||
//#define SNTP_SERVER_ADDRESS "pool.ntp.org" // default
|
||||
//#define SNTP_GET_SERVERS_FROM_DHCP // implicitely enabled by LWIP_DHCP_GET_NTP_SRV
|
||||
//#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_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_SUPPRESS_DELAY_CHECK 1
|
||||
#define SNTP_UPDATE_DELAY_DEFAULT 3600000 // update delay defined by a default weak function
|
||||
#define SNTP_UPDATE_DELAY sntp_update_delay_MS_rfc_not_less_than_15000()
|
||||
extern uint32_t SNTP_UPDATE_DELAY;
|
||||
|
||||
#if LWIP_FEATURES
|
||||
// lwip-1.4 had 3 possible SNTP servers (constant was harcoded)
|
||||
// esp8266/arduino/lwip-1.4 had 3 possible SNTP servers (constant was harcoded)
|
||||
#define SNTP_MAX_SERVERS 3
|
||||
#endif
|
||||
|
||||
// turn off random delay before sntp request
|
||||
// when SNTP_STARTUP_DELAY is not defined,
|
||||
// LWIP_RAND is used to set a delay
|
||||
// no delay by default before sntp request
|
||||
// https://github.com/esp8266/Arduino/pull/5564
|
||||
// from sntp_opts.h:
|
||||
/** According to the RFC, this shall be a random delay
|
||||
* between 1 and 5 minutes (in milliseconds) to prevent load peaks.
|
||||
* This can be defined to a random generation function,
|
||||
* which must return the delay in milliseconds as u32_t.
|
||||
*/
|
||||
#define SNTP_STARTUP_DELAY 0
|
||||
#define SNTP_STARTUP_DELAY 1 // enable startup delay
|
||||
#define SNTP_STARTUP_DELAY_FUNC_DEFAULT 0 // to 0 by default via a default weak function
|
||||
#define SNTP_STARTUP_DELAY_FUNC sntp_startup_delay_MS_rfc_not_less_than_60000()
|
||||
extern uint32_t SNTP_STARTUP_DELAY_FUNC;
|
||||
|
||||
/*
|
||||
--------------------------------------------------
|
||||
@ -3633,4 +3643,8 @@ void tcp_kill_timewait (void);
|
||||
#define MEMP_NUM_TCP_PCB_TIME_WAIT 5
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // MYLWIPOPTS_H
|
||||
|
Reference in New Issue
Block a user