1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-12 01:53:07 +03:00

Update SDK to 1.5.3

This commit is contained in:
Ivan Grokhotkov
2016-05-06 19:33:48 +08:00
parent d3434d345d
commit f266f8a2ff
27 changed files with 841 additions and 675 deletions

View File

@ -35,10 +35,23 @@ enum dhcps_offer_option{
};
#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 ip_addr ip;
uint8 mac[6];
uint32 lease_timer;
dhcps_type_t type;
dhcps_state_t state;
};
typedef struct _list_node{

View File

@ -127,6 +127,14 @@ enum espconn_level{
ESPCONN_KEEPCNT
};
enum espconn_mode{
ESPCONN_NOMODE,
ESPCONN_TCPSERVER_MODE,
ESPCONN_TCPCLIENT_MODE,
ESPCONN_UDP_MODE,
ESPCONN_NUM_MODE
};
struct espconn_packet{
uint16 sent_length; /* sent length successful*/
uint16 snd_buf_size; /* Available buffer size for sending */
@ -169,6 +177,7 @@ typedef struct _espconn_msg{
struct espconn *pespconn;
comon_pkt pcommon;
uint8 count_opt;
uint8 espconn_mode;
sint16_t hs_status; //the status of the handshake
void *preverse;
void *pssl;

View File

@ -569,7 +569,7 @@
* IP_DEFAULT_TTL: Default value for Time-To-Live used by transport layers.
*/
#ifndef IP_DEFAULT_TTL
#define IP_DEFAULT_TTL 255
#define IP_DEFAULT_TTL 128
#endif
/**

File diff suppressed because it is too large Load Diff

View File

@ -264,6 +264,7 @@ espconn_connect(struct espconn *espconn)
uint8 connect_status = 0;
sint8 value = ESPCONN_OK;
espconn_msg *plist = NULL;
remot_info *pinfo = NULL;
if (espconn == NULL) {
return ESPCONN_ARG;
@ -448,6 +449,7 @@ espconn_sendto(struct espconn *espconn, uint8 *psent, uint16 length)
{
espconn_msg *pnode = NULL;
bool value = false;
err_t error = ESPCONN_OK;
if (espconn == NULL || psent == NULL || length == 0) {
return ESPCONN_ARG;
@ -674,7 +676,8 @@ sint8 ICACHE_FLASH_ATTR espconn_tcp_set_buf_count(struct espconn *espconn, uint8
}
}
return ESPCONN_ARG;
if (plist == NULL)
return ESPCONN_ARG;
}
/******************************************************************************
@ -951,7 +954,7 @@ espconn_disconnect(struct espconn *espconn)
if (value){
/*protect for redisconnection*/
if (espconn->state == ESPCONN_CLOSE)
if (pnode->preverse == NULL && espconn->state == ESPCONN_CLOSE)
return ESPCONN_INPROGRESS;
espconn_tcp_disconnect(pnode,0); //1 force, 0 normal
return ESPCONN_OK;

View File

@ -152,6 +152,7 @@ void ICACHE_FLASH_ATTR espconn_kill_pcb(u16_t port)
struct tcp_pcb *cpcb = NULL;
uint8 i = 0;
struct tcp_pcb *inactive = NULL;
struct tcp_pcb *prev = NULL;
u8_t pcb_remove;
/* Check if the address already is in use (on all lists) */
for (i = 1; i < 4; i++) {
@ -186,7 +187,7 @@ struct tcp_pcb *ICACHE_FLASH_ATTR espconn_find_current_pcb(espconn_msg *pcurrent
uint16 local_port = pcurrent_msg->pcommon.local_port;
uint32 local_ip = pcurrent_msg->pcommon.local_ip;
uint16 remote_port = pcurrent_msg->pcommon.remote_port;
uint32 remote_ip = *((uint32*)(pcurrent_msg->pcommon.remote_ip));
uint32 remote_ip = *((uint32*)&pcurrent_msg->pcommon.remote_ip);
struct tcp_pcb *find_pcb = NULL;
if (pcurrent_msg ->preverse == NULL){/*Find the server's TCP block*/
if (local_ip == 0|| local_port == 0) return pcurrent_msg->pcommon.pcb;
@ -218,6 +219,30 @@ struct tcp_pcb *ICACHE_FLASH_ATTR espconn_find_current_pcb(espconn_msg *pcurrent
return NULL;
}
/******************************************************************************
* FunctionName : espconn_tcp_memp_free
* Description : frees the connection memory in the server mode
* Parameters : arg -- Additional argument to pass to the function
* Returns : none
*******************************************************************************/
void ICACHE_FLASH_ATTR espconn_tcp_memp_free(espconn_msg *pmemp)
{
struct espconn *espconn = NULL;
if (pmemp == NULL)
return;
if (pmemp->espconn_mode == ESPCONN_TCPSERVER_MODE){
if (pmemp->pespconn != NULL && pmemp->pespconn->proto.tcp != NULL)
os_free(pmemp->pespconn->proto.tcp);
pmemp->pespconn->proto.tcp = NULL;
os_free(pmemp->pespconn);
pmemp->pespconn = NULL;
}
os_free(pmemp);
pmemp = NULL;
}
/******************************************************************************
* FunctionName : espconn_tcp_reconnect
* Description : reconnect with host
@ -234,24 +259,15 @@ espconn_tcp_reconnect(void *arg)
espconn_kill_oldest_pcb();
if (precon_cb != NULL) {
struct espconn *espconn = precon_cb->preverse;
re_err = precon_cb->pcommon.err;
if (precon_cb->pespconn != NULL){
if (espconn != NULL){/*Process the server's message block*/
if (precon_cb->pespconn->proto.tcp != NULL){
espconn_copy_partial(espconn, precon_cb->pespconn);
espconn_printf("server: %d.%d.%d.%d : %d reconnection\n", espconn->proto.tcp->remote_ip[0],
espconn->proto.tcp->remote_ip[1],espconn->proto.tcp->remote_ip[2],
espconn->proto.tcp->remote_ip[3],espconn->proto.tcp->remote_port);
os_free(precon_cb->pespconn->proto.tcp);
precon_cb->pespconn->proto.tcp = NULL;
}
os_free(precon_cb->pespconn);
precon_cb->pespconn = NULL;
} else {/*Process the client's message block*/
espconn = precon_cb->pespconn;
espconn_printf("client: %d.%d.%d.%d : %d reconnection\n", espconn->proto.tcp->local_ip[0],
espconn->proto.tcp->local_ip[1],espconn->proto.tcp->local_ip[2],
espconn->proto.tcp->local_ip[3],espconn->proto.tcp->local_port);
}
}
@ -266,11 +282,13 @@ espconn_tcp_reconnect(void *arg)
}
os_bzero(&pktinfo[1], sizeof(struct espconn_packet));
os_memcpy(&pktinfo[1], (void*)&precon_cb->pcommon.packet_info, sizeof(struct espconn_packet));
os_free(precon_cb);
precon_cb = NULL;
if (espconn && espconn->proto.tcp && espconn->proto.tcp->reconnect_callback != NULL) {
espconn->proto.tcp->reconnect_callback(espconn, re_err);
}
/*frees the connection memory*/
espconn_tcp_memp_free(precon_cb);
} else {
espconn_printf("espconn_tcp_reconnect err\n");
}
@ -286,31 +304,24 @@ static void ICACHE_FLASH_ATTR
espconn_tcp_disconnect_successful(void *arg)
{
espconn_msg *pdiscon_cb = arg;
sint8 dis_err = 0;
espconn_buf *pdis_buf = NULL;
espconn_buf *pdis_back = NULL;
espconn_kill_oldest_pcb();
if (pdiscon_cb != NULL) {
struct espconn *espconn = pdiscon_cb->preverse;
dis_err = pdiscon_cb->pcommon.err;
if (pdiscon_cb->pespconn != NULL){
struct tcp_pcb *pcb = NULL;
if (espconn != NULL){/*Process the server's message block*/
if (pdiscon_cb->pespconn->proto.tcp != NULL && espconn->proto.tcp){
espconn_copy_partial(espconn, pdiscon_cb->pespconn);
espconn_printf("server: %d.%d.%d.%d : %d disconnect\n", espconn->proto.tcp->remote_ip[0],
espconn->proto.tcp->remote_ip[1],espconn->proto.tcp->remote_ip[2],
espconn->proto.tcp->remote_ip[3],espconn->proto.tcp->remote_port);
os_free(pdiscon_cb->pespconn->proto.tcp);
pdiscon_cb->pespconn->proto.tcp = NULL;
}
os_free(pdiscon_cb->pespconn);
pdiscon_cb->pespconn = NULL;
} else {/*Process the client's message block*/
espconn = pdiscon_cb->pespconn;
espconn_printf("client: %d.%d.%d.%d : %d disconnect\n", espconn->proto.tcp->local_ip[0],
espconn->proto.tcp->local_ip[1],espconn->proto.tcp->local_ip[2],
espconn->proto.tcp->local_ip[3],espconn->proto.tcp->local_port);
}
/*process the current TCP block*/
pcb = espconn_find_current_pcb(pdiscon_cb);
if (pcb != NULL){
@ -365,11 +376,13 @@ espconn_tcp_disconnect_successful(void *arg)
}
os_bzero(&pktinfo[0], sizeof(struct espconn_packet));
os_memcpy(&pktinfo[0], (void*)&pdiscon_cb->pcommon.packet_info, sizeof(struct espconn_packet));
os_free(pdiscon_cb);
pdiscon_cb = NULL;
if (espconn->proto.tcp && espconn->proto.tcp->disconnect_callback != NULL) {
espconn->proto.tcp->disconnect_callback(espconn);
}
/*frees the connection memory*/
espconn_tcp_memp_free(pdiscon_cb);
} else {
espconn_printf("espconn_tcp_disconnect err\n");
}
@ -434,6 +447,7 @@ espconn_tcp_sent(void *arg, uint8 *psent, uint16 length)
struct tcp_pcb *pcb = NULL;
err_t err = 0;
u16_t len = 0;
u8_t data_to_send = false;
espconn_printf("espconn_tcp_sent ptcp_sent %p psent %p length %d\n", ptcp_sent, psent, length);
@ -807,8 +821,6 @@ espconn_client_err(void *arg, err_t err)
case CLOSED:
perr_cb->pcommon.err = ESPCONN_CONN;
break;
default:
break;
}
} else {
perr_cb->pcommon.err = err;
@ -928,6 +940,7 @@ espconn_tcp_client(struct espconn *espconn)
}
#endif
/*Establish the connection*/
pclient->espconn_mode = ESPCONN_TCPCLIENT_MODE;
pclient->pcommon.err = tcp_connect(pcb, &ipaddr,
pclient->pespconn->proto.tcp->remote_port, espconn_client_connect);
if (pclient->pcommon.err == ERR_RTE){
@ -1026,7 +1039,7 @@ espconn_server_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
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, (char*)data_ptr, data_cntr);
precv_cb->pespconn->recv_callback(precv_cb->pespconn, data_ptr, data_cntr);
}
/*switch the state of espconn for next packet copy*/
@ -1236,6 +1249,7 @@ espconn_tcp_accept(void *arg, struct tcp_pcb *pcb, err_t err)
espconn_list_creat(&plink_active, paccept);
paccept->preverse = espconn;
paccept->espconn_mode = ESPCONN_TCPSERVER_MODE;
paccept->pespconn = (struct espconn *)os_zalloc(sizeof(struct espconn));
if (paccept->pespconn == NULL)
return ERR_MEM;
@ -1345,13 +1359,13 @@ espconn_tcp_server(struct espconn *espconn)
*******************************************************************************/
sint8 ICACHE_FLASH_ATTR espconn_tcp_delete(struct espconn *pdeletecon)
{
err_t err = ESPCONN_ARG;
err_t err;
remot_info *pinfo = NULL;
espconn_msg *pdelete_msg = NULL;
struct tcp_pcb *pcb = NULL;
if (pdeletecon == NULL)
return err;
return ESPCONN_ARG;
espconn_get_connection_info(pdeletecon, &pinfo , 0);
/*make sure all the active connection have been disconnect*/
@ -1374,7 +1388,10 @@ sint8 ICACHE_FLASH_ATTR espconn_tcp_delete(struct espconn *pdeletecon)
}
pdelete_msg = pdelete_msg->pnext;
}
return err;
if (err == ERR_OK)
return err;
else
return ESPCONN_ARG;
}
}

