Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
96601b68
Unverified
Commit
96601b68
authored
Mar 20, 2018
by
Arnim Läuger
Committed by
GitHub
Mar 20, 2018
Browse files
Merge pull request #2269 from nwf/for-upstream-sdk22
Update to sdk 2.2
parents
be53d5c9
f3ebfa9b
Changes
24
Expand all
Show whitespace changes
Inline
Side-by-side
Makefile
View file @
96601b68
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
.NOTPARALLEL
:
.NOTPARALLEL
:
# SDK version NodeMCU is locked to
# SDK version NodeMCU is locked to
SDK_VER
:=
2.
1
.0
SDK_VER
:=
2.
2
.0
# no patch: SDK_BASE_VER equals SDK_VER and sdk dir depends on sdk_extracted
# no patch: SDK_BASE_VER equals SDK_VER and sdk dir depends on sdk_extracted
SDK_BASE_VER
:=
$(SDK_VER)
SDK_BASE_VER
:=
$(SDK_VER)
...
@@ -13,13 +13,13 @@ SDK_DIR_DEPENDS:=sdk_extracted
...
@@ -13,13 +13,13 @@ SDK_DIR_DEPENDS:=sdk_extracted
#SDK_DIR_DEPENDS:=sdk_patched
#SDK_DIR_DEPENDS:=sdk_patched
SDK_FILE_VER
:=
$(SDK_BASE_VER)
SDK_FILE_VER
:=
$(SDK_BASE_VER)
SDK_FILE_SHA1
:=
66a4272894dc1bcec19f5f8bf79fee80f60a021b
SDK_FILE_SHA1
:=
8b63f1066d3560ff77f119e8ba30a9c39e7baaad
#SDK_PATCH_VER:=$(SDK_VER)_patch_20160704
#SDK_PATCH_VER:=$(SDK_VER)_patch_20160704
#SDK_PATCH_SHA1:=388d9e91df74e3b49fca126da482cf822cf1ebf1
#SDK_PATCH_SHA1:=388d9e91df74e3b49fca126da482cf822cf1ebf1
# Ensure we search "our" SDK before the tool-chain's SDK (if any)
# Ensure we search "our" SDK before the tool-chain's SDK (if any)
TOP_DIR
:=
$(
abspath
$(
dir
$(
lastword
$(MAKEFILE_LIST)
)))
TOP_DIR
:=
$(
abspath
$(
dir
$(
lastword
$(MAKEFILE_LIST)
)))
SDK_DIR
:=
$(TOP_DIR)
/sdk/esp_iot_sdk_v
$(SDK_VER)
SDK_DIR
:=
$(TOP_DIR)
/sdk/esp_iot_sdk_v
$(SDK_VER)
CCFLAGS
:=
-I
$(TOP_DIR)
/sdk-overrides/include
-I
$(SDK_DIR)
/include
CCFLAGS
:=
-I
$(TOP_DIR)
/sdk-overrides/include
-I
$(TOP_DIR)
/app/include/lwip/app
-I
$(SDK_DIR)
/include
LDFLAGS
:=
-L
$(SDK_DIR)
/lib
-L
$(SDK_DIR)
/ld
$(LDFLAGS)
LDFLAGS
:=
-L
$(SDK_DIR)
/lib
-L
$(SDK_DIR)
/ld
$(LDFLAGS)
ifdef
DEBUG
ifdef
DEBUG
...
@@ -39,6 +39,7 @@ ifeq ($(OS),Windows_NT)
...
@@ -39,6 +39,7 @@ ifeq ($(OS),Windows_NT)
# It is xcc
# It is xcc
AR
=
xt-ar
AR
=
xt-ar
CC
=
xt-xcc
CC
=
xt-xcc
CXX
=
xt-xcc
NM
=
xt-nm
NM
=
xt-nm
CPP
=
xt-cpp
CPP
=
xt-cpp
OBJCOPY
=
xt-objcopy
OBJCOPY
=
xt-objcopy
...
@@ -50,6 +51,7 @@ ifeq ($(OS),Windows_NT)
...
@@ -50,6 +51,7 @@ ifeq ($(OS),Windows_NT)
CCFLAGS
+=
-ffunction-sections
-fno-jump-tables
-fdata-sections
CCFLAGS
+=
-ffunction-sections
-fno-jump-tables
-fdata-sections
AR
=
xtensa-lx106-elf-ar
AR
=
xtensa-lx106-elf-ar
CC
=
xtensa-lx106-elf-gcc
CC
=
xtensa-lx106-elf-gcc
CXX
=
xtensa-lx106-elf-g++
NM
=
xtensa-lx106-elf-nm
NM
=
xtensa-lx106-elf-nm
CPP
=
xtensa-lx106-elf-cpp
CPP
=
xtensa-lx106-elf-cpp
OBJCOPY
=
xtensa-lx106-elf-objcopy
OBJCOPY
=
xtensa-lx106-elf-objcopy
...
@@ -77,6 +79,7 @@ else
...
@@ -77,6 +79,7 @@ else
CCFLAGS
+=
-ffunction-sections
-fno-jump-tables
-fdata-sections
CCFLAGS
+=
-ffunction-sections
-fno-jump-tables
-fdata-sections
AR
=
xtensa-lx106-elf-ar
AR
=
xtensa-lx106-elf-ar
CC
=
$(WRAPCC)
xtensa-lx106-elf-gcc
CC
=
$(WRAPCC)
xtensa-lx106-elf-gcc
CXX
=
$(WRAPCC)
xtensa-lx106-elf-g++
NM
=
xtensa-lx106-elf-nm
NM
=
xtensa-lx106-elf-nm
CPP
=
$(WRAPCC)
xtensa-lx106-elf-gcc
-E
CPP
=
$(WRAPCC)
xtensa-lx106-elf-gcc
-E
OBJCOPY
=
xtensa-lx106-elf-objcopy
OBJCOPY
=
xtensa-lx106-elf-objcopy
...
@@ -104,6 +107,7 @@ ESPTOOL ?= ../tools/esptool.py
...
@@ -104,6 +107,7 @@ ESPTOOL ?= ../tools/esptool.py
CSRCS
?=
$(
wildcard
*
.c
)
CSRCS
?=
$(
wildcard
*
.c
)
CXXSRCS
?=
$(
wildcard
*
.cpp
)
ASRCs
?=
$(
wildcard
*
.s
)
ASRCs
?=
$(
wildcard
*
.s
)
ASRCS
?=
$(
wildcard
*
.S
)
ASRCS
?=
$(
wildcard
*
.S
)
SUBDIRS
?=
$(
patsubst
%/,%,
$(
dir
$(
filter-out
tools/Makefile,
$(
wildcard
*
/Makefile
))))
SUBDIRS
?=
$(
patsubst
%/,%,
$(
dir
$(
filter-out
tools/Makefile,
$(
wildcard
*
/Makefile
))))
...
@@ -112,10 +116,12 @@ ODIR := .output
...
@@ -112,10 +116,12 @@ ODIR := .output
OBJODIR
:=
$(ODIR)
/
$(TARGET)
/
$(FLAVOR)
/obj
OBJODIR
:=
$(ODIR)
/
$(TARGET)
/
$(FLAVOR)
/obj
OBJS
:=
$
(
CSRCS:%.c
=
$(OBJODIR)
/%.o
)
\
OBJS
:=
$
(
CSRCS:%.c
=
$(OBJODIR)
/%.o
)
\
$
(
CXXSRCS:%.cpp
=
$(OBJODIR)
/%.o
)
\
$
(
ASRCs:%.s
=
$(OBJODIR)
/%.o
)
\
$
(
ASRCs:%.s
=
$(OBJODIR)
/%.o
)
\
$
(
ASRCS:%.S
=
$(OBJODIR)
/%.o
)
$
(
ASRCS:%.S
=
$(OBJODIR)
/%.o
)
DEPS
:=
$
(
CSRCS:%.c
=
$(OBJODIR)
/%.d
)
\
DEPS
:=
$
(
CSRCS:%.c
=
$(OBJODIR)
/%.d
)
\
$
(
CXXSCRS:%.cpp
=
$(OBJODIR)
/%.d
)
\
$
(
ASRCs:%.s
=
$(OBJODIR)
/%.d
)
\
$
(
ASRCs:%.s
=
$(OBJODIR)
/%.d
)
\
$
(
ASRCS:%.S
=
$(OBJODIR)
/%.d
)
$
(
ASRCS:%.S
=
$(OBJODIR)
/%.d
)
...
@@ -206,9 +212,11 @@ sdk_patched: sdk_extracted $(TOP_DIR)/sdk/.patched-$(SDK_VER)
...
@@ -206,9 +212,11 @@ sdk_patched: sdk_extracted $(TOP_DIR)/sdk/.patched-$(SDK_VER)
$(TOP_DIR)/sdk/.extracted-$(SDK_BASE_VER)
:
$(TOP_DIR)/cache/v$(SDK_FILE_VER).zip
$(TOP_DIR)/sdk/.extracted-$(SDK_BASE_VER)
:
$(TOP_DIR)/cache/v$(SDK_FILE_VER).zip
mkdir
-p
"
$(
dir
$@
)
"
mkdir
-p
"
$(
dir
$@
)
"
(
cd
"
$(
dir
$@
)
"
&&
rm
-fr
esp_iot_sdk_v
$(SDK_VER)
ESP8266_NONOS_SDK-
$(SDK_VER)
&&
unzip
$(TOP_DIR)
/cache/v
$(SDK_FILE_VER)
.zip ESP8266_NONOS_SDK-
$(SDK_VER)
/lib/
*
ESP8266_NONOS_SDK-
$(SDK_VER)
/ld/eagle.rom.addr.v6.ld ESP8266_NONOS_SDK-
$(SDK_VER)
/include/
*
ESP8266_NONOS_SDK-
$(SDK_VER)
/bin/esp_init_data_default.bin
)
(
cd
"
$(
dir
$@
)
"
&&
rm
-fr
esp_iot_sdk_v
$(SDK_VER)
ESP8266_NONOS_SDK-
$(SDK_VER)
&&
unzip
$(TOP_DIR)
/cache/v
$(SDK_FILE_VER)
.zip ESP8266_NONOS_SDK-
$(SDK_VER)
/lib/
*
ESP8266_NONOS_SDK-
$(SDK_VER)
/ld/eagle.rom.addr.v6.ld ESP8266_NONOS_SDK-
$(SDK_VER)
/include/
*
ESP8266_NONOS_SDK-
$(SDK_VER)
/bin/esp_init_data_default
_v05
.bin
)
mv
$(
dir
$@
)
/ESP8266_NONOS_SDK-
$(SDK_VER)
$(
dir
$@
)
/esp_iot_sdk_v
$(SDK_VER)
mv
$(
dir
$@
)
/ESP8266_NONOS_SDK-
$(SDK_VER)
$(
dir
$@
)
/esp_iot_sdk_v
$(SDK_VER)
rm
-f
$(SDK_DIR)
/lib/liblwip.a
rm
-f
$(SDK_DIR)
/lib/liblwip.a
$(SDK_DIR)
/lib/libssl.a
$(SDK_DIR)
/lib/libmbedtls.a
ar d
$(SDK_DIR)
/lib/libmain.a time.o
ar d
$(SDK_DIR)
/lib/libc.a lib_a-time.o
touch
$@
touch
$@
$(TOP_DIR)/sdk/.patched-$(SDK_VER)
:
$(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER).zip
$(TOP_DIR)/sdk/.patched-$(SDK_VER)
:
$(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER).zip
...
@@ -306,6 +314,17 @@ $(OBJODIR)/%.d: %.c
...
@@ -306,6 +314,17 @@ $(OBJODIR)/%.d: %.c
sed
's,\($*\.o\)[ :]*,
$(OBJODIR)
/\1 $@ : ,g'
<
$@
.
$$$$
>
$@
;
\
sed
's,\($*\.o\)[ :]*,
$(OBJODIR)
/\1 $@ : ,g'
<
$@
.
$$$$
>
$@
;
\
rm
-f
$@
.
$$$$
rm
-f
$@
.
$$$$
$(OBJODIR)/%.o
:
%.cpp
@
mkdir
-p
$(OBJODIR)
;
$(CXX)
$(
if
$(
findstring
$<
,
$(DSRCS)
)
,
$(DFLAGS)
,
$(CFLAGS)
)
$
(
COPTS_
$
(
*
F
))
-o
$@
-c
$<
$(OBJODIR)/%.d
:
%.cpp
@
mkdir
-p
$(OBJODIR)
;
@
echo
DEPEND:
$(CXX)
-M
$(CFLAGS)
$<
@
set
-e
;
rm
-f
$@
;
\
sed
's,\($*\.o\)[ :]*,
$(OBJODIR)
/\1 $@ : ,g'
<
$@
.
$$$$
>
$@
;
\
rm
-f
$@
.
$$$$
$(OBJODIR)/%.o
:
%.s
$(OBJODIR)/%.o
:
%.s
@
mkdir
-p
$(OBJODIR)
;
@
mkdir
-p
$(OBJODIR)
;
$(CC)
$(CFLAGS)
-o
$@
-c
$<
$(CC)
$(CFLAGS)
-o
$@
-c
$<
...
...
app/Makefile
View file @
96601b68
...
@@ -166,6 +166,7 @@ CONFIGURATION_DEFINES = -D__ets__ \
...
@@ -166,6 +166,7 @@ CONFIGURATION_DEFINES = -D__ets__ \
-DLWIP_OPEN_SRC
\
-DLWIP_OPEN_SRC
\
-DPBUF_RSV_FOR_WLAN
\
-DPBUF_RSV_FOR_WLAN
\
-DEBUF_LWIP
\
-DEBUF_LWIP
\
-DUSE_OPTIMIZE_PRINTF
\
-DMBEDTLS_USER_CONFIG_FILE
=
\"
user_mbedtls.h
\"
\
-DMBEDTLS_USER_CONFIG_FILE
=
\"
user_mbedtls.h
\"
\
DEFINES
+=
\
DEFINES
+=
\
...
...
app/driver/key.c
View file @
96601b68
...
@@ -132,9 +132,9 @@ key_50ms_cb(struct single_key_param *single_key)
...
@@ -132,9 +132,9 @@ key_50ms_cb(struct single_key_param *single_key)
LOCAL
void
LOCAL
void
key_intr_handler
(
void
*
arg
)
key_intr_handler
(
void
*
arg
)
{
{
struct
keys_param
*
keys
=
arg
;
uint8
i
;
uint8
i
;
uint32
gpio_status
=
GPIO_REG_READ
(
GPIO_STATUS_ADDRESS
);
uint32
gpio_status
=
GPIO_REG_READ
(
GPIO_STATUS_ADDRESS
);
struct
keys_param
*
keys
=
arg
;
for
(
i
=
0
;
i
<
keys
->
key_num
;
i
++
)
{
for
(
i
=
0
;
i
<
keys
->
key_num
;
i
++
)
{
if
(
gpio_status
&
BIT
(
keys
->
single_key
[
i
]
->
gpio_id
))
{
if
(
gpio_status
&
BIT
(
keys
->
single_key
[
i
]
->
gpio_id
))
{
...
...
app/include/arch/cc.h
View file @
96601b68
...
@@ -65,7 +65,7 @@ typedef uint32_t mem_ptr_t;
...
@@ -65,7 +65,7 @@ typedef uint32_t mem_ptr_t;
#define U32_F "d"
#define U32_F "d"
#define X32_F "x"
#define X32_F "x"
#define LWIP_ERR_T s32_t
//#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
//#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_FIELD(x) x
...
...
app/include/lwip/app/espconn.h
View file @
96601b68
/*
* 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 __ESPCONN_H__
#ifndef __ESPCONN_H__
#define __ESPCONN_H__
#define __ESPCONN_H__
#include "lwip/err.h"
#include "lwip/dns.h"
#include "lwip/dns.h"
#include "os_type.h"
#include "os_type.h"
#include "lwip/app/espconn_buf.h"
#include "lwip/app/espconn_buf.h"
...
@@ -37,8 +62,7 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
...
@@ -37,8 +62,7 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
#define ESPCONN_NODATA -17
/* No data can be read */
#define ESPCONN_NODATA -17
/* No data can be read */
#define ESPCONN_HANDSHAKE -28
/* ssl handshake failed */
#define ESPCONN_HANDSHAKE -28
/* ssl handshake failed */
#define ESPCONN_RESP_TIMEOUT -29
/* ssl handshake no response*/
#define ESPCONN_SSL_INVALID_DATA -61
/* ssl application invalid */
#define ESPCONN_PROTO_MSG -61
/* ssl application invalid */
#define ESPCONN_SSL 0x01
#define ESPCONN_SSL 0x01
#define ESPCONN_NORM 0x00
#define ESPCONN_NORM 0x00
...
@@ -121,6 +145,7 @@ enum espconn_option{
...
@@ -121,6 +145,7 @@ enum espconn_option{
ESPCONN_NODELAY
=
0x02
,
ESPCONN_NODELAY
=
0x02
,
ESPCONN_COPY
=
0x04
,
ESPCONN_COPY
=
0x04
,
ESPCONN_KEEPALIVE
=
0x08
,
ESPCONN_KEEPALIVE
=
0x08
,
ESPCONN_MANUALRECV
=
0x10
,
ESPCONN_END
ESPCONN_END
};
};
...
@@ -461,6 +486,17 @@ extern sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callbac
...
@@ -461,6 +486,17 @@ extern sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callbac
*******************************************************************************/
*******************************************************************************/
extern
sint8
espconn_regist_write_finish
(
struct
espconn
*
espconn
,
espconn_connect_callback
write_finish_fn
);
extern
sint8
espconn_regist_write_finish
(
struct
espconn
*
espconn
,
espconn_connect_callback
write_finish_fn
);
/******************************************************************************
* FunctionName : espconn_send
* Description : sent data for client or server
* Parameters : espconn -- espconn to set for client or server
* psent -- data to send
* length -- length of data to send
* Returns : none
*******************************************************************************/
extern
sint8
espconn_send
(
struct
espconn
*
espconn
,
uint8
*
psent
,
uint16
length
);
/******************************************************************************
/******************************************************************************
* FunctionName : espconn_sent
* FunctionName : espconn_sent
* Description : sent data for client or server
* Description : sent data for client or server
...
@@ -573,7 +609,163 @@ extern sint8 espconn_get_keepalive(struct espconn *espconn, uint8 level, void *o
...
@@ -573,7 +609,163 @@ extern sint8 espconn_get_keepalive(struct espconn *espconn, uint8 level, void *o
* - ESPCONN_ARG: dns client not initialized or invalid hostname
* - ESPCONN_ARG: dns client not initialized or invalid hostname
*******************************************************************************/
*******************************************************************************/
extern
sint8
espconn_gethostbyname
(
struct
espconn
*
pespconn
,
const
char
*
name
,
ip_addr_t
*
addr
,
dns_found_callback
found
);
extern
err_t
espconn_gethostbyname
(
struct
espconn
*
pespconn
,
const
char
*
name
,
ip_addr_t
*
addr
,
dns_found_callback
found
);
/******************************************************************************
* FunctionName : espconn_abort
* Description : Forcely abort with host
* Parameters : espconn -- the espconn used to connect with the host
* Returns : result
*******************************************************************************/
extern
sint8
espconn_abort
(
struct
espconn
*
espconn
);
/******************************************************************************
* FunctionName : espconn_encry_connect
* Description : The function given as connection
* Parameters : espconn -- the espconn used to connect with the host
* Returns : none
*******************************************************************************/
extern
sint8
espconn_secure_connect
(
struct
espconn
*
espconn
);
/******************************************************************************
* FunctionName : espconn_encry_disconnect
* Description : The function given as the disconnection
* Parameters : espconn -- the espconn used to disconnect with the host
* Returns : none
*******************************************************************************/
extern
sint8
espconn_secure_disconnect
(
struct
espconn
*
espconn
);
/******************************************************************************
* FunctionName : espconn_secure_send
* Description : sent data for client or server
* Parameters : espconn -- espconn to set for client or server
* psent -- data to send
* length -- length of data to send
* Returns : none
*******************************************************************************/
extern
sint8
espconn_secure_send
(
struct
espconn
*
espconn
,
uint8
*
psent
,
uint16
length
);
/******************************************************************************
* FunctionName : espconn_encry_sent
* Description : sent data for client or server
* Parameters : espconn -- espconn to set for client or server
* psent -- data to send
* length -- length of data to send
* Returns : none
*******************************************************************************/
extern
sint8
espconn_secure_sent
(
struct
espconn
*
espconn
,
uint8
*
psent
,
uint16
length
);
/******************************************************************************
* FunctionName : espconn_secure_set_size
* Description : set the buffer size for client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* size -- buffer size
* Returns : true or false
*******************************************************************************/
extern
bool
espconn_secure_set_size
(
uint8
level
,
uint16
size
);
/******************************************************************************
* FunctionName : espconn_secure_get_size
* Description : get buffer size for client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* Returns : buffer size for client or server
*******************************************************************************/
extern
sint16
espconn_secure_get_size
(
uint8
level
);
/******************************************************************************
* FunctionName : espconn_secure_ca_enable
* Description : enable the certificate authenticate and set the flash sector
* as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* flash_sector -- flash sector for save certificate
* Returns : result true or false
*******************************************************************************/
extern
bool
espconn_secure_ca_enable
(
uint8
level
,
uint32
flash_sector
);
/******************************************************************************
* FunctionName : espconn_secure_ca_disable
* Description : disable the certificate authenticate as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* Returns : result true or false
*******************************************************************************/
extern
bool
espconn_secure_ca_disable
(
uint8
level
);
/******************************************************************************
* FunctionName : espconn_secure_cert_req_enable
* Description : enable the client certificate authenticate and set the flash sector
* as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* flash_sector -- flash sector for save certificate
* Returns : result true or false
*******************************************************************************/
extern
bool
espconn_secure_cert_req_enable
(
uint8
level
,
uint32
flash_sector
);
/******************************************************************************
* FunctionName : espconn_secure_ca_disable
* Description : disable the client certificate authenticate as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* Returns : result true or false
*******************************************************************************/
extern
bool
espconn_secure_cert_req_disable
(
uint8
level
);
/******************************************************************************
* FunctionName : espconn_secure_set_default_certificate
* Description : Load the certificates in memory depending on compile-time
* and user options.
* Parameters : certificate -- Load the certificate
* length -- Load the certificate length
* Returns : result true or false
*******************************************************************************/
extern
bool
espconn_secure_set_default_certificate
(
const
uint8
*
certificate
,
uint16
length
);
/******************************************************************************
* FunctionName : espconn_secure_set_default_private_key
* Description : Load the key in memory depending on compile-time
* and user options.
* Parameters : private_key -- Load the key
* length -- Load the key length
* Returns : result true or false
*******************************************************************************/
extern
bool
espconn_secure_set_default_private_key
(
const
uint8
*
private_key
,
uint16
length
);
/******************************************************************************
* FunctionName : espconn_secure_accept
* Description : The function given as the listen
* Parameters : espconn -- the espconn used to listen the connection
* Returns : result
*******************************************************************************/
extern
sint8
espconn_secure_accept
(
struct
espconn
*
espconn
);
/******************************************************************************
* FunctionName : espconn_secure_accepts
* Description : delete the secure server host
* Parameters : espconn -- the espconn used to listen the connection
* Returns : result
*******************************************************************************/
extern
sint8
espconn_secure_delete
(
struct
espconn
*
espconn
);
/******************************************************************************
/******************************************************************************
* FunctionName : espconn_igmp_join
* FunctionName : espconn_igmp_join
...
@@ -593,6 +785,22 @@ extern sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
...
@@ -593,6 +785,22 @@ extern sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
*******************************************************************************/
*******************************************************************************/
extern
sint8
espconn_igmp_leave
(
ip_addr_t
*
host_ip
,
ip_addr_t
*
multicast_ip
);
extern
sint8
espconn_igmp_leave
(
ip_addr_t
*
host_ip
,
ip_addr_t
*
multicast_ip
);
/******************************************************************************
* FunctionName : espconn_recv_hold
* Description : hold tcp receive
* Parameters : espconn -- espconn to hold
* Returns : none
*******************************************************************************/
extern
sint8
espconn_recv_hold
(
struct
espconn
*
pespconn
);
/******************************************************************************
* FunctionName : espconn_recv_unhold
* Description : unhold tcp receive
* Parameters : espconn -- espconn to unhold
* Returns : none
*******************************************************************************/
extern
sint8
espconn_recv_unhold
(
struct
espconn
*
pespconn
);
/******************************************************************************
/******************************************************************************
* FunctionName : espconn_mdns_init
* FunctionName : espconn_mdns_init
* Description : register a device with mdns
* Description : register a device with mdns
...
...
app/include/lwip/app/espconn_tcp.h
View file @
96601b68
...
@@ -13,6 +13,9 @@
...
@@ -13,6 +13,9 @@
#define espconn_keepalive_enable(pcb) ((pcb)->so_options |= SOF_KEEPALIVE)
#define espconn_keepalive_enable(pcb) ((pcb)->so_options |= SOF_KEEPALIVE)
#define espconn_keepalive_disable(pcb) ((pcb)->so_options &= ~SOF_KEEPALIVE)
#define espconn_keepalive_disable(pcb) ((pcb)->so_options &= ~SOF_KEEPALIVE)
#define espconn_manual_recv_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_MANUALRECV) != 0)
#define espconn_manual_recv_enabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_MANUALRECV) == 0)
/******************************************************************************
/******************************************************************************
* FunctionName : espconn_kill_oldest_pcb
* FunctionName : espconn_kill_oldest_pcb
* Description : A oldest incoming connection has been killed.
* Description : A oldest incoming connection has been killed.
...
...
app/include/lwip/app/time.h
deleted
100644 → 0
View file @
be53d5c9
/*
* time.h
*
* Created on: May 31, 2016
* Author: liuhan
*/
#ifndef TIME_H_
#define TIME_H_
#include "osapi.h"
#include "os_type.h"
#include "lwip/sntp.h"
struct
timeval
{
unsigned
long
tv_sec
;
/* seconds */
unsigned
long
tv_usec
;
/* and microseconds */
};
/***************************RTC TIME OPTION***************************************/
// daylight settings
// Base calculated with value obtained from NTP server (64 bits)
#define sntp_base (*((uint64_t*)RTC_STORE0))
// Timer value when base was obtained
#define TIM_REF_SET(value) WRITE_PERI_REG(RTC_STORE2, value)
#define TIM_REF_GET() READ_PERI_REG(RTC_STORE2)
// Setters and getters for CAL, TZ and DST.
#define RTC_CAL_SET(val) do {uint32 value = READ_PERI_REG(RTC_STORE3);\
value |= ((val) & 0x0000FFFF);\
WRITE_PERI_REG(RTC_STORE3, value);\
}while(0)
#define RTC_DST_SET(val) do {uint32 value = READ_PERI_REG(RTC_STORE3);\
value |= (((val)<<16) & 0x00010000);\
WRITE_PERI_REG(RTC_STORE3, value);\
}while(0)
#define RTC_TZ_SET(val) do {uint32 value = READ_PERI_REG(RTC_STORE3);\
value |= (((val)<<24) & 0xFF000000);\
WRITE_PERI_REG(RTC_STORE3, value);\
}while(0)
#define RTC_CAL_GET() (READ_PERI_REG(RTC_STORE3) & 0x0000FFFF)
#define RTC_DST_GET() ((READ_PERI_REG(RTC_STORE3) & 0x00010000)>>16)
#define RTC_TZ_GET() ((((int)READ_PERI_REG(RTC_STORE3)) & ((int)0xFF000000))>>24)
void
system_update_rtc
(
time_t
t
,
uint32_t
us
);
time_t
sntp_get_rtc_time
(
sint32_t
*
us
);
int
gettimeofday
(
struct
timeval
*
t
,
void
*
timezone
);
void
updateTime
(
uint32
ms
);
bool
configTime
(
int
timezone
,
int
daylightOffset
,
char
*
server1
,
char
*
server2
,
char
*
server3
,
bool
enable
);
time_t
time
(
time_t
*
t
);
unsigned
long
millis
(
void
);
unsigned
long
micros
(
void
);
#endif
/* TIME_H_ */
app/include/lwip/mem.h
View file @
96601b68
...
@@ -78,7 +78,7 @@ do{\
...
@@ -78,7 +78,7 @@ do{\
#define mem_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__);})
#define mem_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__);})
#endif
#endif
#ifndef mem_calloc
#ifndef mem_calloc
#define mem_calloc(s) ({const char *file = mem_debug_file; pvPortCalloc(s, file, __LINE__);})
#define mem_calloc(
l,
s) ({const char *file = mem_debug_file; pvPortCalloc(
l,
s, file, __LINE__);})
#endif
#endif
#ifndef mem_realloc
#ifndef mem_realloc
#define mem_realloc(p, s) ({const char *file = mem_debug_file; pvPortRealloc(p, s, file, __LINE__);})
#define mem_realloc(p, s) ({const char *file = mem_debug_file; pvPortRealloc(p, s, file, __LINE__);})
...
...
app/include/lwip/sntp.h
deleted
100644 → 0
View file @
be53d5c9
#ifndef LWIP_SNTP_H
#define LWIP_SNTP_H
#include "lwip/opt.h"
#include "lwip/ip_addr.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
long
time_t
;
/** The maximum number of SNTP servers that can be set */
#ifndef SNTP_MAX_SERVERS
#define SNTP_MAX_SERVERS 3
#endif
/** Set this to 1 to implement the callback function called by dhcp when
* NTP servers are received. */
#ifndef SNTP_GET_SERVERS_FROM_DHCP
#define SNTP_GET_SERVERS_FROM_DHCP 0//LWIP_DHCP_GET_NTP_SRV
#endif
/* Set this to 1 to support DNS names (or IP address strings) to set sntp servers */
#ifndef SNTP_SERVER_DNS
#define SNTP_SERVER_DNS 1
#endif
bool
sntp_get_timetype
(
void
);
void
sntp_set_receive_time_size
(
void
);
/** One server address/name can be defined as default if SNTP_SERVER_DNS == 1:
* #define SNTP_SERVER_ADDRESS "pool.ntp.org"
*/
uint32
sntp_get_current_timestamp
();
char
*
sntp_get_real_time
(
long
t
);
void
sntp_init
(
void
);
void
sntp_stop
(
void
);
sint8
sntp_get_timezone
(
void
);
bool
sntp_set_timezone
(
sint8
timezone
);
void
sntp_setserver
(
u8_t
idx
,
ip_addr_t
*
addr
);
ip_addr_t
sntp_getserver
(
u8_t
idx
);
#if SNTP_SERVER_DNS
void
sntp_setservername
(
u8_t
idx
,
char
*
server
);
char
*
sntp_getservername
(
u8_t
idx
);
#endif
/* SNTP_SERVER_DNS */
#if SNTP_GET_SERVERS_FROM_DHCP
void
sntp_servermode_dhcp
(
int
set_servers_from_dhcp
);
#else
/* SNTP_GET_SERVERS_FROM_DHCP */
#define sntp_servermode_dhcp(x)
#endif
/* SNTP_GET_SERVERS_FROM_DHCP */
#ifdef __cplusplus
}
#endif
#endif
/* LWIP_SNTP_H */
app/include/user_mbedtls.h
View file @
96601b68
...
@@ -5,8 +5,9 @@
...
@@ -5,8 +5,9 @@
#undef MBEDTLS_HAVE_ASM
#undef MBEDTLS_HAVE_ASM
#undef MBEDTLS_HAVE_SSE2
#undef MBEDTLS_HAVE_SSE2
#define MBEDTLS_HAVE_TIME
// These are disabled until we have a real, working RTC-based gettimeofday
#define MBEDTLS_HAVE_TIME_DATE
#undef MBEDTLS_HAVE_TIME
#undef MBEDTLS_HAVE_TIME_DATE
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_PLATFORM_MEMORY
#undef MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
#undef MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
...
...
app/include/user_version.h
View file @
96601b68
#ifndef __USER_VERSION_H__
#ifndef __USER_VERSION_H__
#define __USER_VERSION_H__
#define __USER_VERSION_H__
#define NODE_VERSION_MAJOR 2U
#include "version.h"
/* ESP firmware header */
#define NODE_VERSION_MINOR 1U
#define NODE_VERSION_REVISION 0U
#define NODE_VERSION_MAJOR ESP_SDK_VERSION_MAJOR
#define NODE_VERSION_INTERNAL 0U
#define NODE_VERSION_MINOR ESP_SDK_VERSION_MINOR
#define NODE_VERSION_REVISION ESP_SDK_VERSION_PATCH
#define NODE_VERSION_INTERNAL 0
#define NODE_VERSION_STR(x) #x
#define NODE_VERSION_XSTR(x) NODE_VERSION_STR(x)
#define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL)
#define NODE_VERSION "NodeMCU 2.1.0"
#ifndef BUILD_DATE
#ifndef BUILD_DATE
#define BUILD_DATE "unspecified"
#define BUILD_DATE "unspecified"
#endif
#endif
...
...
app/lwip/app/espconn.c
View file @
96601b68
...
@@ -441,6 +441,7 @@ sint16 ICACHE_FLASH_ATTR espconn_recv(struct espconn *espconn, void *mem, size_t
...
@@ -441,6 +441,7 @@ sint16 ICACHE_FLASH_ATTR espconn_recv(struct espconn *espconn, void *mem, size_t
espconn_msg
*
pnode
=
NULL
;
espconn_msg
*
pnode
=
NULL
;
bool
value
=
false
;
bool
value
=
false
;
int
bytes_used
=
0
;
int
bytes_used
=
0
;
struct
tcp_pcb
*
tpcb
=
NULL
;
if
(
espconn
==
NULL
||
mem
==
NULL
||
len
==
0
)
if
(
espconn
==
NULL
||
mem
==
NULL
||
len
==
0
)
return
ESPCONN_ARG
;
return
ESPCONN_ARG
;
...
@@ -454,13 +455,15 @@ sint16 ICACHE_FLASH_ATTR espconn_recv(struct espconn *espconn, void *mem, size_t
...
@@ -454,13 +455,15 @@ sint16 ICACHE_FLASH_ATTR espconn_recv(struct espconn *espconn, void *mem, size_t
len
=
bytes_used
;
len
=
bytes_used
;
}
}
ringbuf_memcpy_from
(
mem
,
pnode
->
readbuf
,
len
);
ringbuf_memcpy_from
(
mem
,
pnode
->
readbuf
,
len
);
espconn_recv_unhold
(
pnode
->
pespconn
);
tpcb
=
pnode
->
pcommon
.
pcb
;
if
(
tpcb
&&
tpcb
->
state
==
ESTABLISHED
)
tcp_recved
(
pnode
->
pcommon
.
pcb
,
len
);
return
len
;
return
len
;
}
else
{
}
else
{
return
ESPCONN_OK
;
return
ESPCONN_OK
;
}
}
}
else
{
}
else
{
return
ESPCONN_
OK
;
return
ESPCONN_
MEM
;
}
}
}
else
{
}
else
{
return
ESPCONN_ARG
;
return
ESPCONN_ARG
;
...
...
app/lwip/app/espconn_tcp.c
View file @
96601b68
...
@@ -231,6 +231,10 @@ void ICACHE_FLASH_ATTR espconn_tcp_memp_free(espconn_msg *pmemp)
...
@@ -231,6 +231,10 @@ void ICACHE_FLASH_ATTR espconn_tcp_memp_free(espconn_msg *pmemp)
if
(
pmemp
==
NULL
)
if
(
pmemp
==
NULL
)
return
;
return
;
/*Enable block option for fetches the data proactive*/
if
(
espconn_manual_recv_disabled
(
pmemp
))
espconn_list_delete
(
&
plink_active
,
pmemp
);
if
(
pmemp
->
espconn_mode
==
ESPCONN_TCPSERVER_MODE
){
if
(
pmemp
->
espconn_mode
==
ESPCONN_TCPSERVER_MODE
){
if
(
pmemp
->
pespconn
!=
NULL
&&
pmemp
->
pespconn
->
proto
.
tcp
!=
NULL
)
if
(
pmemp
->
pespconn
!=
NULL
&&
pmemp
->
pespconn
->
proto
.
tcp
!=
NULL
)
os_free
(
pmemp
->
pespconn
->
proto
.
tcp
);
os_free
(
pmemp
->
pespconn
->
proto
.
tcp
);
...
@@ -431,10 +435,12 @@ espconn_Task(os_event_t *events)
...
@@ -431,10 +435,12 @@ espconn_Task(os_event_t *events)
case
SIG_ESPCONN_ERRER
:
case
SIG_ESPCONN_ERRER
:
/*remove the node from the client's active connection list*/
/*remove the node from the client's active connection list*/
espconn_list_delete
(
&
plink_active
,
task_msg
);
espconn_list_delete
(
&
plink_active
,
task_msg
);
espconn_tcp_reconnect
(
task_msg
);
if
(
espconn_manual_recv_enabled
(
task_msg
))
espconn_list_delete
(
&
plink_active
,
task_msg
);
break
;
break
;
case
SIG_ESPCONN_CLOSE
:
case
SIG_ESPCONN_CLOSE
:
/*remove the node from the client's active connection list*/
/*remove the node from the client's active connection list*/
if
(
espconn_manual_recv_enabled
(
task_msg
))
espconn_list_delete
(
&
plink_active
,
task_msg
);
espconn_list_delete
(
&
plink_active
,
task_msg
);
espconn_tcp_disconnect_successful
(
task_msg
);
espconn_tcp_disconnect_successful
(
task_msg
);
break
;
break
;
...
@@ -538,6 +544,66 @@ void ICACHE_FLASH_ATTR espconn_tcp_disconnect(espconn_msg *pdiscon,u8 type)
...
@@ -538,6 +544,66 @@ void ICACHE_FLASH_ATTR espconn_tcp_disconnect(espconn_msg *pdiscon,u8 type)
}
}
}
}
/******************************************************************************
* FunctionName : espconn_tcp_recv
* Description : Data has been received on this pcb.
* Parameters : arg -- Additional argument to pass to the callback function
* pcb -- The connection pcb which received data
* p -- The received data (or NULL when the connection has been closed!)
* err -- An error code if there has been an error receiving
* Returns : ERR_ABRT: if you have called tcp_abort from within the function!
*******************************************************************************/
static
err_t
ICACHE_FLASH_ATTR
espconn_tcp_recv
(
void
*
arg
,
struct
tcp_pcb
*
pcb
,
struct
pbuf
*
p
,
err_t
err
)
{
espconn_msg
*
precv_cb
=
arg
;
struct
pbuf
*
pthis
=
NULL
;
uint8_t
*
ring
=
NULL
;
size_t
bytes_used
=
0
;
tcp_arg
(
pcb
,
arg
);
if
(
precv_cb
->
readbuf
==
NULL
)
{
precv_cb
->
readbuf
=
ringbuf_new
(
TCP_WND
);
if
(
precv_cb
->
readbuf
==
NULL
)
return
ESPCONN_MEM
;
}
if
(
err
==
ERR_OK
)
{
precv_cb
->
pcommon
.
recv_check
=
0
;
if
(
p
!=
NULL
)
{
/*store the data to the adapter for application fetches it proactive*/
for
(
pthis
=
p
;
pthis
!=
NULL
;
pthis
=
pthis
->
next
)
{
ring
=
ringbuf_memcpy_into
(
precv_cb
->
readbuf
,
pthis
->
payload
,
pthis
->
len
);
if
(
ring
)
pbuf_free
(
pthis
);
else
break
;
}
bytes_used
=
ringbuf_bytes_used
(
precv_cb
->
readbuf
);
/*switch the state of espconn for application process*/
precv_cb
->
pespconn
->
state
=
ESPCONN_READ
;
precv_cb
->
pcommon
.
pcb
=
pcb
;
if
(
precv_cb
->
pespconn
->
recv_callback
!=
NULL
)
{
precv_cb
->
pespconn
->
recv_callback
(
precv_cb
->
pespconn
,
NULL
,
bytes_used
);
}
/*switch the state of espconn for next packet copy*/
if
(
pcb
->
state
==
ESTABLISHED
)
precv_cb
->
pespconn
->
state
=
ESPCONN_CONNECT
;
}
else
{
if
(
precv_cb
->
preverse
)
{
espconn_server_close
(
precv_cb
,
pcb
,
0
);
}
else
{
espconn_client_close
(
precv_cb
,
pcb
,
0
);
}
}
}
return
ERR_OK
;
}
///////////////////////////////client function/////////////////////////////////
///////////////////////////////client function/////////////////////////////////
/******************************************************************************
/******************************************************************************
* FunctionName : espconn_client_close
* FunctionName : espconn_client_close
...
@@ -933,6 +999,10 @@ espconn_client_connect(void *arg, struct tcp_pcb *tpcb, err_t err)
...
@@ -933,6 +999,10 @@ espconn_client_connect(void *arg, struct tcp_pcb *tpcb, err_t err)
pcon
->
pespconn
->
proto
.
tcp
->
connect_callback
(
pcon
->
pespconn
);
pcon
->
pespconn
->
proto
.
tcp
->
connect_callback
(
pcon
->
pespconn
);
}
}
/*Enable block option for fetches the data proactive*/
if
(
espconn_manual_recv_disabled
(
pcon
))
tcp_recv
(
tpcb
,
espconn_tcp_recv
);
/*Enable keep alive option*/
/*Enable keep alive option*/
if
(
espconn_keepalive_disabled
(
pcon
))
if
(
espconn_keepalive_disabled
(
pcon
))
espconn_keepalive_enable
(
tpcb
);
espconn_keepalive_enable
(
tpcb
);
...
@@ -1358,6 +1428,10 @@ espconn_tcp_accept(void *arg, struct tcp_pcb *pcb, err_t err)
...
@@ -1358,6 +1428,10 @@ espconn_tcp_accept(void *arg, struct tcp_pcb *pcb, err_t err)
paccept
->
pespconn
->
proto
.
tcp
->
connect_callback
(
paccept
->
pespconn
);
paccept
->
pespconn
->
proto
.
tcp
->
connect_callback
(
paccept
->
pespconn
);
}
}
/*Enable block option for fetches the data proactive*/
if
(
espconn_manual_recv_disabled
(
paccept
))
tcp_recv
(
pcb
,
espconn_tcp_recv
);
/*Enable keep alive option*/
/*Enable keep alive option*/
if
(
espconn_keepalive_disabled
(
paccept
))
if
(
espconn_keepalive_disabled
(
paccept
))
espconn_keepalive_enable
(
pcb
);
espconn_keepalive_enable
(
pcb
);
...
...
app/lwip/app/espconn_udp.c
View file @
96601b68
...
@@ -237,9 +237,10 @@ espconn_udp_sendto(void *arg, uint8 *psent, uint16 length)
...
@@ -237,9 +237,10 @@ espconn_udp_sendto(void *arg, uint8 *psent, uint16 length)
if
(
wifi_get_opmode
()
==
ESPCONN_AP_STA
&&
default_interface
==
ESPCONN_AP_STA
&&
sta_netif
!=
NULL
&&
ap_netif
!=
NULL
)
if
(
wifi_get_opmode
()
==
ESPCONN_AP_STA
&&
default_interface
==
ESPCONN_AP_STA
&&
sta_netif
!=
NULL
&&
ap_netif
!=
NULL
)
{
{
if
(
netif_is_up
(
sta_netif
)
&&
netif_is_up
(
ap_netif
)
&&
\
if
(
netif_is_up
(
sta_netif
)
&&
\
ip_addr_isbroadcast
(
&
upcb
->
remote_ip
,
sta_netif
)
&&
\
netif_is_up
(
ap_netif
)
&&
\
ip_addr_isbroadcast
(
&
upcb
->
remote_ip
,
ap_netif
))
{
ip_addr_isbroadcast
(
&
dst_ip
,
sta_netif
)
&&
\
ip_addr_isbroadcast
(
&
dst_ip
,
ap_netif
))
{
p_temp
=
pbuf_alloc
(
PBUF_TRANSPORT
,
datalen
,
PBUF_RAM
);
p_temp
=
pbuf_alloc
(
PBUF_TRANSPORT
,
datalen
,
PBUF_RAM
);
if
(
pbuf_copy
(
p_temp
,
p
)
!=
ERR_OK
)
{
if
(
pbuf_copy
(
p_temp
,
p
)
!=
ERR_OK
)
{
...
...
app/lwip/core/sntp.c
deleted
100644 → 0
View file @
be53d5c9
This diff is collapsed.
Click to expand it.
app/lwip/core/tcp_in.c
View file @
96601b68
...
@@ -500,7 +500,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
...
@@ -500,7 +500,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
/* For incoming segments with the ACK flag set, respond with a
/* For incoming segments with the ACK flag set, respond with a
RST. */
RST. */
LWIP_DEBUGF
(
TCP_RST_DEBUG
,
(
"tcp_listen_input: ACK in LISTEN, sending reset
\n
"
));
LWIP_DEBUGF
(
TCP_RST_DEBUG
,
(
"tcp_listen_input: ACK in LISTEN, sending reset
\n
"
));
tcp_rst
(
ackno
+
1
,
seqno
+
tcplen
,
tcp_rst
(
ackno
,
seqno
+
tcplen
,
ip_current_dest_addr
(),
ip_current_src_addr
(),
ip_current_dest_addr
(),
ip_current_src_addr
(),
tcphdr
->
dest
,
tcphdr
->
src
);
tcphdr
->
dest
,
tcphdr
->
src
);
}
else
if
(
flags
&
TCP_SYN
)
{
//�յ�SYN����
}
else
if
(
flags
&
TCP_SYN
)
{
//�յ�SYN����
...
...
app/lwip/core/tcp_out.c
View file @
96601b68
...
@@ -461,6 +461,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
...
@@ -461,6 +461,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
return
ERR_MEM
;
return
ERR_MEM
;
}
}
#if !LWIP_NETIF_TX_SINGLE_PBUF
/*
/*
* Phase 2: Chain a new pbuf to the end of pcb->unsent.
* Phase 2: Chain a new pbuf to the end of pcb->unsent.
*
*
...
@@ -510,6 +511,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
...
@@ -510,6 +511,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
pos
+=
seglen
;
pos
+=
seglen
;
queuelen
+=
pbuf_clen
(
concat_p
);
queuelen
+=
pbuf_clen
(
concat_p
);
}
}
#endif
/* !LWIP_NETIF_TX_SINGLE_PBUF */
}
else
{
}
else
{
#if TCP_OVERSIZE
#if TCP_OVERSIZE
LWIP_ASSERT
(
"unsent_oversize mismatch (pcb->unsent is NULL)"
,
LWIP_ASSERT
(
"unsent_oversize mismatch (pcb->unsent is NULL)"
,
...
@@ -1336,6 +1338,12 @@ tcp_rexmit(struct tcp_pcb *pcb)
...
@@ -1336,6 +1338,12 @@ tcp_rexmit(struct tcp_pcb *pcb)
}
}
seg
->
next
=
*
cur_seg
;
seg
->
next
=
*
cur_seg
;
*
cur_seg
=
seg
;
*
cur_seg
=
seg
;
#if TCP_OVERSIZE
if
(
seg
->
next
==
NULL
)
{
/* the retransmitted segment is last in unsent, so reset unsent_oversize */
pcb
->
unsent_oversize
=
0
;
}
#endif
/* TCP_OVERSIZE */
++
pcb
->
nrtx
;
++
pcb
->
nrtx
;
...
...
app/mbedtls/app/espconn_mbedtls.c
View file @
96601b68
...
@@ -353,6 +353,8 @@ static void mbedtls_msg_free(pmbedtls_msg *msg)
...
@@ -353,6 +353,8 @@ static void mbedtls_msg_free(pmbedtls_msg *msg)
os_free
((
*
msg
)
->
ssl
.
out_buf
);
os_free
((
*
msg
)
->
ssl
.
out_buf
);
(
*
msg
)
->
ssl
.
out_buf
=
NULL
;
(
*
msg
)
->
ssl
.
out_buf
=
NULL
;
}
}
if
((
*
msg
)
->
pfinished
!=
NULL
)
mbedtls_finished_free
(
&
(
*
msg
)
->
pfinished
);
#endif
#endif
mbedtls_entropy_free
(
&
(
*
msg
)
->
entropy
);
mbedtls_entropy_free
(
&
(
*
msg
)
->
entropy
);
mbedtls_ssl_free
(
&
(
*
msg
)
->
ssl
);
mbedtls_ssl_free
(
&
(
*
msg
)
->
ssl
);
...
@@ -427,10 +429,6 @@ static void mbedtls_fail_info(espconn_msg *pinfo, int ret)
...
@@ -427,10 +429,6 @@ static void mbedtls_fail_info(espconn_msg *pinfo, int ret)
TLSmsg
=
pinfo
->
pssl
;
TLSmsg
=
pinfo
->
pssl
;
lwIP_REQUIRE_ACTION
(
TLSmsg
,
exit
,);
lwIP_REQUIRE_ACTION
(
TLSmsg
,
exit
,);
if
(
TLSmsg
->
quiet
)
{
mbedtls_ssl_close_notify
(
&
TLSmsg
->
ssl
);
}
/* Don't complain to console if we've been told the other end is hanging
/* Don't complain to console if we've been told the other end is hanging
* up. That's entirely normal and not worthy of the confusion it sows!
* up. That's entirely normal and not worthy of the confusion it sows!
*/
*/
...
@@ -441,6 +439,7 @@ static void mbedtls_fail_info(espconn_msg *pinfo, int ret)
...
@@ -441,6 +439,7 @@ static void mbedtls_fail_info(espconn_msg *pinfo, int ret)
}
else
{
}
else
{
os_printf
(
"client's data invalid protocol
\n
"
);
os_printf
(
"client's data invalid protocol
\n
"
);
}
}
mbedtls_ssl_close_notify
(
&
TLSmsg
->
ssl
);
}
else
{
}
else
{
if
(
pinfo
->
preverse
!=
NULL
)
{
if
(
pinfo
->
preverse
!=
NULL
)
{
os_printf
(
"server handshake failed!
\n
"
);
os_printf
(
"server handshake failed!
\n
"
);
...
@@ -564,6 +563,11 @@ static void espconn_close_internal(void *arg, netconn_event event_type)
...
@@ -564,6 +563,11 @@ static void espconn_close_internal(void *arg, netconn_event event_type)
ssl_reerr
=
pssl_recon
->
pcommon
.
err
;
ssl_reerr
=
pssl_recon
->
pcommon
.
err
;
hs_status
=
pssl_recon
->
hs_status
;
hs_status
=
pssl_recon
->
hs_status
;
if
(
espconn
!=
NULL
)
{
if
(
espconn
!=
NULL
)
{
//clear pcommon parameters.
pssl_recon
->
pcommon
.
write_flag
=
false
;
pssl_recon
->
pcommon
.
ptrbuf
=
NULL
;
pssl_recon
->
pcommon
.
cntr
=
0
;
pssl_recon
->
pcommon
.
err
=
0
;
espconn
=
pssl_recon
->
preverse
;
espconn
=
pssl_recon
->
preverse
;
}
else
{
}
else
{
espconn
=
pssl_recon
->
pespconn
;
espconn
=
pssl_recon
->
pespconn
;
...
@@ -667,6 +671,11 @@ again:
...
@@ -667,6 +671,11 @@ again:
offerset
+=
sizeof
(
file_head
)
+
pfile_param
->
file_head
.
file_length
;
offerset
+=
sizeof
(
file_head
)
+
pfile_param
->
file_head
.
file_length
;
goto
again
;
goto
again
;
}
}
/*Optional is load the cert*/
if
(
auth_info
->
auth_type
==
ESPCONN_CERT_OWN
&&
os_memcmp
(
pfile_param
->
file_head
.
file_name
,
"certificate"
,
os_strlen
(
"certificate"
))
!=
0
){
offerset
+=
sizeof
(
file_head
)
+
pfile_param
->
file_head
.
file_length
;
goto
again
;
}
load_buf
=
(
uint8_t
*
)
os_zalloc
(
pfile_param
->
file_head
.
file_length
+
FILE_OFFSET
);
load_buf
=
(
uint8_t
*
)
os_zalloc
(
pfile_param
->
file_head
.
file_length
+
FILE_OFFSET
);
if
(
load_buf
==
NULL
){
if
(
load_buf
==
NULL
){
os_free
(
pfile_param
);
os_free
(
pfile_param
);
...
@@ -839,6 +848,9 @@ int __attribute__((weak)) mbedtls_parse_internal(int socket, sint8 error)
...
@@ -839,6 +848,9 @@ int __attribute__((weak)) mbedtls_parse_internal(int socket, sint8 error)
if
(
ret
==
MBEDTLS_ERR_SSL_WANT_READ
||
ret
==
0
){
if
(
ret
==
MBEDTLS_ERR_SSL_WANT_READ
||
ret
==
0
){
ret
=
ESPCONN_OK
;
ret
=
ESPCONN_OK
;
break
;
break
;
}
else
if
(
ret
==
MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY
){
ret
=
ESPCONN_OK
;
mbedtls_ssl_close_notify
(
&
TLSmsg
->
ssl
);
}
else
{
}
else
{
break
;
break
;
}
}
...
@@ -891,6 +903,9 @@ int __attribute__((weak)) mbedtls_parse_internal(int socket, sint8 error)
...
@@ -891,6 +903,9 @@ int __attribute__((weak)) mbedtls_parse_internal(int socket, sint8 error)
}
}
system_soft_wdt_stop
();
system_soft_wdt_stop
();
uint8
cpu_freq
;
cpu_freq
=
system_get_cpu_freq
();
system_update_cpu_freq
(
160
);
while
((
ret
=
mbedtls_ssl_handshake
(
&
TLSmsg
->
ssl
))
!=
0
)
{
while
((
ret
=
mbedtls_ssl_handshake
(
&
TLSmsg
->
ssl
))
!=
0
)
{
if
(
ret
==
MBEDTLS_ERR_SSL_WANT_READ
||
ret
==
MBEDTLS_ERR_SSL_WANT_WRITE
)
{
if
(
ret
==
MBEDTLS_ERR_SSL_WANT_READ
||
ret
==
MBEDTLS_ERR_SSL_WANT_WRITE
)
{
...
@@ -901,6 +916,7 @@ int __attribute__((weak)) mbedtls_parse_internal(int socket, sint8 error)
...
@@ -901,6 +916,7 @@ int __attribute__((weak)) mbedtls_parse_internal(int socket, sint8 error)
}
}
}
}
system_soft_wdt_restart
();
system_soft_wdt_restart
();
system_update_cpu_freq
(
cpu_freq
);
lwIP_REQUIRE_NOERROR
(
ret
,
exit
);
lwIP_REQUIRE_NOERROR
(
ret
,
exit
);
/**/
/**/
TLSmsg
->
quiet
=
mbedtls_handshake_result
(
TLSmsg
);
TLSmsg
->
quiet
=
mbedtls_handshake_result
(
TLSmsg
);
...
@@ -937,6 +953,9 @@ int __attribute__((weak)) mbedtls_parse_internal(int socket, sint8 error)
...
@@ -937,6 +953,9 @@ int __attribute__((weak)) mbedtls_parse_internal(int socket, sint8 error)
exit:
exit:
if
(
ret
!=
ESPCONN_OK
){
if
(
ret
!=
ESPCONN_OK
){
mbedtls_fail_info
(
Threadmsg
,
ret
);
mbedtls_fail_info
(
Threadmsg
,
ret
);
if
(
ret
==
MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY
){
Threadmsg
->
hs_status
=
ESPCONN_OK
;
}
ets_post
(
lwIPThreadPrio
,
NETCONN_EVENT_CLOSE
,(
uint32
)
Threadmsg
);
ets_post
(
lwIPThreadPrio
,
NETCONN_EVENT_CLOSE
,(
uint32
)
Threadmsg
);
}
}
return
ret
;
return
ret
;
...
...
app/mbedtls/app/lwIPSocket.c
View file @
96601b68
...
@@ -302,6 +302,20 @@ static err_t do_accepted(void *arg, struct tcp_pcb *newpcb, err_t err)
...
@@ -302,6 +302,20 @@ static err_t do_accepted(void *arg, struct tcp_pcb *newpcb, err_t err)
lwIP_netconn
*
newconn
=
NULL
;
lwIP_netconn
*
newconn
=
NULL
;
lwIP_netconn
*
conn
=
arg
;
lwIP_netconn
*
conn
=
arg
;
err
=
ERR_OK
;
err
=
ERR_OK
;
//Avoid two TCP connections coming in simultaneously
struct
tcp_pcb
*
pactive_pcb
;
int
active_pcb_num
=
0
;
for
(
pactive_pcb
=
tcp_active_pcbs
;
pactive_pcb
!=
NULL
;
pactive_pcb
=
pactive_pcb
->
next
){
if
(
pactive_pcb
->
state
==
ESTABLISHED
||
pactive_pcb
->
state
==
SYN_RCVD
){
active_pcb_num
++
;
if
(
active_pcb_num
>
MEMP_NUM_TCP_PCB
){
ESP_LOG
(
"%s %d active_pcb_number:%d
\n
"
,
__FILE__
,
__LINE__
,
active_pcb_num
);
return
ERR_MEM
;
}
}
}
lwIP_REQUIRE_ACTION
(
conn
,
exit
,
err
=
ESP_ARG
);
lwIP_REQUIRE_ACTION
(
conn
,
exit
,
err
=
ESP_ARG
);
/* We have to set the callback here even though
/* We have to set the callback here even though
* the new socket is unknown. conn->socket is marked as -1. */
* the new socket is unknown. conn->socket is marked as -1. */
...
@@ -738,6 +752,11 @@ int lwip_close(int s)
...
@@ -738,6 +752,11 @@ int lwip_close(int s)
return
-
1
;
return
-
1
;
}
}
/*Do not set callback function when tcp->state is LISTEN.
Avoid memory overlap when conn->tcp changes from
struct tcp_bcb to struct tcp_pcb_listen after lwip_listen.*/
if
(
sock
->
conn
->
tcp
->
state
!=
LISTEN
)
{
if
(
sock
->
conn
->
state
!=
NETCONN_STATE_ERROR
){
if
(
sock
->
conn
->
state
!=
NETCONN_STATE_ERROR
){
tcp_recv
(
sock
->
conn
->
tcp
,
NULL
);
tcp_recv
(
sock
->
conn
->
tcp
,
NULL
);
err
=
tcp_close
(
sock
->
conn
->
tcp
);
err
=
tcp_close
(
sock
->
conn
->
tcp
);
...
@@ -749,9 +768,11 @@ int lwip_close(int s)
...
@@ -749,9 +768,11 @@ int lwip_close(int s)
return
-
1
;
return
-
1
;
}
}
}
}
/* closing succeeded */
/* closing succeeded */
remove_tcp
(
sock
->
conn
);
remove_tcp
(
sock
->
conn
);
}
else
{
tcp_close
(
sock
->
conn
->
tcp
);
}
free_netconn
(
sock
->
conn
);
free_netconn
(
sock
->
conn
);
free_socket
(
sock
);
free_socket
(
sock
);
return
ERR_OK
;
return
ERR_OK
;
...
...
app/modules/tls.c
View file @
96601b68
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include "mem.h"
#include "mem.h"
#include "lwip/ip_addr.h"
#include "lwip/ip_addr.h"
#include "espconn.h"
#include "espconn.h"
#include "sys/espconn_mbedtls.h"
#include "lwip/err.h"
#include "lwip/err.h"
#include "lwip/dns.h"
#include "lwip/dns.h"
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment