Commit a33e3a4a authored by Vowstar's avatar Vowstar
Browse files

Merge pull request #687 from DiUS/dev140

Major upgrade to SDK 1.4.0 & open LWIP
parents 093a8959 8fba0f47
sudo: false
language: cpp language: cpp
before_install: addons:
- sudo apt-get install -y python-serial srecord apt:
packages:
- python-serial
- srecord
install: install:
- tar -zxvf tools/esp-open-sdk.tar.gz - tar -zxvf tools/esp-open-sdk.tar.gz
- export PATH=$PATH:$PWD/esp-open-sdk/sdk:$PWD/esp-open-sdk/xtensa-lx106-elf/bin - export PATH=$PATH:$PWD/esp-open-sdk/xtensa-lx106-elf/bin
script: script:
- make all - export BUILD_DATE=$(date +%Y%m%d)
- make EXTRA_CCFLAGS="-DBUILD_DATE='\"'$BUILD_DATE'\"'" all
- cd bin/ - cd bin/
- file_name_float="nodemcu_float_${TRAVIS_TAG}.bin" - file_name_float="nodemcu_float_${TRAVIS_TAG}.bin"
- srec_cat -output ${file_name_float} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000 - srec_cat -output ${file_name_float} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000
- cd ../ - cd ../
- make clean - make clean
- make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL" - make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL -DBUILD_DATE='\"'$BUILD_DATE'\"'"
- cd bin/ - cd bin/
- file_name_integer="nodemcu_integer_${TRAVIS_TAG}.bin" - file_name_integer="nodemcu_integer_${TRAVIS_TAG}.bin"
- srec_cat -output ${file_name_integer} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000 - srec_cat -output ${file_name_integer} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000
......
# copyright (c) 2010 Espressif System # copyright (c) 2010 Espressif System
# #
.NOTPARALLEL:
ifndef PDIR ifndef PDIR
endif endif
# SDK version NodeMCU is locked to
SDK_VER:=1.4.0
# Ensure we search "our" SDK before the tool-chain's SDK (if any)
TOP_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
SDK_DIR:=$(TOP_DIR)sdk/esp_iot_sdk_v$(SDK_VER)
CCFLAGS:= -I$(TOP_DIR)sdk-overrides/include -I$(SDK_DIR)/include
LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS)
############################################################# #############################################################
# Select compile # Select compile
# #
......
...@@ -24,12 +24,12 @@ SPECIAL_MKTARGETS=$(APP_MKTARGETS) ...@@ -24,12 +24,12 @@ SPECIAL_MKTARGETS=$(APP_MKTARGETS)
SUBDIRS= \ SUBDIRS= \
user \ user \
driver \ driver \
lwip \
json \ json \
upgrade \ upgrade \
platform \ platform \
libc \ libc \
lua \ lua \
lwip \
coap \ coap \
mqtt \ mqtt \
u8glib \ u8glib \
...@@ -64,25 +64,17 @@ ifeq ($(FLAVOR),release) ...@@ -64,25 +64,17 @@ ifeq ($(FLAVOR),release)
TARGET_LDFLAGS += -Os TARGET_LDFLAGS += -Os
endif endif
LD_FILE = $(LDDIR)/eagle.app.v6.ld LD_FILE = $(LDDIR)/nodemcu.ld
ifeq ($(APP), 1)
LD_FILE = $(LDDIR)/eagle.app.v6.app1.ld
endif
ifeq ($(APP), 2)
LD_FILE = $(LDDIR)/eagle.app.v6.app2.ld
endif
COMPONENTS_eagle.app.v6 = \ COMPONENTS_eagle.app.v6 = \
user/libuser.a \ user/libuser.a \
driver/libdriver.a \ driver/libdriver.a \
lwip/liblwip.a \
json/libjson.a \ json/libjson.a \
upgrade/libupgrade.a \ upgrade/libupgrade.a \
platform/libplatform.a \ platform/libplatform.a \
libc/liblibc.a \ libc/liblibc.a \
lua/liblua.a \ lua/liblua.a \
lwip/liblwip.a \
coap/coap.a \ coap/coap.a \
mqtt/mqtt.a \ mqtt/mqtt.a \
u8glib/u8glib.a \ u8glib/u8glib.a \
...@@ -93,17 +85,18 @@ COMPONENTS_eagle.app.v6 = \ ...@@ -93,17 +85,18 @@ COMPONENTS_eagle.app.v6 = \
cjson/libcjson.a \ cjson/libcjson.a \
crypto/libcrypto.a \ crypto/libcrypto.a \
dhtlib/libdhtlib.a \ dhtlib/libdhtlib.a \
tsl2561/tsl2561lib.a \ tsl2561/tsl2561lib.a \
modules/libmodules.a modules/libmodules.a
LINKFLAGS_eagle.app.v6 = \ LINKFLAGS_eagle.app.v6 = \
-L../lib \
-Wl,--gc-sections \ -Wl,--gc-sections \
-Xlinker -Map=mapfile \ -Wl,-Map=mapfile \
-nostdlib \ -nostdlib \
-T$(LD_FILE) \ -T$(LD_FILE) \
-Wl,@../ld/defsym.rom \
-Wl,--no-check-sections \ -Wl,--no-check-sections \
-Wl,--wrap=_xtos_set_exception_handler \ -Wl,--wrap=_xtos_set_exception_handler \
-Wl,-static \ -Wl,-static \
-Wl,--start-group \ -Wl,--start-group \
-lc \ -lc \
...@@ -123,7 +116,7 @@ LINKFLAGS_eagle.app.v6 = \ ...@@ -123,7 +116,7 @@ LINKFLAGS_eagle.app.v6 = \
DEPENDS_eagle.app.v6 = \ DEPENDS_eagle.app.v6 = \
$(LD_FILE) \ $(LD_FILE) \
$(LDDIR)/eagle.rom.addr.v6.ld Makefile
############################################################# #############################################################
# Configuration i.e. compile options etc. # Configuration i.e. compile options etc.
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
extern "C" { extern "C" {
#endif #endif
#include "c_types.h"
#include "lwip/ip_addr.h"
#include "espconn.h" #include "espconn.h"
#include "pdu.h" #include "pdu.h"
#include "hash.h" #include "hash.h"
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "lualib.h" #include "lualib.h"
#include "os_type.h" #include "os_type.h"
#include "user_interface.h"
#include "user_config.h"
void build_well_known_rsp(char *rsp, uint16_t rsplen); void build_well_known_rsp(char *rsp, uint16_t rsplen);
...@@ -164,8 +166,6 @@ end: ...@@ -164,8 +166,6 @@ end:
} }
extern lua_Load gLoad; extern lua_Load gLoad;
extern os_timer_t lua_timer;
extern void dojob(lua_Load *load);
static const coap_endpoint_path_t path_command = {2, {"v1", "c"}}; static const coap_endpoint_path_t path_command = {2, {"v1", "c"}};
static int handle_post_command(const coap_endpoint_t *ep, coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo) static int handle_post_command(const coap_endpoint_t *ep, coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)
{ {
...@@ -184,9 +184,7 @@ static int handle_post_command(const coap_endpoint_t *ep, coap_rw_buffer_t *scra ...@@ -184,9 +184,7 @@ static int handle_post_command(const coap_endpoint_t *ep, coap_rw_buffer_t *scra
NODE_DBG("Get command:\n"); NODE_DBG("Get command:\n");
NODE_DBG(load->line); // buggy here NODE_DBG(load->line); // buggy here
NODE_DBG("\nResult(if any):\n"); NODE_DBG("\nResult(if any):\n");
os_timer_disarm(&lua_timer); system_os_post (LUA_TASK_PRIO, LUA_PROCESS_LINE_SIG, 0);
os_timer_setfn(&lua_timer, (os_timer_func_t *)dojob, load);
os_timer_arm(&lua_timer, READLINE_INTERVAL, 0); // no repeat
} }
return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_TEXT_PLAIN); return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_TEXT_PLAIN);
} }
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
#include "digests.h" #include "digests.h"
#include "user_config.h" #include "user_config.h"
#include "rom.h" #include "rom.h"
#include "lwip/mem.h" #include "osapi.h"
#include "mem.h"
#include <string.h> #include <string.h>
#include <c_errno.h> #include <c_errno.h>
...@@ -108,7 +109,7 @@ int ICACHE_FLASH_ATTR crypto_hash (const digest_mech_info_t *mi, ...@@ -108,7 +109,7 @@ int ICACHE_FLASH_ATTR crypto_hash (const digest_mech_info_t *mi,
if (!mi) if (!mi)
return EINVAL; return EINVAL;
void *ctx = os_malloc (mi->ctx_size); void *ctx = (void *)os_malloc (mi->ctx_size);
if (!ctx) if (!ctx)
return ENOMEM; return ENOMEM;
...@@ -129,7 +130,7 @@ int ICACHE_FLASH_ATTR crypto_hmac (const digest_mech_info_t *mi, ...@@ -129,7 +130,7 @@ int ICACHE_FLASH_ATTR crypto_hmac (const digest_mech_info_t *mi,
if (!mi) if (!mi)
return EINVAL; return EINVAL;
void *ctx = os_malloc (mi->ctx_size); void *ctx = (void *)os_malloc (mi->ctx_size);
if (!ctx) if (!ctx)
return ENOMEM; return ENOMEM;
......
...@@ -253,7 +253,7 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay) ...@@ -253,7 +253,7 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay)
// delay(wakeupDelay); // delay(wakeupDelay);
for (i = 0; i < wakeupDelay; i++) os_delay_us(1000); for (i = 0; i < wakeupDelay; i++) os_delay_us(1000);
// Disable interrupts // Disable interrupts
os_intr_lock(); ets_intr_lock();
// digitalWrite(pin, HIGH); // T-go // digitalWrite(pin, HIGH); // T-go
DIRECT_WRITE_HIGH(pin); DIRECT_WRITE_HIGH(pin);
os_delay_us(40); os_delay_us(40);
...@@ -306,7 +306,7 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay) ...@@ -306,7 +306,7 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay)
} }
} }
// Enable interrupts // Enable interrupts
os_intr_unlock(); ets_intr_unlock();
// pinMode(pin, OUTPUT); // pinMode(pin, OUTPUT);
DIRECT_MODE_OUTPUT(pin); DIRECT_MODE_OUTPUT(pin);
// digitalWrite(pin, HIGH); // digitalWrite(pin, HIGH);
...@@ -316,4 +316,4 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay) ...@@ -316,4 +316,4 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay)
} }
// //
// END OF FILE // END OF FILE
// //
\ No newline at end of file
...@@ -60,8 +60,8 @@ sample code bearing this copyright. ...@@ -60,8 +60,8 @@ sample code bearing this copyright.
#include "platform.h" #include "platform.h"
#include "osapi.h" #include "osapi.h"
#define noInterrupts os_intr_lock #define noInterrupts ets_intr_lock
#define interrupts os_intr_unlock #define interrupts ets_intr_unlock
#define delayMicroseconds os_delay_us #define delayMicroseconds os_delay_us
// 1 for keeping the parasitic power on H // 1 for keeping the parasitic power on H
......
...@@ -13,10 +13,19 @@ ...@@ -13,10 +13,19 @@
#include "osapi.h" #include "osapi.h"
#include "driver/uart.h" #include "driver/uart.h"
#include "user_config.h" #include "user_config.h"
#include "user_interface.h"
#define UART0 0 #define UART0 0
#define UART1 1 #define UART1 1
#ifndef FUNC_U0RXD
#define FUNC_U0RXD 0
#endif
// For event signalling
static uint8 task = USER_TASK_PRIO_MAX;
static os_signal_t sig;
// UartDev is defined and initialized in rom code. // UartDev is defined and initialized in rom code.
extern UartDevice UartDev; extern UartDevice UartDev;
...@@ -183,6 +192,7 @@ uart0_rx_intr_handler(void *para) ...@@ -183,6 +192,7 @@ uart0_rx_intr_handler(void *para)
*/ */
RcvMsgBuff *pRxBuff = (RcvMsgBuff *)para; RcvMsgBuff *pRxBuff = (RcvMsgBuff *)para;
uint8 RcvChar; uint8 RcvChar;
bool got_input = false;
if (UART_RXFIFO_FULL_INT_ST != (READ_PERI_REG(UART_INT_ST(UART0)) & UART_RXFIFO_FULL_INT_ST)) { if (UART_RXFIFO_FULL_INT_ST != (READ_PERI_REG(UART_INT_ST(UART0)) & UART_RXFIFO_FULL_INT_ST)) {
return; return;
...@@ -216,7 +226,12 @@ uart0_rx_intr_handler(void *para) ...@@ -216,7 +226,12 @@ uart0_rx_intr_handler(void *para)
pRxBuff->pReadPos++; pRxBuff->pReadPos++;
} }
} }
got_input = true;
} }
if (got_input && task != USER_TASK_PRIO_MAX)
system_os_post (task, sig, UART0);
} }
/****************************************************************************** /******************************************************************************
...@@ -224,11 +239,16 @@ uart0_rx_intr_handler(void *para) ...@@ -224,11 +239,16 @@ uart0_rx_intr_handler(void *para)
* Description : user interface for init uart * Description : user interface for init uart
* Parameters : UartBautRate uart0_br - uart0 bautrate * Parameters : UartBautRate uart0_br - uart0 bautrate
* UartBautRate uart1_br - uart1 bautrate * UartBautRate uart1_br - uart1 bautrate
* uint8 task_prio - task priority to signal on input
* os_signal_t sig_input - signal to post
* Returns : NONE * Returns : NONE
*******************************************************************************/ *******************************************************************************/
void ICACHE_FLASH_ATTR void ICACHE_FLASH_ATTR
uart_init(UartBautRate uart0_br, UartBautRate uart1_br) uart_init(UartBautRate uart0_br, UartBautRate uart1_br, uint8 task_prio, os_signal_t sig_input)
{ {
task = task_prio;
sig = sig_input;
// rom use 74880 baut_rate, here reinitialize // rom use 74880 baut_rate, here reinitialize
UartDev.baut_rate = uart0_br; UartDev.baut_rate = uart0_br;
uart_config(UART0); uart_config(UART0);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "uart_register.h" #include "uart_register.h"
#include "eagle_soc.h" #include "eagle_soc.h"
#include "c_types.h" #include "c_types.h"
#include "os_type.h"
#define RX_BUFF_SIZE 0x100 #define RX_BUFF_SIZE 0x100
#define TX_BUFF_SIZE 100 #define TX_BUFF_SIZE 100
...@@ -100,7 +101,7 @@ typedef struct { ...@@ -100,7 +101,7 @@ typedef struct {
int buff_uart_no; //indicate which uart use tx/rx buffer int buff_uart_no; //indicate which uart use tx/rx buffer
} UartDevice; } UartDevice;
void uart_init(UartBautRate uart0_br, UartBautRate uart1_br); void uart_init(UartBautRate uart0_br, UartBautRate uart1_br, uint8 task_prio, os_signal_t sig_input);
void uart0_sendStr(const char *str); void uart0_sendStr(const char *str);
void uart0_putc(const char c); void uart0_putc(const char c);
void uart0_tx_buffer(uint8 *buf, uint16 len); void uart0_tx_buffer(uint8 *buf, uint16 len);
......
#ifndef __DHCPS_H__ #ifndef __DHCPS_H__
#define __DHCPS_H__ #define __DHCPS_H__
typedef struct dhcps_state{ #define USE_DNS
sint16_t state;
} dhcps_state; typedef struct dhcps_state{
sint16_t state;
// ����dhcpclient�Զ����һ��DHCP msg�ṹ�� } dhcps_state;
typedef struct dhcps_msg {
uint8_t op, htype, hlen, hops; // ����dhcpclient�Զ����һ��DHCP msg�ṹ��
uint8_t xid[4]; typedef struct dhcps_msg {
uint16_t secs, flags; uint8_t op, htype, hlen, hops;
uint8_t ciaddr[4]; uint8_t xid[4];
uint8_t yiaddr[4]; uint16_t secs, flags;
uint8_t siaddr[4]; uint8_t ciaddr[4];
uint8_t giaddr[4]; uint8_t yiaddr[4];
uint8_t chaddr[16]; uint8_t siaddr[4];
uint8_t sname[64]; uint8_t giaddr[4];
uint8_t file[128]; uint8_t chaddr[16];
uint8_t options[312]; uint8_t sname[64];
}dhcps_msg; uint8_t file[128];
uint8_t options[312];
#ifndef LWIP_OPEN_SRC }dhcps_msg;
struct dhcps_lease {
uint32 start_ip; #ifndef LWIP_OPEN_SRC
uint32 end_ip; struct dhcps_lease {
}; bool enable;
#endif struct ip_addr start_ip;
struct ip_addr end_ip;
struct dhcps_pool{ };
struct ip_addr ip;
uint8 mac[6]; enum dhcps_offer_option{
uint32 lease_timer; OFFER_START = 0x00,
}; OFFER_ROUTER = 0x01,
OFFER_END
typedef struct _list_node{ };
void *pnode; #endif
struct _list_node *pnext;
}list_node; struct dhcps_pool{
struct ip_addr ip;
#define DHCPS_LEASE_TIMER 0x05A0 uint8 mac[6];
#define DHCPS_MAX_LEASE 0x64 uint32 lease_timer;
#define BOOTP_BROADCAST 0x8000 };
#define DHCP_REQUEST 1 typedef struct _list_node{
#define DHCP_REPLY 2 void *pnode;
#define DHCP_HTYPE_ETHERNET 1 struct _list_node *pnext;
#define DHCP_HLEN_ETHERNET 6 }list_node;
#define DHCP_MSG_LEN 236
extern uint32 dhcps_lease_time;
#define DHCPS_SERVER_PORT 67 #define DHCPS_LEASE_TIMER dhcps_lease_time //0x05A0
#define DHCPS_CLIENT_PORT 68 #define DHCPS_MAX_LEASE 0x64
#define BOOTP_BROADCAST 0x8000
/*
* Advertise DNS capability in DHCP OFFER #define DHCP_REQUEST 1
*/ #define DHCP_REPLY 2
#define USE_DNS 0 #define DHCP_HTYPE_ETHERNET 1
#define DHCP_HLEN_ETHERNET 6
#define DHCPDISCOVER 1 #define DHCP_MSG_LEN 236
#define DHCPOFFER 2
#define DHCPREQUEST 3 #define DHCPS_SERVER_PORT 67
#define DHCPDECLINE 4 #define DHCPS_CLIENT_PORT 68
#define DHCPACK 5
#define DHCPNAK 6 #define DHCPDISCOVER 1
#define DHCPRELEASE 7 #define DHCPOFFER 2
#define DHCPREQUEST 3
#define DHCP_OPTION_SUBNET_MASK 1 #define DHCPDECLINE 4
#define DHCP_OPTION_ROUTER 3 #define DHCPACK 5
#define DHCP_OPTION_DNS_SERVER 6 #define DHCPNAK 6
#define DHCP_OPTION_REQ_IPADDR 50 #define DHCPRELEASE 7
#define DHCP_OPTION_LEASE_TIME 51
#define DHCP_OPTION_MSG_TYPE 53 #define DHCP_OPTION_SUBNET_MASK 1
#define DHCP_OPTION_SERVER_ID 54 #define DHCP_OPTION_ROUTER 3
#define DHCP_OPTION_INTERFACE_MTU 26 #define DHCP_OPTION_DNS_SERVER 6
#define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31 #define DHCP_OPTION_REQ_IPADDR 50
#define DHCP_OPTION_BROADCAST_ADDRESS 28 #define DHCP_OPTION_LEASE_TIME 51
#define DHCP_OPTION_REQ_LIST 55 #define DHCP_OPTION_MSG_TYPE 53
#define DHCP_OPTION_END 255 #define DHCP_OPTION_SERVER_ID 54
#define DHCP_OPTION_INTERFACE_MTU 26
//#define USE_CLASS_B_NET 1 #define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31
#define DHCPS_DEBUG 0 #define DHCP_OPTION_BROADCAST_ADDRESS 28
#define DHCP_OPTION_REQ_LIST 55
#define DHCP_OPTION_END 255
#define DHCPS_STATE_OFFER 1
#define DHCPS_STATE_DECLINE 2 //#define USE_CLASS_B_NET 1
#define DHCPS_STATE_ACK 3 #define DHCPS_DEBUG 0
#define DHCPS_STATE_NAK 4 #define MAX_STATION_NUM 8
#define DHCPS_STATE_IDLE 5
#define DHCPS_STATE_OFFER 1
void dhcps_start(struct ip_info *info); #define DHCPS_STATE_DECLINE 2
void dhcps_stop(void); #define DHCPS_STATE_ACK 3
#define DHCPS_STATE_NAK 4
#endif #define DHCPS_STATE_IDLE 5
#define DHCPS_STATE_RELEASE 6
#define dhcps_router_enabled(offer) ((offer & OFFER_ROUTER) != 0)
void dhcps_start(struct ip_info *info);
void dhcps_stop(void);
#endif
...@@ -21,7 +21,8 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err); ...@@ -21,7 +21,8 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
#define ESPCONN_MEM -1 /* Out of memory error. */ #define ESPCONN_MEM -1 /* Out of memory error. */
#define ESPCONN_TIMEOUT -3 /* Timeout. */ #define ESPCONN_TIMEOUT -3 /* Timeout. */
#define ESPCONN_RTE -4 /* Routing problem. */ #define ESPCONN_RTE -4 /* Routing problem. */
#define ESPCONN_INPROGRESS -5 /* Operation in progress */ #define ESPCONN_INPROGRESS -5 /* Operation in progress */
#define ESPCONN_MAXNUM -7 /* Total number exceeds the set maximum*/
#define ESPCONN_ABRT -8 /* Connection aborted. */ #define ESPCONN_ABRT -8 /* Connection aborted. */
#define ESPCONN_RST -9 /* Connection reset. */ #define ESPCONN_RST -9 /* Connection reset. */
...@@ -29,8 +30,13 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err); ...@@ -29,8 +30,13 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
#define ESPCONN_CONN -11 /* Not connected. */ #define ESPCONN_CONN -11 /* Not connected. */
#define ESPCONN_ARG -12 /* Illegal argument. */ #define ESPCONN_ARG -12 /* Illegal argument. */
#define ESPCONN_IF -14 /* Low_level error */
#define ESPCONN_ISCONN -15 /* Already connected. */ #define ESPCONN_ISCONN -15 /* Already connected. */
#define ESPCONN_HANDSHAKE -28 /* ssl handshake failed */
#define ESPCONN_RESP_TIMEOUT -29 /* ssl handshake no response*/
#define ESPCONN_PROTO_MSG -61 /* ssl application invalid */
#define ESPCONN_SSL 0x01 #define ESPCONN_SSL 0x01
#define ESPCONN_NORM 0x00 #define ESPCONN_NORM 0x00
...@@ -69,6 +75,7 @@ typedef struct _esp_tcp { ...@@ -69,6 +75,7 @@ typedef struct _esp_tcp {
espconn_connect_callback connect_callback; espconn_connect_callback connect_callback;
espconn_reconnect_callback reconnect_callback; espconn_reconnect_callback reconnect_callback;
espconn_connect_callback disconnect_callback; espconn_connect_callback disconnect_callback;
espconn_connect_callback write_finish_fn;
} esp_tcp; } esp_tcp;
typedef struct _esp_udp { typedef struct _esp_udp {
...@@ -106,34 +113,107 @@ struct espconn { ...@@ -106,34 +113,107 @@ struct espconn {
}; };
enum espconn_option{ enum espconn_option{
ESPCONN_REUSEADDR = 1, ESPCONN_START = 0x00,
ESPCONN_REUSEADDR = 0x01,
ESPCONN_NODELAY = 0x02,
ESPCONN_COPY = 0x04,
ESPCONN_KEEPALIVE = 0x08,
ESPCONN_END ESPCONN_END
}; };
enum espconn_level{
ESPCONN_KEEPIDLE,
ESPCONN_KEEPINTVL,
ESPCONN_KEEPCNT
};
struct espconn_packet{
uint16 sent_length; /* sent length successful*/
uint16 snd_buf_size; /* Available buffer size for sending */
uint16 snd_queuelen; /* Available buffer space for sending */
uint16 total_queuelen; /* total Available buffer space for sending */
uint32 packseqno; /* seqno to be sent */
uint32 packseq_nxt; /* seqno expected */
uint32 packnum;
};
typedef struct _espconn_buf{
uint8 *payload;
uint8 *punsent;
uint16 unsent;
uint16 len;
uint16 tot_len;
struct _espconn_buf *pnext;
} espconn_buf;
typedef struct _comon_pkt{ typedef struct _comon_pkt{
void *pcb; void *pcb;
int remote_port; int remote_port;
uint8 remote_ip[4]; uint8 remote_ip[4];
uint8 *ptrbuf; uint32 local_port;
uint32 local_ip;
espconn_buf *pbuf;
espconn_buf *ptail;
uint8* ptrbuf;
uint16 cntr; uint16 cntr;
uint16 write_len;
uint16 write_total;
sint8 err; sint8 err;
uint32 timeout; uint32 timeout;
uint32 recv_check; uint32 recv_check;
uint8 pbuf_num;
struct espconn_packet packet_info;
bool write_flag;
enum espconn_option espconn_opt; enum espconn_option espconn_opt;
os_timer_t ptimer;
}comon_pkt; }comon_pkt;
typedef struct _espconn_msg{ typedef struct _espconn_msg{
struct espconn *pespconn; struct espconn *pespconn;
comon_pkt pcommon; comon_pkt pcommon;
uint8 count_opt; uint8 count_opt;
int16_t hs_status; //the status of the handshake
void *preverse; void *preverse;
void *pssl; void *pssl;
struct _espconn_msg *pnext; struct _espconn_msg *pnext;
//***********Code for WIFI_BLOCK from upper**************
uint8 recv_hold_flag;
uint16 recv_holded_buf_Len;
}espconn_msg; }espconn_msg;
#ifndef _MDNS_INFO
#define _MDNS_INFO
struct mdns_info {
char *host_name;
char *server_name;
uint16 server_port;
unsigned long ipAddr;
char *txt_data[10];
};
#endif
#define linkMax 15
#define espconn_delay_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_NODELAY) != 0)
#define espconn_delay_enabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_NODELAY) == 0)
#define espconn_reuse_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_REUSEADDR) != 0)
#define espconn_copy_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_COPY) != 0)
#define espconn_copy_enabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_COPY) == 0)
#define espconn_keepalive_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_KEEPALIVE) != 0)
#define espconn_keepalive_enabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_KEEPALIVE) == 0)
#define espconn_TaskPrio 26
#define espconn_TaskQueueLen 15
enum espconn_sig {
SIG_ESPCONN_NONE,
SIG_ESPCONN_ERRER,
SIG_ESPCONN_LISTEN,
SIG_ESPCONN_CONNECT,
SIG_ESPCONN_WRITE,
SIG_ESPCONN_SEND,
SIG_ESPCONN_READ,
SIG_ESPCONN_CLOSE
};
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_copy_partial * FunctionName : espconn_copy_partial
* Description : reconnect with host * Description : reconnect with host
...@@ -181,6 +261,16 @@ bool espconn_find_connection(struct espconn *pespconn, espconn_msg **pnode); ...@@ -181,6 +261,16 @@ bool espconn_find_connection(struct espconn *pespconn, espconn_msg **pnode);
sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags); sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags);
/******************************************************************************
* FunctionName : espconn_get_packet_info
* Description : get the packet info with host
* Parameters : espconn -- the espconn used to disconnect the connection
* infoarg -- the packet info
* Returns : the errur code
*******************************************************************************/
sint8 espconn_get_packet_info(struct espconn *espconn, struct espconn_packet* infoarg);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_connect * FunctionName : espconn_connect
* Description : The function given as the connect * Description : The function given as the connect
...@@ -226,6 +316,23 @@ extern sint8 espconn_accept(struct espconn *espconn); ...@@ -226,6 +316,23 @@ extern sint8 espconn_accept(struct espconn *espconn);
extern sint8 espconn_create(struct espconn *espconn); extern sint8 espconn_create(struct espconn *espconn);
/******************************************************************************
* FunctionName : espconn_tcp_get_wnd
* Description : get the window size of simulatenously active TCP connections
* Parameters : none
* Returns : the number of TCP_MSS active TCP connections
*******************************************************************************/
extern uint8 espconn_tcp_get_wnd(void);
/******************************************************************************
* FunctionName : espconn_tcp_set_max_con
* Description : set the window size simulatenously active TCP connections
* Parameters : num -- the number of TCP_MSS
* Returns : ESPCONN_ARG -- Illegal argument
* ESPCONN_OK -- No error
*******************************************************************************/
extern sint8 espconn_tcp_set_wnd(uint8 num);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_tcp_get_max_con * FunctionName : espconn_tcp_get_max_con
* Description : get the number of simulatenously active TCP connections * Description : get the number of simulatenously active TCP connections
...@@ -243,6 +350,42 @@ extern uint8 espconn_tcp_get_max_con(void); ...@@ -243,6 +350,42 @@ extern uint8 espconn_tcp_get_max_con(void);
*******************************************************************************/ *******************************************************************************/
extern sint8 espconn_tcp_set_max_con(uint8 num); extern sint8 espconn_tcp_set_max_con(uint8 num);
/******************************************************************************
* FunctionName : espconn_tcp_get_max_retran
* Description : get the Maximum number of retransmissions of data active TCP connections
* Parameters : none
* Returns : the Maximum number of retransmissions
*******************************************************************************/
extern uint8 espconn_tcp_get_max_retran(void);
/******************************************************************************
* FunctionName : espconn_tcp_set_max_retran
* Description : set the Maximum number of retransmissions of data active TCP connections
* Parameters : num -- the Maximum number of retransmissions
* Returns : result
*******************************************************************************/
extern sint8 espconn_tcp_set_max_retran(uint8 num);
/******************************************************************************
* FunctionName : espconn_tcp_get_max_syn
* Description : get the Maximum number of retransmissions of SYN segments
* Parameters : none
* Returns : the Maximum number of retransmissions
*******************************************************************************/
extern uint8 espconn_tcp_get_max_syn(void);
/******************************************************************************
* FunctionName : espconn_tcp_set_max_syn
* Description : set the Maximum number of retransmissions of SYN segments
* Parameters : num -- the Maximum number of retransmissions
* Returns : result
*******************************************************************************/
extern sint8 espconn_tcp_set_max_syn(uint8 num);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_tcp_get_max_con_allow * FunctionName : espconn_tcp_get_max_con_allow
* Description : get the count of simulatenously active connections on the server * Description : get the count of simulatenously active connections on the server
...@@ -261,6 +404,16 @@ extern sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn); ...@@ -261,6 +404,16 @@ extern sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn);
extern sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num); extern sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num);
/******************************************************************************
* FunctionName : espconn_tcp_set_buf_count
* Description : set the total number of espconn_buf on the unsent lists
* Parameters : espconn -- espconn to set the count
* num -- the total number of espconn_buf
* Returns : result
*******************************************************************************/
extern sint8 espconn_tcp_set_buf_count(struct espconn *espconn, uint8 num);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_regist_time * FunctionName : espconn_regist_time
* Description : used to specify the time that should be called when don't recv data * Description : used to specify the time that should be called when don't recv data
...@@ -283,6 +436,17 @@ extern sint8 espconn_regist_time(struct espconn *espconn, uint32 interval, uint8 ...@@ -283,6 +436,17 @@ extern sint8 espconn_regist_time(struct espconn *espconn, uint32 interval, uint8
extern sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb); extern sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb);
/******************************************************************************
* FunctionName : espconn_regist_sentcb
* Description : Used to specify the function that should be called when data
* has been successfully delivered to the remote host.
* Parameters : espconn -- espconn to set the sent callback
* sent_cb -- sent callback function to call for this espconn
* when data is successfully sent
* Returns : none
*******************************************************************************/
extern sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_sent * FunctionName : espconn_sent
* Description : sent data for client or server * Description : sent data for client or server
...@@ -356,6 +520,27 @@ extern uint32 espconn_port(void); ...@@ -356,6 +520,27 @@ extern uint32 espconn_port(void);
*******************************************************************************/ *******************************************************************************/
extern sint8 espconn_set_opt(struct espconn *espconn, uint8 opt); extern sint8 espconn_set_opt(struct espconn *espconn, uint8 opt);
/******************************************************************************
* FunctionName : espconn_set_keepalive
* Description : access level value for connection so that we set the value for
* keep alive
* Parameters : espconn -- the espconn used to set the connection
* level -- the connection's level
* value -- the value of time(s)
* Returns : access port value
*******************************************************************************/
extern sint8 espconn_set_keepalive(struct espconn *espconn, uint8 level, void* optarg);
/******************************************************************************
* FunctionName : espconn_get_keepalive
* Description : access level value for connection so that we get the value for
* keep alive
* Parameters : espconn -- the espconn used to get the connection
* level -- the connection's level
* Returns : access keep alive value
*******************************************************************************/
extern sint8 espconn_get_keepalive(struct espconn *espconn, uint8 level, void *optarg);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_gethostbyname * FunctionName : espconn_gethostbyname
* Description : Resolve a hostname (string) into an IP address. * Description : Resolve a hostname (string) into an IP address.
...@@ -395,20 +580,85 @@ extern sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip); ...@@ -395,20 +580,85 @@ 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 * FunctionName : espconn_mdns_init
* Description : hold tcp receive * Description : register a device with mdns
* Parameters : espconn -- espconn to hold * Parameters : ipAddr -- the ip address of device
* hostname -- the hostname of device
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
extern sint8 espconn_recv_hold(struct espconn *pespconn); extern void espconn_mdns_init(struct mdns_info *info);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_recv_unhold * FunctionName : espconn_mdns_init
* Description : unhold tcp receive * Description : close mdns socket
* Parameters : espconn -- espconn to unhold * Parameters : void
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
extern sint8 espconn_recv_unhold(struct espconn *pespconn); extern void espconn_mdns_close(void);
/******************************************************************************
* FunctionName : mdns_server_register
* Description : register a server and join a multicast group
* Parameters : none
* Returns : none
*******************************************************************************/
extern void espconn_mdns_server_register(void);
/******************************************************************************
* FunctionName : mdns_server_register
* Description : unregister server and leave multicast group
* Parameters : none
* Returns : none
*******************************************************************************/
extern void espconn_mdns_server_unregister(void);
/******************************************************************************
* FunctionName : espconn_mdns_get_servername
* Description : get server name
* Parameters : none
* Returns : server name
*******************************************************************************/
extern char* espconn_mdns_get_servername(void);
/******************************************************************************
* FunctionName : espconn_mdns_get_servername
* Description : set server name
* Parameters : server name
* Returns : none
*******************************************************************************/
extern void espconn_mdns_set_servername(const char *name);
/******************************************************************************
* FunctionName : espconn_mdns_set_hostname
* Description : set host name
* Parameters : host name
* Returns : none
*******************************************************************************/
extern void espconn_mdns_set_hostname(char *name);
/******************************************************************************
* FunctionName : espconn_mdns_init
* Description : get host name
* Parameters : void
* Returns : hostname
*******************************************************************************/
extern char* espconn_mdns_get_hostname(void);
/******************************************************************************
* FunctionName : espconn_mdns_disable
* Description : join a multicast group
* Parameters : host_ip -- the ip address of udp server
* multicast_ip -- multicast ip given by user
* Returns : none
*******************************************************************************/
extern void espconn_mdns_disable(void);
/******************************************************************************
* FunctionName : espconn_mdns_enable
* Description : enable mdns
* Parameters : void
* Returns : none
*******************************************************************************/
extern void espconn_mdns_enable(void);
/******************************************************************************
* FunctionName : espconn_dns_setserver
* Description : Initialize one of the DNS servers.
* Parameters : numdns -- the index of the DNS server to set must
* be < DNS_MAX_SERVERS = 2
* dnsserver -- IP address of the DNS server to set
* Returns : none
*******************************************************************************/
extern void espconn_dns_setserver(u8_t numdns, ip_addr_t *dnsserver);
#endif #endif
#ifndef __ESPCONN_TCP_H__ #ifndef __ESPCONN_TCP_H__
#define __ESPCONN_TCP_H__ #define __ESPCONN_TCP_H__
#ifndef ESPCONN_TCP_DEBUG #ifndef ESPCONN_TCP_DEBUG
#define ESPCONN_TCP_DEBUG LWIP_DBG_OFF #define ESPCONN_TCP_DEBUG LWIP_DBG_OFF
#endif #endif
#include "lwip/app/espconn.h" #include "lwip/app/espconn.h"
#ifndef ESPCONN_TCP_TIMER #ifndef ESPCONN_TCP_TIMER
#define ESPCONN_TCP_TIMER 40 #define ESPCONN_TCP_TIMER 40
#endif #endif
/****************************************************************************** #define espconn_keepalive_enable(pcb) ((pcb)->so_options |= SOF_KEEPALIVE)
* FunctionName : espconn_tcp_disconnect #define espconn_keepalive_disable(pcb) ((pcb)->so_options &= ~SOF_KEEPALIVE)
* Description : A new incoming connection has been disconnected.
* Parameters : espconn -- the espconn used to disconnect with host /******************************************************************************
* Returns : none * FunctionName : espconn_kill_oldest_pcb
*******************************************************************************/ * Description : A oldest incoming connection has been killed.
* Parameters : none
extern void espconn_tcp_disconnect(espconn_msg *pdiscon); * Returns : none
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_tcp_client extern void espconn_kill_oldest_pcb(void);
* Description : Initialize the client: set up a connect PCB and bind it to
* the defined port /******************************************************************************
* Parameters : espconn -- the espconn used to build client * FunctionName : espconn_tcp_disconnect
* Returns : none * Description : A new incoming connection has been disconnected.
*******************************************************************************/ * Parameters : espconn -- the espconn used to disconnect with host
* Returns : none
extern sint8 espconn_tcp_client(struct espconn* espconn); *******************************************************************************/
/****************************************************************************** extern void espconn_tcp_disconnect(espconn_msg *pdiscon);
* FunctionName : espconn_tcp_server
* Description : Initialize the server: set up a listening PCB and bind it to /******************************************************************************
* the defined port * FunctionName : espconn_tcp_client
* Parameters : espconn -- the espconn used to build server * Description : Initialize the client: set up a connect PCB and bind it to
* Returns : none * the defined port
*******************************************************************************/ * Parameters : espconn -- the espconn used to build client
* Returns : none
extern sint8 espconn_tcp_server(struct espconn *espconn); *******************************************************************************/
#endif /* __CLIENT_TCP_H__ */ extern sint8 espconn_tcp_client(struct espconn* espconn);
/******************************************************************************
* FunctionName : espconn_tcp_server
* Description : Initialize the server: set up a listening PCB and bind it to
* the defined port
* Parameters : espconn -- the espconn used to build server
* Returns : none
*******************************************************************************/
extern sint8 espconn_tcp_server(struct espconn *espconn);
#endif /* __CLIENT_TCP_H__ */
#ifndef __ESPCONN_UDP_H__ #ifndef __ESPCONN_UDP_H__
#define __ESPCONN_UDP_H__ #define __ESPCONN_UDP_H__
#ifndef ESPCONN_UDP_DEBUG #ifndef ESPCONN_UDP_DEBUG
#define ESPCONN_UDP_DEBUG LWIP_DBG_OFF #define ESPCONN_UDP_DEBUG LWIP_DBG_OFF
#endif #endif
#include "lwip/app/espconn.h" #include "lwip/app/espconn.h"
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_udp_client * FunctionName : espconn_udp_client
* Description : Initialize the client: set up a PCB and bind it to the port * Description : Initialize the client: set up a PCB and bind it to the port
* Parameters : pespconn -- the espconn used to build client * Parameters : pespconn -- the espconn used to build client
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
extern sint8 espconn_udp_client(struct espconn *pespconn); extern sint8 espconn_udp_client(struct espconn *pespconn);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_udp_disconnect * FunctionName : espconn_udp_disconnect
* Description : A new incoming connection has been disconnected. * Description : A new incoming connection has been disconnected.
* Parameters : espconn -- the espconn used to disconnect with host * Parameters : espconn -- the espconn used to disconnect with host
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
extern void espconn_udp_disconnect(espconn_msg *pdiscon); extern void espconn_udp_disconnect(espconn_msg *pdiscon);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_udp_server * FunctionName : espconn_udp_server
* Description : Initialize the server: set up a PCB and bind it to the port * Description : Initialize the server: set up a PCB and bind it to the port
* Parameters : pespconn -- the espconn used to build server * Parameters : pespconn -- the espconn used to build server
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
extern sint8 espconn_udp_server(struct espconn *espconn); extern sint8 espconn_udp_server(struct espconn *espconn);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_udp_sent * FunctionName : espconn_udp_sent
* Description : sent data for client or server * Description : sent data for client or server
* Parameters : void *arg -- client or server to send * Parameters : void *arg -- client or server to send
* uint8* psent -- Data to send * uint8* psent -- Data to send
* uint16 length -- Length of data to send * uint16 length -- Length of data to send
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
extern void espconn_udp_sent(void *arg, uint8 *psent, uint16 length); extern err_t espconn_udp_sent(void *arg, uint8 *psent, uint16 length);
/******************************************************************************
#endif /* __ESPCONN_UDP_H__ */ * FunctionName : espconn_udp_sendto
* Description : sent data for UDP
* Parameters : void *arg -- UDP to send
* uint8* psent -- Data to send
* uint16 length -- Length of data to send
* Returns : return espconn error code.
* - ESPCONN_OK. Successful. No error occured.
* - ESPCONN_MEM. Out of memory.
* - ESPCONN_RTE. Could not find route to destination address.
* - More errors could be returned by lower protocol layers.
*******************************************************************************/
extern err_t espconn_udp_sendto(void *arg, uint8 *psent, uint16 length);
#endif /* __ESPCONN_UDP_H__ */
...@@ -207,6 +207,15 @@ void dhcp_fine_tmr(void); ...@@ -207,6 +207,15 @@ void dhcp_fine_tmr(void);
#define DHCP_OPTION_TCP_TTL 37 #define DHCP_OPTION_TCP_TTL 37
#define DHCP_OPTION_END 255 #define DHCP_OPTION_END 255
/**add options for support more router by liuHan**/
#define DHCP_OPTION_DOMAIN_NAME 15
#define DHCP_OPTION_PRD 31
#define DHCP_OPTION_STATIC_ROUTER 33
#define DHCP_OPTION_VSN 43
#define DHCP_OPTION_NB_TINS 44
#define DHCP_OPTION_NB_TINT 46
#define DHCP_OPTION_NB_TIS 47
#define DHCP_OPTION_CLASSLESS_STATIC_ROUTER 121
/** DHCP options */ /** DHCP options */
#define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */ #define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */
#define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */ #define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */
......
...@@ -96,7 +96,7 @@ void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest)ICACHE_FLAS ...@@ -96,7 +96,7 @@ void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest)ICACHE_FLAS
err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)ICACHE_FLASH_ATTR; err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)ICACHE_FLASH_ATTR;
err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)ICACHE_FLASH_ATTR; err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)ICACHE_FLASH_ATTR;
void igmp_tmr(void)ICACHE_FLASH_ATTR; void igmp_tmr(void)ICACHE_FLASH_ATTR;
#define LWIP_RAND() rand() #define LWIP_RAND() r_rand()
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
/**
* lwip MDNS resolver header file.
*
* Created on: Jul 29, 2010
* Author: Daniel Toma
* ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels.
*
* 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.
*/
#ifndef __LWIP_DNS_H__
#define __LWIP_DNS_H__
#include "lwip/opt.h"
#if LWIP_MDNS /* don't build if not configured for use in lwipopts.h */
/** DNS timer period */
#define DNS_TMR_INTERVAL 1000
/** mDNS Address offset flag*/
#define DNS_OFFSET_FLAG 0xC0 /* the offset flag in the DNS message */
#define DNS_DEFAULT_OFFSET 0x0C /* the offset is set at the beginning of the DNS message */
#define DNS_IP_ADDR_LEN 4
/** DNS field TYPE used for "Resource Records" */
#define DNS_RRTYPE_A 1 /* a host address */
#define DNS_RRTYPE_NS 2 /* an authoritative name server */
#define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */
#define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */
#define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */
#define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */
#define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */
#define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */
#define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */
#define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */
#define DNS_RRTYPE_WKS 11 /* a well known service description */
#define DNS_RRTYPE_PTR 12 /* a domain name pointer */
#define DNS_RRTYPE_HINFO 13 /* host information */
#define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */
#define DNS_RRTYPE_MX 15 /* mail exchange */
#define DNS_RRTYPE_TXT 16 /* text strings */
#define DNS_RRTYPE_SRV 33 /* Service record */
#define DNS_RRTYPE_OPT 41 /* EDNS0 OPT record */
#define DNS_RRTYPE_TSIG 250 /* Transaction Signature */
#define DNS_RRTYPE_ANY 255 /*Not a DNS type, but a DNS query type, meaning "all types"*/
/* DNS field CLASS used for "Resource Records" */
#define DNS_RRCLASS_IN 1 /* the Internet */
#define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */
#define DNS_RRCLASS_CH 3 /* the CHAOS class */
#define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */
#define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */
#define DNS_RRCLASS_FLUSH_IN 0x8001/* Flush bit and Internet*/
/** Callback which is invoked when a hostname is found.
* A function of this type must be implemented by the application using the DNS resolver.
* @param name pointer to the name that was looked up.
* @param ipaddr pointer to a struct ip_addr containing the IP address of the hostname,
* or NULL if the name could not be found (or on any other error).
* @param callback_arg a user-specified callback argument passed to dns_gethostbyname
*/
#ifndef _MDNS_INFO
#define _MDNS_INFO
struct mdns_info {
char *host_name;
char *server_name;
uint16 server_port;
unsigned long ipAddr;
char *txt_data[10];
};
#endif
//void mdns_enable(void);
//void mdns_disable(void);
//void mdns_init(struct mdns_info *info);
//void mdns_close(void);
//char* mdns_get_hostname(void);
//void mdns_set_hostname(char *name);
//void mdns_set_servername(const char *name);
//char* mdns_get_servername(void);
//void mdns_server_unregister(void);
//void mdns_server_register(void) ;
//void mdns_tmr(void);
//void Delay(unsigned long ulSeconds);
#endif /* LWIP_DNS */
#endif /* __LWIP_DNS_H__ */
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#define __LWIP_MEM_H__ #define __LWIP_MEM_H__
#include "lwip/opt.h" #include "lwip/opt.h"
#include "mem_manager.h" //#include "mem_manager.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -50,6 +50,7 @@ typedef size_t mem_size_t; ...@@ -50,6 +50,7 @@ typedef size_t mem_size_t;
/* in case C library malloc() needs extra protection, /* in case C library malloc() needs extra protection,
* allow these defines to be overridden. * allow these defines to be overridden.
*/ */
#ifndef MEMLEAK_DEBUG
#ifndef mem_free #ifndef mem_free
#define mem_free vPortFree #define mem_free vPortFree
#endif #endif
...@@ -64,6 +65,28 @@ typedef size_t mem_size_t; ...@@ -64,6 +65,28 @@ typedef size_t mem_size_t;
#endif #endif
#ifndef mem_zalloc #ifndef mem_zalloc
#define mem_zalloc pvPortZalloc #define mem_zalloc pvPortZalloc
#endif
#else
#ifndef mem_free
#define mem_free(s) \
do{\
const char *file = mem_debug_file;\
vPortFree(s, file, __LINE__);\
}while(0)
#endif
#ifndef mem_malloc
#define mem_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__);})
#endif
#ifndef mem_calloc
#define mem_calloc(s) ({const char *file = mem_debug_file; pvPortCalloc(s, file, __LINE__);})
#endif
#ifndef mem_realloc
#define mem_realloc(p, s) ({const char *file = mem_debug_file; pvPortRealloc(p, s, file, __LINE__);})
#endif
#ifndef mem_zalloc
#define mem_zalloc(s) ({const char *file = mem_debug_file; pvPortZalloc(s, file, __LINE__);})
#endif
#endif #endif
#ifndef os_malloc #ifndef os_malloc
......
...@@ -76,7 +76,7 @@ typedef enum { ...@@ -76,7 +76,7 @@ typedef enum {
#endif /* MEM_USE_POOLS */ #endif /* MEM_USE_POOLS */
#if MEMP_MEM_MALLOC || MEM_USE_POOLS #if MEMP_MEM_MALLOC || MEM_USE_POOLS
extern const u16_t memp_sizes[MEMP_MAX]; extern const u32_t memp_sizes[MEMP_MAX];
#endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */ #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */
#if MEMP_MEM_MALLOC #if MEMP_MEM_MALLOC
......
...@@ -130,6 +130,9 @@ typedef void (*netif_status_callback_fn)(struct netif *netif); ...@@ -130,6 +130,9 @@ typedef void (*netif_status_callback_fn)(struct netif *netif);
typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif,
ip_addr_t *group, u8_t action); ip_addr_t *group, u8_t action);
/*add DHCP event processing by LiuHan*/
typedef void (*dhcp_event_fn)(void);
/** Generic data structure used for all lwIP network interfaces. /** Generic data structure used for all lwIP network interfaces.
* The following fields should be filled in by the initialization * The following fields should be filled in by the initialization
* function for the device driver: hwaddr_len, hwaddr[], mtu, flags */ * function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
...@@ -169,6 +172,8 @@ struct netif { ...@@ -169,6 +172,8 @@ struct netif {
#if LWIP_DHCP #if LWIP_DHCP
/** the DHCP client state information for this netif */ /** the DHCP client state information for this netif */
struct dhcp *dhcp; struct dhcp *dhcp;
struct udp_pcb *dhcps_pcb; //dhcps
dhcp_event_fn dhcp_event;
#endif /* LWIP_DHCP */ #endif /* LWIP_DHCP */
#if LWIP_AUTOIP #if LWIP_AUTOIP
/** the AutoIP client state information for this netif */ /** the AutoIP client state information for this netif */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment