IDF release/v3.3 (#3339)

* IDF release/v3.3 46b12a560

* fix build

* IDF release/v3.3 367c3c09c
This commit is contained in:
Me No Dev
2020-01-20 22:07:04 +02:00
committed by GitHub
parent 307b1368dd
commit 1977370e6f
282 changed files with 13004 additions and 4377 deletions

View File

@ -1,3 +1,3 @@
#pragma once
#warning "This header file is deprecated, please include lwip/apps/sntp.h instead."
#include "lwip/apps/sntp.h"
#warning "This header file is deprecated, please include esp_sntp.h instead."
#include "esp_sntp.h"

View File

@ -0,0 +1,22 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __ESP_SNTP_H__
#define __ESP_SNTP_H__
#include "lwip/err.h"
#include "lwip/apps/sntp.h"
#include "sntp.h"
#endif // __ESP_SNTP_H__

View File

@ -89,12 +89,21 @@ struct dhcp
struct dhcp_msg *msg_out; /* outgoing msg */
u16_t options_out_len; /* outgoing msg options length */
u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */
#if ESP_DHCP_TIMER
u32_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */
u32_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */
u32_t t1_renew_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next renew try */
u32_t t2_rebind_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next rebind try */
u32_t lease_used; /* #ticks with period DHCP_COARSE_TIMER_SECS since last received DHCP ack */
u32_t t0_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for lease time */
#else
u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */
u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */
u16_t t1_renew_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next renew try */
u16_t t2_rebind_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next rebind try */
u16_t lease_used; /* #ticks with period DHCP_COARSE_TIMER_SECS since last received DHCP ack */
u16_t t0_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for lease time */
#endif
ip_addr_t server_ip_addr; /* dhcp server address that offered this lease (ip_addr_t because passed to UDP) */
ip4_addr_t offered_ip_addr;
ip4_addr_t offered_sn_mask;

View File

@ -1,8 +1,8 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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,
@ -11,21 +11,21 @@
* 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.
* 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
* 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: Simon Goldschmidt
*
*/
@ -43,7 +43,7 @@
#include "esp_task.h"
#include "esp_system.h"
#include "sdkconfig.h"
#include "sntp.h"
#include "netif/dhcp_state.h"
/* Enable all Espressif-only options */
@ -316,7 +316,7 @@
* scenario happens: 192.168.0.2 -> 0.0.0.0 -> 192.168.0.2 or 192.168.0.2 -> 0.0.0.0
*/
#define ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES
#define ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES
/*
* LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all
* events (accept, sent, etc) that happen in the system.
@ -525,6 +525,13 @@
*/
#define LWIP_SO_SNDTIMEO 1
/**
* LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS==1: randomize the local port for the first
* local TCP/UDP pcb (default==0). This can prevent creating predictable port
* numbers after booting a device.
*/
#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS CONFIG_LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS
/**
* LWIP_SO_RCVTIMEO==1: Enable receive timeout for sockets/netconns and
* SO_RCVTIMEO processing.
@ -589,6 +596,11 @@
#if PPP_SUPPORT
/**
* PPP_NOTIFY_PHASE==1: Support PPP notify phase.
*/
#define PPP_NOTIFY_PHASE CONFIG_PPP_NOTIFY_PHASE_SUPPORT
/**
* PAP_SUPPORT==1: Support PAP.
*/
@ -754,7 +766,6 @@
#define ESP_DNS 1
#define ESP_IPV6_AUTOCONFIG 1
#define ESP_PERF 0
#define ESP_RANDOM_TCP_PORT 1
#define ESP_IP4_ATON 1
#define ESP_LIGHT_SLEEP 1
#define ESP_L2_TO_L3_COPY CONFIG_L2_TO_L3_COPY
@ -769,11 +780,10 @@
#define ESP_AUTO_RECV 1
#define ESP_GRATUITOUS_ARP CONFIG_ESP_GRATUITOUS_ARP
#if CONFIG_LWIP_IRAM_OPTIMIZATION
#define ESP_IRAM_ATTR IRAM_ATTR
#else
#define ESP_IRAM_ATTR
#ifdef ESP_IRAM_ATTR
#undef ESP_IRAM_ATTR
#endif
#define ESP_IRAM_ATTR
#if ESP_PERF
#define DBG_PERF_PATH_SET(dir, point)
@ -795,7 +805,7 @@ enum {
};
#else
#define DBG_PERF_PATH_SET(dir, point)
#define DBG_PERF_PATH_SET(dir, point)
#define DBG_PERF_FILTER_LEN 1000
#endif
@ -829,10 +839,20 @@ enum {
#define LWIP_DHCP_MAX_NTP_SERVERS CONFIG_LWIP_DHCP_MAX_NTP_SERVERS
#define LWIP_TIMEVAL_PRIVATE 0
/*
--------------------------------------
------------ SNTP options ------------
--------------------------------------
*/
/*
* SNTP update delay - in milliseconds
*/
#define SNTP_UPDATE_DELAY CONFIG_LWIP_SNTP_UPDATE_DELAY
#define SNTP_SET_SYSTEM_TIME_US(sec, us) \
do { \
struct timeval tv = { .tv_sec = sec, .tv_usec = us }; \
settimeofday(&tv, NULL); \
sntp_sync_time(&tv); \
} while (0);
#define SNTP_GET_SYSTEM_TIME(sec, us) \
@ -841,6 +861,7 @@ enum {
gettimeofday(&tv, NULL); \
(sec) = tv.tv_sec; \
(us) = tv.tv_usec; \
sntp_set_sync_status(SNTP_SYNC_STATUS_RESET); \
} while (0);
#define SOC_SEND_LOG //printf

View File

@ -0,0 +1,127 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __SNTP_H__
#define __SNTP_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
* The time update takes place in the sntp_sync_time() function.
* The user has the ability to redefine this function in order
* to re-define its functionality. This function has two time update modes,
* which can be set via the sntp_set_sync_mode() function.
* Two modes are available:
* - the first is an immediate update when receiving time from the sntp server,
* - the second is a smooth time update (if the time error is no more than 35 minutes,
* and an immediate update if the error is more than 35 minutes).
*
* To receive notification of time synchronization,
* you can use the callback function or get the synchronization status
* via the sntp_get_sync_status() function.
*
* To determine the time synchronization time on the device, you can use:
* 1) sntp_set_time_sync_notification_cb() function to set the callback function,
* which is convenient to use to receive notification of the update time.
* 2) sntp_get_sync_status() function for getting time synchronization status.
* After the time synchronization is completed, the status will be
* SNTP_SYNC_STATUS_COMPLETED, after, it will be reseted to SNTP_SYNC_STATUS_RESET
* to wait for the next sync cycle.
*/
/// SNTP time update mode
typedef enum {
SNTP_SYNC_MODE_IMMED, /*!< Update system time immediately when receiving a response from the SNTP server. */
SNTP_SYNC_MODE_SMOOTH, /*!< Smooth time updating. Time error is gradually reduced using adjtime function. If the difference between SNTP response time and system time is large (more than 35 minutes) then update immediately. */
} sntp_sync_mode_t;
/// SNTP sync status
typedef enum {
SNTP_SYNC_STATUS_RESET, // Reset status.
SNTP_SYNC_STATUS_COMPLETED, // Time is synchronized.
SNTP_SYNC_STATUS_IN_PROGRESS, // Smooth time sync in progress.
} sntp_sync_status_t;
/**
* @brief SNTP callback function for notifying about time sync event
*
* @param tv Time received from SNTP server.
*/
typedef void (*sntp_sync_time_cb_t) (struct timeval *tv);
/**
* @brief This function updates the system time.
*
* This is a weak-linked function. It is possible to replace all SNTP update functionality
* by placing a sntp_sync_time() function in the app firmware source.
* If the default implementation is used, calling sntp_set_sync_mode() allows
* the time synchronization mode to be changed to instant or smooth.
* If a callback function is registered via sntp_set_time_sync_notification_cb(),
* it will be called following time synchronization.
*
* @param tv Time received from SNTP server.
*/
void sntp_sync_time(struct timeval *tv);
/**
* @brief Set the sync mode
*
* Allowable two mode: SNTP_SYNC_MODE_IMMED and SNTP_SYNC_MODE_SMOOTH.
* @param sync_mode Sync mode.
*/
void sntp_set_sync_mode(sntp_sync_mode_t sync_mode);
/**
* @brief Get set sync mode
*
* @return SNTP_SYNC_MODE_IMMED: Update time immediately.
* SNTP_SYNC_MODE_SMOOTH: Smooth time updating.
*/
sntp_sync_mode_t sntp_get_sync_mode(void);
/**
* @brief Get status of time sync
*
* After the update is completed, the status will be returned as SNTP_SYNC_STATUS_COMPLETED.
* After that, the status will be reset to SNTP_SYNC_STATUS_RESET.
* If the update operation is not completed yet, the status will be SNTP_SYNC_STATUS_RESET.
* If a smooth mode was chosen and the synchronization is still continuing (adjtime works), then it will be SNTP_SYNC_STATUS_IN_PROGRESS.
*
* @return SNTP_SYNC_STATUS_RESET: Reset status.
* SNTP_SYNC_STATUS_COMPLETED: Time is synchronized.
* SNTP_SYNC_STATUS_IN_PROGRESS: Smooth time sync in progress.
*/
sntp_sync_status_t sntp_get_sync_status(void);
/**
* @brief Set status of time sync
*
* @param sync_status status of time sync (see sntp_sync_status_t)
*/
void sntp_set_sync_status(sntp_sync_status_t sync_status);
/**
* @brief Set a callback function for time synchronization notification
*
* @param callback a callback function
*/
void sntp_set_time_sync_notification_cb(sntp_sync_time_cb_t callback);
#ifdef __cplusplus
}
#endif
#endif // __SNTP_H__

View File

@ -0,0 +1,127 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __SNTP_H__
#define __SNTP_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
* The time update takes place in the sntp_sync_time() function.
* The user has the ability to redefine this function in order
* to re-define its functionality. This function has two time update modes,
* which can be set via the sntp_set_sync_mode() function.
* Two modes are available:
* - the first is an immediate update when receiving time from the sntp server,
* - the second is a smooth time update (if the time error is no more than 35 minutes,
* and an immediate update if the error is more than 35 minutes).
*
* To receive notification of time synchronization,
* you can use the callback function or get the synchronization status
* via the sntp_get_sync_status() function.
*
* To determine the time synchronization time on the device, you can use:
* 1) sntp_set_time_sync_notification_cb() function to set the callback function,
* which is convenient to use to receive notification of the update time.
* 2) sntp_get_sync_status() function for getting time synchronization status.
* After the time synchronization is completed, the status will be
* SNTP_SYNC_STATUS_COMPLETED, after, it will be reseted to SNTP_SYNC_STATUS_RESET
* to wait for the next sync cycle.
*/
/// SNTP time update mode
typedef enum {
SNTP_SYNC_MODE_IMMED, /*!< Update system time immediately when receiving a response from the SNTP server. */
SNTP_SYNC_MODE_SMOOTH, /*!< Smooth time updating. Time error is gradually reduced using adjtime function. If the difference between SNTP response time and system time is large (more than 35 minutes) then update immediately. */
} sntp_sync_mode_t;
/// SNTP sync status
typedef enum {
SNTP_SYNC_STATUS_RESET, // Reset status.
SNTP_SYNC_STATUS_COMPLETED, // Time is synchronized.
SNTP_SYNC_STATUS_IN_PROGRESS, // Smooth time sync in progress.
} sntp_sync_status_t;
/**
* @brief SNTP callback function for notifying about time sync event
*
* @param tv Time received from SNTP server.
*/
typedef void (*sntp_sync_time_cb_t) (struct timeval *tv);
/**
* @brief This function updates the system time.
*
* This is a weak-linked function. It is possible to replace all SNTP update functionality
* by placing a sntp_sync_time() function in the app firmware source.
* If the default implementation is used, calling sntp_set_sync_mode() allows
* the time synchronization mode to be changed to instant or smooth.
* If a callback function is registered via sntp_set_time_sync_notification_cb(),
* it will be called following time synchronization.
*
* @param tv Time received from SNTP server.
*/
void sntp_sync_time(struct timeval *tv);
/**
* @brief Set the sync mode
*
* Allowable two mode: SNTP_SYNC_MODE_IMMED and SNTP_SYNC_MODE_SMOOTH.
* @param sync_mode Sync mode.
*/
void sntp_set_sync_mode(sntp_sync_mode_t sync_mode);
/**
* @brief Get set sync mode
*
* @return SNTP_SYNC_MODE_IMMED: Update time immediately.
* SNTP_SYNC_MODE_SMOOTH: Smooth time updating.
*/
sntp_sync_mode_t sntp_get_sync_mode(void);
/**
* @brief Get status of time sync
*
* After the update is completed, the status will be returned as SNTP_SYNC_STATUS_COMPLETED.
* After that, the status will be reset to SNTP_SYNC_STATUS_RESET.
* If the update operation is not completed yet, the status will be SNTP_SYNC_STATUS_RESET.
* If a smooth mode was chosen and the synchronization is still continuing (adjtime works), then it will be SNTP_SYNC_STATUS_IN_PROGRESS.
*
* @return SNTP_SYNC_STATUS_RESET: Reset status.
* SNTP_SYNC_STATUS_COMPLETED: Time is synchronized.
* SNTP_SYNC_STATUS_IN_PROGRESS: Smooth time sync in progress.
*/
sntp_sync_status_t sntp_get_sync_status(void);
/**
* @brief Set status of time sync
*
* @param sync_status status of time sync (see sntp_sync_status_t)
*/
void sntp_set_sync_status(sntp_sync_status_t sync_status);
/**
* @brief Set a callback function for time synchronization notification
*
* @param callback a callback function
*/
void sntp_set_time_sync_notification_cb(sntp_sync_time_cb_t callback);
#ifdef __cplusplus
}
#endif
#endif // __SNTP_H__