View File

@ -285,6 +285,7 @@ espconn_udp_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p,
struct ip_addr *addr, u16_t port)
{
espconn_msg *precv = arg;
struct pbuf *q = NULL;
u8_t *pdata = NULL;
u16_t length = 0;
struct ip_info ipconfig;
@ -320,7 +321,7 @@ espconn_udp_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p,
pbuf_free(p);
if (length != 0) {
if (precv->pespconn->recv_callback != NULL) {
precv->pespconn->recv_callback(precv->pespconn, (char *)pdata, length);
precv->pespconn->recv_callback(precv->pespconn, pdata, length);
}
}
os_free(pdata);

View File

@ -109,7 +109,7 @@ ping_prepare_echo( struct icmp_echo_hdr *iecho, u16_t len)
iecho->chksum = inet_chksum(iecho, len);
}
/*
static void ICACHE_FLASH_ATTR
ping_prepare_er(struct icmp_echo_hdr *iecho, u16_t len)
{
@ -120,7 +120,7 @@ ping_prepare_er(struct icmp_echo_hdr *iecho, u16_t len)
iecho->chksum = inet_chksum(iecho, len);
}
*/
/* Ping using the raw ip */
static u8_t ICACHE_FLASH_ATTR
ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *addr)

View File

@ -450,26 +450,25 @@ dns_local_addhost(const char *hostname, const ip_addr_t *addr)
* better check for failure: != IPADDR_NONE) or IPADDR_NONE if the hostname
* was not found in the cached dns_table.
*/
/*
static u32_t ICACHE_FLASH_ATTR
dns_lookup(const char *name)
{
u8_t i;
#if DNS_LOCAL_HOSTLIST || defined(DNS_LOOKUP_LOCAL_EXTERN)
u32_t addr;
#endif
#endif /* DNS_LOCAL_HOSTLIST || defined(DNS_LOOKUP_LOCAL_EXTERN) */
#if DNS_LOCAL_HOSTLIST
if ((addr = dns_lookup_local(name)) != IPADDR_NONE) {
return addr;
}
#endif
#endif /* DNS_LOCAL_HOSTLIST */
#ifdef DNS_LOOKUP_LOCAL_EXTERN
if((addr = DNS_LOOKUP_LOCAL_EXTERN(name)) != IPADDR_NONE) {
return addr;
}
#endif
#endif /* DNS_LOOKUP_LOCAL_EXTERN */
// Walk through name list, return entry if found. If not, return NULL.
/* Walk through name list, return entry if found. If not, return NULL. */
for (i = 0; i < DNS_TABLE_SIZE; ++i) {
if ((dns_table[i].state == DNS_STATE_DONE) &&
(strcmp(name, dns_table[i].name) == 0)) {
@ -482,7 +481,7 @@ dns_lookup(const char *name)
return IPADDR_NONE;
}
*/
#if DNS_DOES_NAME_CHECK
/**
* Compare the "dotted" name "query" with the encoded name "response"
@ -775,9 +774,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t
if (i < DNS_TABLE_SIZE) {
pEntry = &dns_table[i];
if(pEntry->state == DNS_STATE_ASKING) {
/* This entry is now completed. */
pEntry->state = DNS_STATE_DONE;
pEntry->err = hdr->flags2 & DNS_FLAG2_ERR_MASK;
pEntry->err = hdr->flags2 & DNS_FLAG2_ERR_MASK;
/* We only care about the question(s) and the answers. The authrr
and the extrarr are simply discarded. */
@ -788,8 +785,11 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t
if (((hdr->flags1 & DNS_FLAG1_RESPONSE) == 0) || (pEntry->err != 0) || (nquestions != 1)) {
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in flags\n", pEntry->name));
/* call callback to indicate error, clean up memory and return */
goto responseerr;
//goto responseerr;
goto memerr;
}
/* This entry is now completed. */
pEntry->state = DNS_STATE_DONE;
#if DNS_DOES_NAME_CHECK
/* Check if the name in the "question" part match with the name in the entry. */

View File

@ -47,6 +47,7 @@
#include "lwip/inet_chksum.h"
#include "lwip/ip.h"
#include "lwip/def.h"
#include "lwipopts.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"

View File

@ -710,6 +710,17 @@ igmp_start_timer(struct igmp_group *group, u8_t max_time)
group->timer = (LWIP_RAND() % (max_time - 1)) + 1;
}
/**
* Stop a timer for an igmp_group
*
* @param group the igmp_group for which to stop the timer
*/
static void
igmp_stop_timer(struct igmp_group *group)
{
group->timer = 0;
}
/**
* Delaying membership report for a group if necessary
*

View File

@ -900,11 +900,27 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr,
void ICACHE_FLASH_ATTR
mdns_close(void)
{
if (mdns_pcb != NULL && ms_info != NULL)
uint8 text_index = 0;
if (mdns_pcb != NULL && ms_info != NULL) {
udp_remove(mdns_pcb);
for(text_index = 0;text_index < 10;text_index++) {
if(ms_info->txt_data[text_index] != NULL) {
os_free(ms_info->txt_data[text_index]);
ms_info->txt_data[text_index] = NULL;
}
}
if (ms_info->host_name != NULL) {
os_free(ms_info->host_name);
ms_info->host_name = NULL;
}
if (ms_info->server_name != NULL) {
os_free(ms_info->server_name);
ms_info->server_name = NULL;
}
os_free(ms_info);
mdns_pcb = NULL;
ms_info = NULL;
}
}
@ -1034,9 +1050,24 @@ mdns_init(struct mdns_info *info) {
multicast_addr.addr = DNS_MULTICAST_ADDRESS;
struct ip_addr ap_host_addr;
struct ip_info ipconfig;
uint8 text_index = 0;
ms_info = (struct mdns_info *)os_zalloc(sizeof(struct mdns_info));
if (ms_info != NULL) {
os_memcpy(ms_info,info,sizeof(struct mdns_info));
ms_info->host_name = (char *)os_zalloc(os_strlen(info->host_name)+1);
os_memcpy(ms_info->host_name,info->host_name,os_strlen(info->host_name));
ms_info->server_name = (char *)os_zalloc(os_strlen(info->server_name)+1);
os_memcpy(ms_info->server_name,info->server_name,os_strlen(info->server_name));
for(text_index = 0;text_index < 10;text_index++) {
if(info->txt_data[text_index] != NULL) {
ms_info->txt_data[text_index] = (char *)os_zalloc(os_strlen(info->txt_data[text_index])+1);
os_memcpy(ms_info->txt_data[text_index],info->txt_data[text_index],os_strlen(info->txt_data[text_index]));
} else {
break;
}
}
} else {
os_printf("ms_info alloc failed\n");
return;

View File

@ -268,10 +268,7 @@ struct sntp_server {
};
static struct sntp_server sntp_servers[SNTP_MAX_SERVERS];
#if SNTP_GET_SERVERS_FROM_DHCP
static u8_t sntp_set_servers_from_dhcp;
#endif
#if SNTP_SUPPORT_MULTIPLE_SERVERS
/** The currently used server (initialized to 0) */
static u8_t sntp_current_server;
@ -364,6 +361,7 @@ sntp_mktm_r(const time_t * tim_p ,struct tm *res ,int is_gmtime)
{
long days, rem;
time_t lcltime;
int i;
int y;
int yleap;
const int *ip;

View File

@ -114,7 +114,7 @@ tcp_timer_needed(void)
*
* @param arg unused argument
*/
/*
static void ICACHE_FLASH_ATTR
tcp_timer_coarse(void *arg)
{
@ -123,7 +123,7 @@ tcp_timer_coarse(void *arg)
tcp_tmr();
sys_timeout(TCP_TMR_INTERVAL, tcp_timer_coarse, NULL);
}
*/
#endif /* LWIP_TCP */
#if IP_REASSEMBLY