Commit dceed526 authored by Vowstar's avatar Vowstar
Browse files

Merge pull request #470 from nodemcu/dev096

* Update SDK to 0.9.6
* Fix some bugs
* Update examples
* Add crypto module by @creationix 
parents 0ad57470 b0a4e4d3
...@@ -42,7 +42,7 @@ The small 4KB sectors allow for greater flexibility in applications th ...@@ -42,7 +42,7 @@ The small 4KB sectors allow for greater flexibility in applications th
********************/ ********************/
void spiffs_mount() { void myspiffs_mount() {
spiffs_config cfg; spiffs_config cfg;
cfg.phys_addr = ( u32_t )platform_flash_get_first_free_block_address( NULL ); cfg.phys_addr = ( u32_t )platform_flash_get_first_free_block_address( NULL );
cfg.phys_addr += 0x3000; cfg.phys_addr += 0x3000;
...@@ -69,6 +69,10 @@ void spiffs_mount() { ...@@ -69,6 +69,10 @@ void spiffs_mount() {
NODE_DBG("mount res: %i\n", res); NODE_DBG("mount res: %i\n", res);
} }
void myspiffs_unmount() {
SPIFFS_unmount(&fs);
}
// FS formatting function // FS formatting function
// Returns 1 if OK, 0 for error // Returns 1 if OK, 0 for error
int myspiffs_format( void ) int myspiffs_format( void )
...@@ -85,7 +89,7 @@ int myspiffs_format( void ) ...@@ -85,7 +89,7 @@ int myspiffs_format( void )
while( sect_first <= sect_last ) while( sect_first <= sect_last )
if( platform_flash_erase_sector( sect_first ++ ) == PLATFORM_ERR ) if( platform_flash_erase_sector( sect_first ++ ) == PLATFORM_ERR )
return 0; return 0;
spiffs_mount(); myspiffs_mount();
return 1; return 1;
} }
......
...@@ -477,6 +477,8 @@ u32_t SPIFFS_buffer_bytes_for_cache(spiffs *fs, u32_t num_pages); ...@@ -477,6 +477,8 @@ u32_t SPIFFS_buffer_bytes_for_cache(spiffs *fs, u32_t num_pages);
#if SPIFFS_CACHE #if SPIFFS_CACHE
#endif #endif
void myspiffs_mount();
void myspiffs_unmount();
int myspiffs_open(const char *name, int flags); int myspiffs_open(const char *name, int flags);
int myspiffs_close( int fd ); int myspiffs_close( int fd );
size_t myspiffs_write( int fd, const void* ptr, size_t len ); size_t myspiffs_write( int fd, const void* ptr, size_t len );
......
...@@ -395,13 +395,11 @@ typedef struct __attribute(( packed )) { ...@@ -395,13 +395,11 @@ typedef struct __attribute(( packed )) {
// common page header // common page header
spiffs_page_header p_hdr; spiffs_page_header p_hdr;
// alignment // alignment
u8_t _align[4 - (sizeof(spiffs_page_header)&3)==0 ? 4 : (sizeof(spiffs_page_header)&3)]; u8_t _align[4 - ((sizeof(spiffs_page_header)+sizeof(spiffs_obj_type)+SPIFFS_OBJ_NAME_LEN)&3)==0 ? 4 : ((sizeof(spiffs_page_header)+sizeof(spiffs_obj_type)+SPIFFS_OBJ_NAME_LEN)&3)];
// size of object // size of object
u32_t size; u32_t size;
// type of object // type of object
spiffs_obj_type type; spiffs_obj_type type;
// alignment2
u8_t _align2[4 - (sizeof(spiffs_obj_type)&3)==0 ? 4 : (sizeof(spiffs_obj_type)&3)];
// name of object // name of object
u8_t name[SPIFFS_OBJ_NAME_LEN]; u8_t name[SPIFFS_OBJ_NAME_LEN];
} spiffs_page_object_ix_header; } spiffs_page_object_ix_header;
......
...@@ -44,6 +44,7 @@ INCLUDES += -I ../libc ...@@ -44,6 +44,7 @@ INCLUDES += -I ../libc
INCLUDES += -I ../platform INCLUDES += -I ../platform
INCLUDES += -I ../lua INCLUDES += -I ../lua
INCLUDES += -I ../wofs INCLUDES += -I ../wofs
INCLUDES += -I ../spiffs
PDIR := ../$(PDIR) PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile sinclude $(PDIR)Makefile
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
#include "c_stdlib.h" #include "c_stdlib.h"
#include "c_stdio.h" #include "c_stdio.h"
#include "romfs.h" #include "flash_fs.h"
#include "user_interface.h" #include "user_interface.h"
#include "ets_sys.h" #include "ets_sys.h"
...@@ -44,7 +43,6 @@ void task_init(void){ ...@@ -44,7 +43,6 @@ void task_init(void){
system_os_task(task_lua, USER_TASK_PRIO_0, taskQueue, TASK_QUEUE_LEN); system_os_task(task_lua, USER_TASK_PRIO_0, taskQueue, TASK_QUEUE_LEN);
} }
extern void spiffs_mount();
// extern void test_spiffs(); // extern void test_spiffs();
// extern int test_romfs(); // extern int test_romfs();
...@@ -69,7 +67,16 @@ void nodemcu_init(void) ...@@ -69,7 +67,16 @@ void nodemcu_init(void)
// Flash init data at FLASHSIZE - 0x04000 Byte. // Flash init data at FLASHSIZE - 0x04000 Byte.
flash_init_data_default(); flash_init_data_default();
// Flash blank data at FLASHSIZE - 0x02000 Byte. // Flash blank data at FLASHSIZE - 0x02000 Byte.
flash_init_data_blank(); flash_init_data_blank();
if( !fs_format() )
{
NODE_ERR( "\ni*** ERROR ***: unable to format. FS might be compromised.\n" );
NODE_ERR( "It is advised to re-flash the NodeMCU image.\n" );
}
else{
NODE_ERR( "format done.\n" );
}
fs_unmount(); // mounted by format.
} }
#endif // defined(FLASH_SAFE_API) #endif // defined(FLASH_SAFE_API)
...@@ -94,7 +101,7 @@ void nodemcu_init(void) ...@@ -94,7 +101,7 @@ void nodemcu_init(void)
// test_romfs(); // test_romfs();
#elif defined ( BUILD_SPIFFS ) #elif defined ( BUILD_SPIFFS )
spiffs_mount(); fs_mount();
// test_spiffs(); // test_spiffs();
#endif #endif
// endpoint_setup(); // endpoint_setup();
......
...@@ -381,3 +381,141 @@ function TestDNSLeak() ...@@ -381,3 +381,141 @@ function TestDNSLeak()
tmr.alarm(1, 3000, 0, function() print("hack socket close, MEM: "..node.heap()) c:close() end) -- socket timeout hack tmr.alarm(1, 3000, 0, function() print("hack socket close, MEM: "..node.heap()) c:close() end) -- socket timeout hack
print("MEM: "..node.heap()) print("MEM: "..node.heap())
end end
v="abc%0D%0Adef"
print(string.gsub(v, "%%(%x%x)", function(x) return string.char(tonumber(x, 16)) end))
function ex(x) string.find("abc%0Ddef","bc") return 's' end
string.gsub("abc%0Ddef", "%%(%x%x)", ex)
function ex(x) string.char(35) return 's' end
string.gsub("abc%0Ddef", "%%(%x%x)", ex) print("hello")
function ex(x) string.lower('Ab') return 's' end
string.gsub("abc%0Ddef", "%%(%x%x)", ex) print("hello")
v="abc%0D%0Adef"
pcall(function() print(string.gsub(v, "%%(%x%x)", function(x) return string.char(tonumber(x, 16)) end)) end)
mosca -v | bunyan
m=mqtt.Client()
m:connect("192.168.18.88",1883)
topic={}
topic["/topic1"]=0
topic["/topic2"]=0
m:subscribe(topic,function(m) print("sub done") end)
m:on("message",function(m,t,pl) print(t..":") if pl~=nil then print(pl) end end )
m:publish("/topic1","hello",0,0)
m:publish("/topic3","hello",0,0) m:publish("/topic4","hello",0,0)
m=mqtt.Client()
m:connect("192.168.18.88",1883)
m:subscribe("/topic1",0,function(m) print("sub done") end)
m:subscribe("/topic2",0,function(m) print("sub done") end)
m:on("message",function(m,t,pl) print(t..":") if pl~=nil then print(pl) end end )
m:publish("/topic1","hello",0,0)
m:publish("/topic3","hello",0,0) m:publish("/topic4","hello",0,0)
m:publish("/topic1","hello1",0,0) m:publish("/topic2","hello2",0,0)
m:publish("/topic1","hello",1,0)
m:subscribe("/topic3",0,function(m) print("sub done") end)
m:publish("/topic3","hello3",2,0)
m=mqtt.Client()
m:connect("192.168.18.88",1883, function(con) print("connected hello") end)
m=mqtt.Client()
m:on("connect",function(m) print("connection") end )
m:connect("192.168.18.88",1883)
m:on("offline",function(m) print("disconnection") end )
m=mqtt.Client()
m:on("connect",function(m) print("connection "..node.heap()) end )
m:on("offline", function(conn)
if conn == nil then print("conn is nil") end
print("Reconnect to broker...")
print(node.heap())
conn:connect("192.168.18.88",1883,0,1)
end)
m:connect("192.168.18.88",1883,0,1)
m=mqtt.Client()
m:on("connect",function(m) print("connection "..node.heap()) end )
m:on("offline", function(conn)
if conn == nil then print("conn is nil") end
print("Reconnect to broker...")
print(node.heap())
conn:connect("192.168.18.88",1883)
end)
m:connect("192.168.18.88",1883)
m:close()
m=mqtt.Client()
m:connect("192.168.18.88",1883)
m:on("message",function(m,t,pl) print(t..":") if pl~=nil then print(pl) end end )
m:subscribe("/topic1",0,function(m) print("sub done") end)
m:publish("/topic1","hello3",2,0) m:publish("/topic1","hello2",2,0)
m:publish("/topic1","hello3",0,0) m:publish("/topic1","hello2",2,0)
m:subscribe("/topic2",2,function(m) print("sub done") end)
m:publish("/topic2","hello3",0,0) m:publish("/topic2","hello2",2,0)
m=mqtt.Client()
m:on("connect",function(m)
print("connection "..node.heap())
m:subscribe("/topic1",0,function(m) print("sub done") end)
m:publish("/topic1","hello3",0,0) m:publish("/topic1","hello2",2,0)
end )
m:on("offline", function(conn)
print("disconnect to broker...")
print(node.heap())
end)
m:connect("192.168.18.88",1883,0,1)
-- serout( pin, firstLevel, delay_table, [repeatNum] )
gpio.mode(1,gpio.OUTPUT,gpio.PULLUP)
gpio.serout(1,1,{30,30,60,60,30,30}) -- serial one byte, b10110010
gpio.serout(1,1,{30,70},8) -- serial 30% pwm 10k, lasts 8 cycles
gpio.serout(1,1,{3,7},8) -- serial 30% pwm 100k, lasts 8 cycles
gpio.serout(1,1,{0,0},8) -- serial 50% pwm as fast as possible, lasts 8 cycles
gpio.mode(1,gpio.OUTPUT,gpio.PULLUP)
gpio.serout(1,0,{20,10,10,20,10,10,10,100}) -- sim uart one byte 0x5A at about 100kbps
gpio.serout(1,1,{8,18},8) -- serial 30% pwm 38k, lasts 8 cycles
-- Lua: mqtt.Client(clientid, keepalive, user, pass)
-- test with cloudmqtt.com
m_dis={}
function dispatch(m,t,pl)
if pl~=nil and m_dis[t] then
m_dis[t](pl)
end
end
function topic1func(pl)
print("get1: "..pl)
end
function topic2func(pl)
print("get2: "..pl)
end
m_dis["/topic1"]=topic1func
m_dis["/topic2"]=topic2func
m=mqtt.Client("nodemcu1",60,"test","test123")
m:on("connect",function(m)
print("connection "..node.heap())
m:subscribe("/topic1",0,function(m) print("sub done") end)
m:subscribe("/topic2",0,function(m) print("sub done") end)
m:publish("/topic1","hello",0,0) m:publish("/topic2","world",0,0)
end )
m:on("offline", function(conn)
print("disconnect to broker...")
print(node.heap())
end)
m:on("message",dispatch )
m:connect("m11.cloudmqtt.com",11214,0,1)
-- Lua: mqtt:connect( host, port, secure, auto_reconnect, function(client) )
tmr.alarm(0,10000,1,function() local pl = "time: "..tmr.time()
m:publish("/topic1",pl,0,0)
end)
--init.lua, something like this
countdown = 3
tmr.alarm(0,1000,1,function()
print(countdown)
countdown = countdown-1
if countdown<1 then
tmr.stop(0)
countdown = nil
local s,err
if file.open("user.lc") then
file.close()
s,err = pcall(function() dofile("user.lc") end)
else
s,err = pcall(function() dofile("user.lua") end)
end
if not s then print(err) end
end
end)
print("hello NodeMCU")
#ifndef __ESPCONN_H__ #ifndef __ESPCONN_H__
#define __ESPCONN_H__ #define __ESPCONN_H__
#include "lwip/ip_addr.h" #include "lwip/ip_addr.h"
typedef sint8 err_t; typedef sint8 err_t;
typedef void *espconn_handle; typedef void *espconn_handle;
typedef void (* espconn_connect_callback)(void *arg); typedef void (* espconn_connect_callback)(void *arg);
typedef void (* espconn_reconnect_callback)(void *arg, sint8 err); typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
/* Definitions for error constants. */ /* Definitions for error constants. */
#define ESPCONN_OK 0 /* No error, everything OK. */ #define ESPCONN_OK 0 /* No error, everything OK. */
#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_ABRT -8 /* Connection aborted. */ #define ESPCONN_ABRT -8 /* Connection aborted. */
#define ESPCONN_RST -9 /* Connection reset. */ #define ESPCONN_RST -9 /* Connection reset. */
#define ESPCONN_CLSD -10 /* Connection closed. */ #define ESPCONN_CLSD -10 /* Connection closed. */
#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_ISCONN -15 /* Already connected. */ #define ESPCONN_ISCONN -15 /* Already connected. */
/** Protocol family and type of the espconn */ /** Protocol family and type of the espconn */
enum espconn_type { enum espconn_type {
ESPCONN_INVALID = 0, ESPCONN_INVALID = 0,
/* ESPCONN_TCP Group */ /* ESPCONN_TCP Group */
ESPCONN_TCP = 0x10, ESPCONN_TCP = 0x10,
/* ESPCONN_UDP Group */ /* ESPCONN_UDP Group */
ESPCONN_UDP = 0x20, ESPCONN_UDP = 0x20,
}; };
/** Current state of the espconn. Non-TCP espconn are always in state ESPCONN_NONE! */ /** Current state of the espconn. Non-TCP espconn are always in state ESPCONN_NONE! */
enum espconn_state { enum espconn_state {
ESPCONN_NONE, ESPCONN_NONE,
ESPCONN_WAIT, ESPCONN_WAIT,
ESPCONN_LISTEN, ESPCONN_LISTEN,
ESPCONN_CONNECT, ESPCONN_CONNECT,
ESPCONN_WRITE, ESPCONN_WRITE,
ESPCONN_READ, ESPCONN_READ,
ESPCONN_CLOSE ESPCONN_CLOSE
}; };
typedef struct _esp_tcp { typedef struct _esp_tcp {
int remote_port; int remote_port;
int local_port; int local_port;
uint8 local_ip[4]; uint8 local_ip[4];
uint8 remote_ip[4]; uint8 remote_ip[4];
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;
} esp_tcp; espconn_connect_callback write_finish_fn;
} esp_tcp;
typedef struct _esp_udp {
int remote_port; typedef struct _esp_udp {
int local_port; int remote_port;
uint8 local_ip[4]; int local_port;
uint8 remote_ip[4]; uint8 local_ip[4];
} esp_udp; uint8 remote_ip[4];
} esp_udp;
typedef struct _remot_info{
enum espconn_state state; typedef struct _remot_info{
int remote_port; enum espconn_state state;
uint8 remote_ip[4]; int remote_port;
}remot_info; uint8 remote_ip[4];
}remot_info;
/** A callback prototype to inform about events for a espconn */
typedef void (* espconn_recv_callback)(void *arg, char *pdata, unsigned short len); /** A callback prototype to inform about events for a espconn */
typedef void (* espconn_sent_callback)(void *arg); typedef void (* espconn_recv_callback)(void *arg, char *pdata, unsigned short len);
typedef void (* espconn_sent_callback)(void *arg);
/** A espconn descriptor */
struct espconn { /** A espconn descriptor */
/** type of the espconn (TCP, UDP) */ struct espconn {
enum espconn_type type; /** type of the espconn (TCP, UDP) */
/** current state of the espconn */ enum espconn_type type;
enum espconn_state state; /** current state of the espconn */
union { enum espconn_state state;
esp_tcp *tcp; union {
esp_udp *udp; esp_tcp *tcp;
} proto; esp_udp *udp;
/** A callback function that is informed about events for this espconn */ } proto;
espconn_recv_callback recv_callback; /** A callback function that is informed about events for this espconn */
espconn_sent_callback sent_callback; espconn_recv_callback recv_callback;
uint8 link_cnt; espconn_sent_callback sent_callback;
void *reverse; uint8 link_cnt;
}; void *reverse;
};
enum espconn_option{
ESPCONN_REUSEADDR = 1, enum espconn_option{
ESPCONN_NODELAY, ESPCONN_START = 0x00,
ESPCONN_END ESPCONN_REUSEADDR = 0x01,
}; ESPCONN_NODELAY = 0x02,
ESPCONN_COPY = 0x04,
/****************************************************************************** ESPCONN_END
* FunctionName : espconn_connect };
* Description : The function given as the connect
* Parameters : espconn -- the espconn used to listen the connection /******************************************************************************
* Returns : none * FunctionName : espconn_connect
*******************************************************************************/ * Description : The function given as the connect
* Parameters : espconn -- the espconn used to listen the connection
sint8 espconn_connect(struct espconn *espconn); * Returns : none
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_disconnect sint8 espconn_connect(struct espconn *espconn);
* Description : disconnect with host
* Parameters : espconn -- the espconn used to disconnect the connection /******************************************************************************
* Returns : none * FunctionName : espconn_disconnect
*******************************************************************************/ * Description : disconnect with host
* Parameters : espconn -- the espconn used to disconnect the connection
sint8 espconn_disconnect(struct espconn *espconn); * Returns : none
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_delete sint8 espconn_disconnect(struct espconn *espconn);
* Description : disconnect with host
* Parameters : espconn -- the espconn used to disconnect the connection /******************************************************************************
* Returns : none * FunctionName : espconn_delete
*******************************************************************************/ * Description : disconnect with host
* Parameters : espconn -- the espconn used to disconnect the connection
sint8 espconn_delete(struct espconn *espconn); * Returns : none
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_accept sint8 espconn_delete(struct espconn *espconn);
* Description : The function given as the listen
* Parameters : espconn -- the espconn used to listen the connection /******************************************************************************
* Returns : none * FunctionName : espconn_accept
*******************************************************************************/ * Description : The function given as the listen
* Parameters : espconn -- the espconn used to listen the connection
sint8 espconn_accept(struct espconn *espconn); * Returns : none
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_create sint8 espconn_accept(struct espconn *espconn);
* Description : sent data for client or server
* Parameters : espconn -- espconn to the data transmission /******************************************************************************
* Returns : result * FunctionName : espconn_create
*******************************************************************************/ * Description : sent data for client or server
* Parameters : espconn -- espconn to the data transmission
sint8 espconn_create(struct espconn *espconn); * Returns : result
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_tcp_get_max_con sint8 espconn_create(struct espconn *espconn);
* Description : get the number of simulatenously active TCP connections
* Parameters : none /******************************************************************************
* Returns : none * FunctionName : espconn_tcp_get_max_con
*******************************************************************************/ * Description : get the number of simulatenously active TCP connections
* Parameters : none
uint8 espconn_tcp_get_max_con(void); * Returns : none
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_tcp_set_max_con uint8 espconn_tcp_get_max_con(void);
* Description : set the number of simulatenously active TCP connections
* Parameters : num -- total number /******************************************************************************
* Returns : none * FunctionName : espconn_tcp_set_max_con
*******************************************************************************/ * Description : set the number of simulatenously active TCP connections
* Parameters : num -- total number
sint8 espconn_tcp_set_max_con(uint8 num); * Returns : none
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_tcp_get_max_con_allow sint8 espconn_tcp_set_max_con(uint8 num);
* Description : get the count of simulatenously active connections on the server
* Parameters : espconn -- espconn to get the count /******************************************************************************
* Returns : result * FunctionName : espconn_tcp_get_max_con_allow
*******************************************************************************/ * Description : get the count of simulatenously active connections on the server
* Parameters : espconn -- espconn to get the count
sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn); * Returns : result
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_tcp_set_max_con_allow sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn);
* Description : set the count of simulatenously active connections on the server
* Parameters : espconn -- espconn to set the count /******************************************************************************
* num -- support the connection number * FunctionName : espconn_tcp_set_max_con_allow
* Returns : result * Description : set the count of simulatenously active connections on the server
*******************************************************************************/ * Parameters : espconn -- espconn to set the count
* num -- support the connection number
sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num); * Returns : result
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_regist_time sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num);
* Description : used to specify the time that should be called when don't recv data
* Parameters : espconn -- the espconn used to the connection /******************************************************************************
* interval -- the timer when don't recv data * FunctionName : espconn_regist_time
* Returns : none * Description : used to specify the time that should be called when don't recv data
*******************************************************************************/ * Parameters : espconn -- the espconn used to the connection
* interval -- the timer when don't recv data
sint8 espconn_regist_time(struct espconn *espconn, uint32 interval, uint8 type_flag); * Returns : none
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_get_connection_info sint8 espconn_regist_time(struct espconn *espconn, uint32 interval, uint8 type_flag);
* Description : used to specify the function that should be called when disconnect
* Parameters : espconn -- espconn to set the err callback /******************************************************************************
* discon_cb -- err callback function to call when err * FunctionName : espconn_get_connection_info
* Returns : none * Description : used to specify the function that should be called when disconnect
*******************************************************************************/ * Parameters : espconn -- espconn to set the err callback
* discon_cb -- err callback function to call when err
sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags); * Returns : none
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_regist_sentcb sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags);
* Description : Used to specify the function that should be called when data
* has been successfully delivered to the remote host. /******************************************************************************
* Parameters : struct espconn *espconn -- espconn to set the sent callback * FunctionName : espconn_regist_sentcb
* espconn_sent_callback sent_cb -- sent callback function to * Description : Used to specify the function that should be called when data
* call for this espconn when data is successfully sent * has been successfully delivered to the remote host.
* Returns : none * Parameters : struct espconn *espconn -- espconn to set the sent callback
*******************************************************************************/ * espconn_sent_callback sent_cb -- sent callback function to
* call for this espconn when data is successfully sent
sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb); * Returns : none
*******************************************************************************/
/******************************************************************************
* FunctionName : espconn_sent sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb);
* Description : sent data for client or server
* Parameters : espconn -- espconn to set for client or server /******************************************************************************
* psent -- data to send * FunctionName : espconn_regist_sentcb
* length -- length of data to send * Description : Used to specify the function that should be called when data
* Returns : none * 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
sint8 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length); * when data is successfully sent
* Returns : none
/****************************************************************************** *******************************************************************************/
* FunctionName : espconn_regist_connectcb
* Description : used to specify the function that should be called when sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn);
* connects to host.
* Parameters : espconn -- espconn to set the connect callback /******************************************************************************
* connect_cb -- connected callback function to call when connected * FunctionName : espconn_sent
* Returns : none * Description : sent data for client or server
*******************************************************************************/ * Parameters : espconn -- espconn to set for client or server
* psent -- data to send
sint8 espconn_regist_connectcb(struct espconn *espconn, espconn_connect_callback connect_cb); * length -- length of data to send
* Returns : none
/****************************************************************************** *******************************************************************************/
* FunctionName : espconn_regist_recvcb
* Description : used to specify the function that should be called when recv sint8 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length);
* data from host.
* Parameters : espconn -- espconn to set the recv callback /******************************************************************************
* recv_cb -- recv callback function to call when recv data * FunctionName : espconn_regist_connectcb
* Returns : none * Description : used to specify the function that should be called when
*******************************************************************************/ * connects to host.
* Parameters : espconn -- espconn to set the connect callback
sint8 espconn_regist_recvcb(struct espconn *espconn, espconn_recv_callback recv_cb); * connect_cb -- connected callback function to call when connected
* Returns : none
/****************************************************************************** *******************************************************************************/
* FunctionName : espconn_regist_reconcb
* Description : used to specify the function that should be called when connection sint8 espconn_regist_connectcb(struct espconn *espconn, espconn_connect_callback connect_cb);
* because of err disconnect.
* Parameters : espconn -- espconn to set the err callback /******************************************************************************
* recon_cb -- err callback function to call when err * FunctionName : espconn_regist_recvcb
* Returns : none * Description : used to specify the function that should be called when recv
*******************************************************************************/ * data from host.
* Parameters : espconn -- espconn to set the recv callback
sint8 espconn_regist_reconcb(struct espconn *espconn, espconn_reconnect_callback recon_cb); * recv_cb -- recv callback function to call when recv data
* Returns : none
/****************************************************************************** *******************************************************************************/
* FunctionName : espconn_regist_disconcb
* Description : used to specify the function that should be called when disconnect sint8 espconn_regist_recvcb(struct espconn *espconn, espconn_recv_callback recv_cb);
* Parameters : espconn -- espconn to set the err callback
* discon_cb -- err callback function to call when err /******************************************************************************
* Returns : none * FunctionName : espconn_regist_reconcb
*******************************************************************************/ * Description : used to specify the function that should be called when connection
* because of err disconnect.
sint8 espconn_regist_disconcb(struct espconn *espconn, espconn_connect_callback discon_cb); * Parameters : espconn -- espconn to set the err callback
* recon_cb -- err callback function to call when err
/****************************************************************************** * Returns : none
* FunctionName : espconn_port *******************************************************************************/
* Description : access port value for client so that we don't end up bouncing
* all connections at the same time . sint8 espconn_regist_reconcb(struct espconn *espconn, espconn_reconnect_callback recon_cb);
* Parameters : none
* Returns : access port value /******************************************************************************
*******************************************************************************/ * FunctionName : espconn_regist_disconcb
* Description : used to specify the function that should be called when disconnect
uint32 espconn_port(void); * Parameters : espconn -- espconn to set the err callback
* discon_cb -- err callback function to call when err
/****************************************************************************** * Returns : none
* FunctionName : espconn_set_opt *******************************************************************************/
* Description : access port value for client so that we don't end up bouncing
* all connections at the same time . sint8 espconn_regist_disconcb(struct espconn *espconn, espconn_connect_callback discon_cb);
* Parameters : none
* Returns : access port value /******************************************************************************
*******************************************************************************/ * FunctionName : espconn_port
* Description : access port value for client so that we don't end up bouncing
sint8 espconn_set_opt(struct espconn *espconn, uint8 opt); * all connections at the same time .
* Parameters : none
/****************************************************************************** * Returns : access port value
* TypedefName : dns_found_callback *******************************************************************************/
* Description : Callback which is invoked when a hostname is found.
* Parameters : name -- pointer to the name that was looked up. uint32 espconn_port(void);
* ipaddr -- pointer to an ip_addr_t containing the IP address of
* the hostname, or NULL if the name could not be found (or on any /******************************************************************************
* other error). * FunctionName : espconn_set_opt
* callback_arg -- a user-specified callback argument passed to * Description : access port value for client so that we don't end up bouncing
* dns_gethostbyname * all connections at the same time .
*******************************************************************************/ * Parameters : none
* Returns : access port value
typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg); *******************************************************************************/
/****************************************************************************** sint8 espconn_set_opt(struct espconn *espconn, uint8 opt);
* FunctionName : espconn_gethostbyname
* Description : Resolve a hostname (string) into an IP address. /******************************************************************************
* Parameters : pespconn -- espconn to resolve a hostname * TypedefName : dns_found_callback
* hostname -- the hostname that is to be queried * Description : Callback which is invoked when a hostname is found.
* addr -- pointer to a ip_addr_t where to store the address if * Parameters : name -- pointer to the name that was looked up.
* it is already cached in the dns_table (only valid if ESPCONN_OK * ipaddr -- pointer to an ip_addr_t containing the IP address of
* is returned!) * the hostname, or NULL if the name could not be found (or on any
* found -- a callback function to be called on success, failure * other error).
* or timeout (only if ERR_INPROGRESS is returned!) * callback_arg -- a user-specified callback argument passed to
* Returns : err_t return code * dns_gethostbyname
* - ESPCONN_OK if hostname is a valid IP address string or the host *******************************************************************************/
* name is already in the local names table.
* - ESPCONN_INPROGRESS enqueue a request to be sent to the DNS server typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg);
* for resolution if no errors are present.
* - ESPCONN_ARG: dns client not initialized or invalid hostname /******************************************************************************
*******************************************************************************/ * FunctionName : espconn_gethostbyname
* Description : Resolve a hostname (string) into an IP address.
err_t espconn_gethostbyname(struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found); * Parameters : pespconn -- espconn to resolve a hostname
* hostname -- the hostname that is to be queried
/****************************************************************************** * addr -- pointer to a ip_addr_t where to store the address if
* FunctionName : espconn_encry_connect * it is already cached in the dns_table (only valid if ESPCONN_OK
* Description : The function given as connection * is returned!)
* Parameters : espconn -- the espconn used to connect with the host * found -- a callback function to be called on success, failure
* Returns : none * or timeout (only if ERR_INPROGRESS is returned!)
*******************************************************************************/ * Returns : err_t return code
* - ESPCONN_OK if hostname is a valid IP address string or the host
sint8 espconn_secure_connect(struct espconn *espconn); * name is already in the local names table.
* - ESPCONN_INPROGRESS enqueue a request to be sent to the DNS server
/****************************************************************************** * for resolution if no errors are present.
* FunctionName : espconn_encry_disconnect * - ESPCONN_ARG: dns client not initialized or invalid hostname
* Description : The function given as the disconnection *******************************************************************************/
* Parameters : espconn -- the espconn used to disconnect with the host
* Returns : none err_t espconn_gethostbyname(struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found);
*******************************************************************************/
/******************************************************************************
sint8 espconn_secure_disconnect(struct espconn *espconn); * FunctionName : espconn_encry_connect
* Description : The function given as connection
/****************************************************************************** * Parameters : espconn -- the espconn used to connect with the host
* FunctionName : espconn_encry_sent * Returns : none
* Description : sent data for client or server *******************************************************************************/
* Parameters : espconn -- espconn to set for client or server
* psent -- data to send sint8 espconn_secure_connect(struct espconn *espconn);
* length -- length of data to send
* Returns : none /******************************************************************************
*******************************************************************************/ * FunctionName : espconn_encry_disconnect
* Description : The function given as the disconnection
sint8 espconn_secure_sent(struct espconn *espconn, uint8 *psent, uint16 length); * Parameters : espconn -- the espconn used to disconnect with the host
* Returns : none
/****************************************************************************** *******************************************************************************/
* FunctionName : espconn_secure_accept
* Description : The function given as the listen sint8 espconn_secure_disconnect(struct espconn *espconn);
* Parameters : espconn -- the espconn used to listen the connection
* Returns : none /******************************************************************************
*******************************************************************************/ * FunctionName : espconn_encry_sent
* Description : sent data for client or server
sint8 espconn_secure_accept(struct espconn *espconn); * Parameters : espconn -- espconn to set for client or server
* psent -- data to send
/****************************************************************************** * length -- length of data to send
* FunctionName : espconn_igmp_join * Returns : none
* Description : join a multicast group *******************************************************************************/
* Parameters : host_ip -- the ip address of udp server
* multicast_ip -- multicast ip given by user sint8 espconn_secure_sent(struct espconn *espconn, uint8 *psent, uint16 length);
* Returns : none
*******************************************************************************/ /******************************************************************************
sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip); * FunctionName : espconn_secure_accept
* Description : The function given as the listen
/****************************************************************************** * Parameters : espconn -- the espconn used to listen the connection
* FunctionName : espconn_igmp_leave * Returns : none
* Description : leave a multicast group *******************************************************************************/
* Parameters : host_ip -- the ip address of udp server
* multicast_ip -- multicast ip given by user sint8 espconn_secure_accept(struct espconn *espconn);
* Returns : none
*******************************************************************************/ /******************************************************************************
sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip); * FunctionName : espconn_igmp_join
* Description : join a multicast group
/****************************************************************************** * Parameters : host_ip -- the ip address of udp server
* FunctionName : espconn_recv_hold * multicast_ip -- multicast ip given by user
* Description : hold tcp receive * Returns : none
* Parameters : espconn -- espconn to hold *******************************************************************************/
* Returns : none sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
*******************************************************************************/
sint8 espconn_recv_hold(struct espconn *pespconn); /******************************************************************************
* FunctionName : espconn_igmp_leave
/****************************************************************************** * Description : leave a multicast group
* FunctionName : espconn_recv_unhold * Parameters : host_ip -- the ip address of udp server
* Description : unhold tcp receive * multicast_ip -- multicast ip given by user
* Parameters : espconn -- espconn to unhold * Returns : none
* Returns : none *******************************************************************************/
*******************************************************************************/ sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
sint8 espconn_recv_unhold(struct espconn *pespconn);
/******************************************************************************
#endif * FunctionName : espconn_recv_hold
* Description : hold tcp receive
* Parameters : espconn -- espconn to hold
* Returns : none
*******************************************************************************/
sint8 espconn_recv_hold(struct espconn *pespconn);
/******************************************************************************
* FunctionName : espconn_recv_unhold
* Description : unhold tcp receive
* Parameters : espconn -- espconn to unhold
* Returns : none
*******************************************************************************/
sint8 espconn_recv_unhold(struct espconn *pespconn);
#endif
...@@ -89,6 +89,7 @@ bool system_rtc_mem_write(uint8 des_addr, const void *src_addr, uint16 save_size ...@@ -89,6 +89,7 @@ bool system_rtc_mem_write(uint8 des_addr, const void *src_addr, uint16 save_size
void system_uart_swap(void); void system_uart_swap(void);
uint16 system_adc_read(void); uint16 system_adc_read(void);
uint16 system_get_vdd33(void);
const char *system_get_sdk_version(void); const char *system_get_sdk_version(void);
...@@ -97,6 +98,7 @@ const char *system_get_sdk_version(void); ...@@ -97,6 +98,7 @@ const char *system_get_sdk_version(void);
#define SOFTAP_MODE 0x02 #define SOFTAP_MODE 0x02
#define STATIONAP_MODE 0x03 #define STATIONAP_MODE 0x03
typedef enum _auth_mode { typedef enum _auth_mode {
AUTH_OPEN = 0, AUTH_OPEN = 0,
AUTH_WEP, AUTH_WEP,
...@@ -240,6 +242,10 @@ typedef void (* wifi_promiscuous_cb_t)(uint8 *buf, uint16 len); ...@@ -240,6 +242,10 @@ typedef void (* wifi_promiscuous_cb_t)(uint8 *buf, uint16 len);
void wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb); void wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb);
#define PHY_MODE_B 0x01
#define PHY_MODE_G 0x02
#define PHY_MODE_N 0x03
enum phy_mode { enum phy_mode {
PHY_MODE_11B = 1, PHY_MODE_11B = 1,
PHY_MODE_11G = 2, PHY_MODE_11G = 2,
......
...@@ -5,7 +5,7 @@ MEMORY ...@@ -5,7 +5,7 @@ MEMORY
dport0_0_seg : org = 0x3FF00000, len = 0x10 dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000 dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000 iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40210000, len = 0x5A000 irom0_0_seg : org = 0x40210000, len = 0x60000
} }
PHDRS PHDRS
...@@ -71,7 +71,6 @@ SECTIONS ...@@ -71,7 +71,6 @@ SECTIONS
_irom0_text_start = ABSOLUTE(.); _irom0_text_start = ABSOLUTE(.);
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text) *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
*(.literal.* .text.*) *(.literal.* .text.*)
*(.rodata2.text)
/* put font and progmem data into irom0 */ /* put font and progmem data into irom0 */
*(.u8g_progmem.*) *(.u8g_progmem.*)
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
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