diff --git a/README.md b/README.md
index 1bb17511..930403d5 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# **NodeMcu** #
version 0.9.5
###A lua based firmware for wifi-soc esp8266
-Build on [ESP8266 sdk 0.9.5](http://bbs.espressif.com/viewtopic.php?f=7&t=104)
+Build on [ESP8266 sdk 0.9.5](http://bbs.espressif.com/viewtopic.php?f=5&t=154)
Lua core based on [eLua project](http://www.eluaproject.net/)
File system based on [spiffs](https://github.com/pellepl/spiffs)
Open source development kit for NodeMCU [nodemcu-devkit](https://github.com/nodemcu/nodemcu-devkit)
@@ -16,16 +16,22 @@ Tencent QQ group: 309957875
- Easy to access wireless router
- Based on Lua 5.1.4 (without *io, math, debug, os* module.)
- Event-Drive programming preferred.
-- Build-in file, timer, pwm, i2c, 1-wire, net, gpio, wifi, adc, uart and system api.
+- Build-in file, timer, pwm, i2c, spi, 1-wire, net, mqtt, gpio, wifi, adc, uart and system api.
- GPIO pin re-mapped, use the index to access gpio, i2c, pwm.
# To Do List (pull requests are very welcomed)
- fix wifi smart connect
-- add spi module
-- add mqtt module
+- add spi module (done)
+- add mqtt module (done)
- add coap module
+- cross compiler
# Change log
+2015-01-24
+migrate to sdk 0.9.5 release.
+tmr.time() now return second(not precise yet).
+build pre_build bin.
+
2015-01-23
merge mqtt branch to master.
build pre_build bin.
@@ -80,39 +86,6 @@ pre_build/latest/nodemcu_512k_latest.bin is removed. use pre_build/latest/nodemc
#### [*] D0(GPIO16) can only be used as gpio read/write. no interrupt supported. no pwm/i2c/ow supported.
-##GPIO OLD TABLE (Before build 20141212)
-
-
-
-
- IO index | ESP8266 pin | IO index | ESP8266 pin |
-
-
- 0 | GPIO12 | 8 | GPIO0 |
-
-
- 1 | GPIO13 | 9 | GPIO2 |
-
-
- 2 | GPIO14 | 10 | GPIO4 |
-
-
- 3 | GPIO15 | 11 | GPIO5 |
-
-
- 4 | GPIO3 | | |
-
-
- 5 | GPIO1 | | |
-
-
- 6 | GPIO9 | | |
-
-
- 7 | GPIO10 | |
-
-
-
#Build option
####file ./app/include/user_config.h
```c
@@ -145,10 +118,8 @@ for most esp8266 modules, just pull GPIO0 down and restart.
You can use the [nodemcu-flasher](https://github.com/nodemcu/nodemcu-flasher) to burn the firmware.
Or, if you build your own bin from source code.
-eagle.app.v6.flash.bin: 0x00000
-eagle.app.v6.irom0text.bin: 0x10000
-esp_init_data_default.bin: 0x7c000
-blank.bin: 0x7e000
+0x00000.bin: 0x00000
+0x10000.bin: 0x10000
*Better run file.format() after flash*
diff --git a/app/Makefile b/app/Makefile
index 584d4545..605534db 100644
--- a/app/Makefile
+++ b/app/Makefile
@@ -42,6 +42,7 @@ endif # } PDIR
APPDIR = .
LDDIR = ../ld
+CCFLAGS += -Os
TARGET_LDFLAGS = \
-nostdlib \
@@ -49,7 +50,6 @@ TARGET_LDFLAGS = \
--longcalls \
--text-section-literals
-
ifeq ($(FLAVOR),debug)
TARGET_LDFLAGS += -g -O2
endif
@@ -101,6 +101,7 @@ LINKFLAGS_eagle.app.v6 = \
-lwpa \
-lmain \
-ljson \
+ -lsmartconfig \
$(DEP_LIBS_eagle.app.v6) \
-Wl,--end-group
diff --git a/app/driver/i2c_master.c b/app/driver/i2c_master.c
index 24128eaa..772be691 100644
--- a/app/driver/i2c_master.c
+++ b/app/driver/i2c_master.c
@@ -219,6 +219,45 @@ i2c_master_getAck(void)
return retVal;
}
+/******************************************************************************
+* FunctionName : i2c_master_checkAck
+* Description : get dev response
+* Parameters : NONE
+* Returns : true : get ack ; false : get nack
+*******************************************************************************/
+bool ICACHE_FLASH_ATTR
+i2c_master_checkAck(void)
+{
+ if(i2c_master_getAck()){
+ return FALSE;
+ }else{
+ return TRUE;
+ }
+}
+
+/******************************************************************************
+* FunctionName : i2c_master_send_ack
+* Description : response ack
+* Parameters : NONE
+* Returns : NONE
+*******************************************************************************/
+void ICACHE_FLASH_ATTR
+i2c_master_send_ack(void)
+{
+ i2c_master_setAck(0x0);
+}
+/******************************************************************************
+* FunctionName : i2c_master_send_nack
+* Description : response nack
+* Parameters : NONE
+* Returns : NONE
+*******************************************************************************/
+void ICACHE_FLASH_ATTR
+i2c_master_send_nack(void)
+{
+ i2c_master_setAck(0x1);
+}
+
/******************************************************************************
* FunctionName : i2c_master_readByte
* Description : read Byte from i2c bus
diff --git a/app/driver/pwm.c b/app/driver/pwm.c
index 7e1728fd..cc147d05 100644
--- a/app/driver/pwm.c
+++ b/app/driver/pwm.c
@@ -349,11 +349,6 @@ pwm_init(uint16 freq, uint16 *duty)
{
uint8 i;
- ETS_FRC_TIMER1_INTR_ATTACH(pwm_tim1_intr_handler, NULL);
- TM1_EDGE_INT_ENABLE();
- ETS_FRC1_INTR_ENABLE();
-
- RTC_CLR_REG_MASK(FRC1_INT_ADDRESS, FRC1_INT_CLR_MASK);
RTC_REG_WRITE(FRC1_CTRL_ADDRESS, //FRC2_AUTO_RELOAD|
DIVDED_BY_16
| FRC1_ENABLE_TIMER
@@ -377,6 +372,10 @@ pwm_init(uint16 freq, uint16 *duty)
// pwm_set_freq_duty(freq, duty);
pwm_start();
+
+ ETS_FRC_TIMER1_INTR_ATTACH(pwm_tim1_intr_handler, NULL);
+ TM1_EDGE_INT_ENABLE();
+ ETS_FRC1_INTR_ENABLE();
}
bool ICACHE_FLASH_ATTR
diff --git a/app/include/driver/i2c_master.h b/app/include/driver/i2c_master.h
index 22f7443b..18635d5f 100644
--- a/app/include/driver/i2c_master.h
+++ b/app/include/driver/i2c_master.h
@@ -63,6 +63,11 @@ void i2c_master_setAck(uint8 level);
uint8 i2c_master_getAck(void);
uint8 i2c_master_readByte(void);
void i2c_master_writeByte(uint8 wrdata);
+
+bool i2c_master_checkAck(void);
+void i2c_master_send_ack(void);
+void i2c_master_send_nack(void);
+
uint8 i2c_master_get_pinSDA();
uint8 i2c_master_get_pinSCL();
diff --git a/app/include/user_config.h b/app/include/user_config.h
index 1af91c0a..4a02db17 100644
--- a/app/include/user_config.h
+++ b/app/include/user_config.h
@@ -7,7 +7,7 @@
#define NODE_VERSION_INTERNAL 0U
#define NODE_VERSION "NodeMCU 0.9.5"
-#define BUILD_DATE "build 20150123"
+#define BUILD_DATE "build 20150124"
// #define FLASH_512K
// #define FLASH_1M
@@ -18,6 +18,9 @@
#define FULL_VERSION_FOR_USER
#ifdef DEVELOP_VERSION
+
+#define USE_OPTIMIZE_PRINTF
+
#define NODE_DEBUG
#endif /* DEVELOP_VERSION */
@@ -38,7 +41,7 @@
#define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
#define ICACHE_STORE_ATTR __attribute__((aligned(4)))
#define ICACHE_RAM_ATTR __attribute__((section(".iram0.text")))
-#define ICACHE_RODATA_ATTR __attribute__((section(".rodata2.text")))
+// #define ICACHE_RODATA_ATTR __attribute__((section(".rodata2.text")))
#define CLIENT_SSL_ENABLE
#define GPIO_INTERRUPT_ENABLE
diff --git a/app/libc/c_stdio.h b/app/libc/c_stdio.h
index d8302a38..c24f82d2 100644
--- a/app/libc/c_stdio.h
+++ b/app/libc/c_stdio.h
@@ -47,6 +47,10 @@ extern int c_stderr;
#define SEEK_END 2 /* set file offset to EOF plus offset */
#endif
+#define c_malloc os_malloc
+#define c_zalloc os_zalloc
+#define c_free os_free
+
extern void output_redirect(const char *str);
#define c_puts output_redirect
diff --git a/app/libc/c_stdlib.c b/app/libc/c_stdlib.c
index 7115914d..2b2fa1d8 100644
--- a/app/libc/c_stdlib.c
+++ b/app/libc/c_stdlib.c
@@ -20,27 +20,27 @@ const char *c_getenv(const char *__string){
}
// make sure there is enough memory before real malloc, otherwise malloc will panic and reset
-void *c_malloc(size_t __size){
- if(__size>system_get_free_heap_size()){
- NODE_ERR("malloc: not enough memory\n");
- return NULL;
- }
- return (void *)os_malloc(__size);
-}
+// void *c_malloc(size_t __size){
+// if(__size>system_get_free_heap_size()){
+// NODE_ERR("malloc: not enough memory\n");
+// return NULL;
+// }
+// return (void *)os_malloc(__size);
+// }
-void *c_zalloc(size_t __size){
- if(__size>system_get_free_heap_size()){
- NODE_ERR("zalloc: not enough memory\n");
- return NULL;
- }
- return (void *)os_zalloc(__size);
-}
+// void *c_zalloc(size_t __size){
+// if(__size>system_get_free_heap_size()){
+// NODE_ERR("zalloc: not enough memory\n");
+// return NULL;
+// }
+// return (void *)os_zalloc(__size);
+// }
-void c_free(void *p){
- // NODE_ERR("free1: %d\n", system_get_free_heap_size());
- os_free(p);
- // NODE_ERR("-free1: %d\n", system_get_free_heap_size());
-}
+// void c_free(void *p){
+// // NODE_ERR("free1: %d\n", system_get_free_heap_size());
+// os_free(p);
+// // NODE_ERR("-free1: %d\n", system_get_free_heap_size());
+// }
// int c_rand(void){
diff --git a/app/lua/lundump.c b/app/lua/lundump.c
index 92aa5b4f..b036e7a5 100644
--- a/app/lua/lundump.c
+++ b/app/lua/lundump.c
@@ -5,6 +5,7 @@
*/
#include "c_string.h"
+#include "c_types.h"
#define lundump_c
#define LUA_CORE
@@ -141,13 +142,11 @@ static lua_Number LoadNumber(LoadState* S)
LoadVar(S,y);
x = (lua_Number)y;
} break;
-#if 0
case 8: {
int64_t y;
LoadVar(S,y);
x = (lua_Number)y;
} break;
-#endif
default: lua_assert(0);
}
}
diff --git a/app/lwip/app/espconn_tcp.c b/app/lwip/app/espconn_tcp.c
index 9cc7129d..91843887 100644
--- a/app/lwip/app/espconn_tcp.c
+++ b/app/lwip/app/espconn_tcp.c
@@ -812,10 +812,6 @@ espconn_tcp_accept(void *arg, struct tcp_pcb *pcb, err_t err)
remot_info *pinfo = NULL;
LWIP_UNUSED_ARG(err);
- if(4096>system_get_free_heap_size()){
- return ERR_MEM;
- }
-
paccept = (espconn_msg *)os_zalloc(sizeof(espconn_msg));
tcp_arg(pcb, paccept);
tcp_err(pcb, esponn_server_err);
diff --git a/app/modules/tmr.c b/app/modules/tmr.c
index 7d67d6be..78221589 100644
--- a/app/modules/tmr.c
+++ b/app/modules/tmr.c
@@ -147,14 +147,33 @@ static int tmr_wdclr( lua_State* L )
return 0;
}
+static os_timer_t rtc_timer_updator;
+static unsigned rtc_second = 0; // TODO: load from rtc memory
+static uint64_t cur_count = 0;
+static uint64_t rtc_count = 0;
+void rtc_timer_update_cb(void *arg){
+ uint64_t t = (uint64_t)system_get_rtc_time();
+ // NODE_ERR("%x\n",t);
+ if(t>=cur_count){
+ rtc_count += t - cur_count;
+ cur_count = t;
+ } else {
+ rtc_count += 0x100000000 + t - cur_count;
+ cur_count = t;
+ }
+ unsigned c = system_rtc_clock_cali_proc();
+ uint64_t itg = c >> 12;
+ uint64_t dec = c & 0xFFF;
+ uint64_t second = (cur_count*itg + ((cur_count*dec)>>12)) / 1000000;
+ // NODE_ERR("%x\n",second);
+ rtc_second = (unsigned)second;
+ // TODO: store rtc_count, rtc_second to rtc memory.
+}
// Lua: time() , return rtc time in us
static int tmr_time( lua_State* L )
{
- unsigned t = 0xFFFFFFFF & system_get_rtc_time();
- unsigned c = 0xFFFFFFFF & system_rtc_clock_cali_proc();
- lua_pushinteger( L, t );
- lua_pushinteger( L, c );
- return 2;
+ lua_pushinteger( L, rtc_second & 0x7FFFFFFF );
+ return 1;
}
// Module function map
@@ -182,6 +201,10 @@ LUALIB_API int luaopen_tmr( lua_State *L )
os_timer_setfn(&(alarm_timer[i]), (os_timer_func_t *)(alarm_timer_cb[i]), L);
}
+ os_timer_disarm(&rtc_timer_updator);
+ os_timer_setfn(&rtc_timer_updator, (os_timer_func_t *)(rtc_timer_update_cb), NULL);
+ os_timer_arm(&rtc_timer_updator, 500, 1);
+
#if LUA_OPTIMIZE_MEMORY > 0
return 0;
#else // #if LUA_OPTIMIZE_MEMORY > 0
diff --git a/app/modules/wifi.c b/app/modules/wifi.c
index e1bf6ea4..4acdd304 100644
--- a/app/modules/wifi.c
+++ b/app/modules/wifi.c
@@ -12,6 +12,7 @@
#include "c_types.h"
#include "user_interface.h"
#include "smart.h"
+#include "smartconfig.h"
static int wifi_smart_succeed = LUA_NOREF;
@@ -19,6 +20,13 @@ static void wifi_smart_succeed_cb(void *arg){
NODE_DBG("wifi_smart_succeed_cb is called.\n");
if( !arg )
return;
+#if 0
+ struct station_config *sta_conf = arg;
+ wifi_station_set_config(sta_conf);
+ wifi_station_disconnect();
+ wifi_station_connect();
+ smartconfig_stop();
+#endif
if(wifi_smart_succeed == LUA_NOREF)
return;
lua_State* L = (lua_State *)arg;
@@ -81,6 +89,7 @@ static void wifi_scan_done(void *arg, STATUS status)
}
// Lua: smart(channel, function succeed_cb)
+// Lua: smart(type, function succeed_cb)
static int wifi_start_smart( lua_State* L )
{
unsigned channel;
@@ -109,13 +118,15 @@ static int wifi_start_smart( lua_State* L )
}else{
smart_begin(channel, (smart_succeed )wifi_smart_succeed_cb, L);
}
+ // smartconfig_start(0, wifi_smart_succeed_cb);
return 0;
}
-// Lua: exit_smart(channel)
+// Lua: exit_smart()
static int wifi_exit_smart( lua_State* L )
{
smart_end();
+ // smartconfig_stop();
if(wifi_smart_succeed != LUA_NOREF)
luaL_unref(L, LUA_REGISTRYINDEX, wifi_smart_succeed);
wifi_smart_succeed = LUA_NOREF;
diff --git a/include/at_custom.h b/include/at_custom.h
new file mode 100644
index 00000000..a9b05c4c
--- /dev/null
+++ b/include/at_custom.h
@@ -0,0 +1,85 @@
+
+/*
+ * custom_at.h
+ *
+ * This file is part of Espressif's AT+ command set program.
+ * Copyright (C) 2013 - 2016, Espressif Systems
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of version 3 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#ifndef CUSTOM_AT_H_
+#define CUSTOM_AT_H_
+
+#include "c_types.h"
+
+typedef struct
+{
+ char *at_cmdName;
+ int8_t at_cmdLen;
+ void (*at_testCmd)(uint8_t id);
+ void (*at_queryCmd)(uint8_t id);
+ void (*at_setupCmd)(uint8_t id, char *pPara);
+ void (*at_exeCmd)(uint8_t id);
+}at_funcationType;
+
+/**
+ * @brief Response "OK" to uart.
+ * @param None
+ * @retval None
+ */
+void at_response_ok(void);
+/**
+ * @brief Response "ERROR" to uart.
+ * @param events: no used
+ * @retval None
+ */
+void at_response_error(void);
+/**
+ * @brief Task of process command or txdata.
+ * @param custom_at_cmd_array: the array of at cmd that custom defined
+ * cmd_num : the num of at cmd that custom defined
+ * @retval None
+ */
+void at_cmd_array_regist(at_funcationType *custom_at_cmd_array,uint32 cmd_num);
+/**
+ * @brief get digit form at cmd line.the maybe alter pSrc
+ * @param p_src: at cmd line string
+ * result:the buffer to be placed result
+ * err : err num
+ * @retval TRUE:
+ * FALSE:
+ */
+bool at_get_next_int_dec(char **p_src,int*result,int* err);
+/**
+ * @brief get string form at cmd line.the maybe alter pSrc
+ * @param p_dest: the buffer to be placed result
+ * p_src: at cmd line string
+ * max_len :max len of string excepted to get
+ * @retval None
+ */
+int32 at_data_str_copy(char *p_dest, char **p_src, int32 max_len);
+
+/**
+ * @brief initialize at module
+ * @param None
+ * @retval None
+ */
+void at_init(void);
+/**
+ * @brief print string to at port
+ * @param string
+ * @retval None
+ */
+void at_port_print(const char *str);
+#endif
diff --git a/include/c_types.h b/include/c_types.h
index 88822345..55bffd46 100644
--- a/include/c_types.h
+++ b/include/c_types.h
@@ -16,6 +16,7 @@ typedef unsigned long uint32_t;
typedef signed long sint32_t;
typedef signed long int32_t;
typedef signed long long sint64_t;
+typedef signed long long int64_t;
typedef unsigned long long uint64_t;
typedef unsigned long long u_int64_t;
typedef float real32_t;
@@ -78,6 +79,7 @@ typedef enum {
#ifdef ICACHE_FLASH
#define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text")))
+#define ICACHE_RODATA_ATTR __attribute__((section(".irom.text")))
#else
#define ICACHE_FLASH_ATTR
#endif /* ICACHE_FLASH */
diff --git a/include/espconn.h b/include/espconn.h
index 3fc3cb7e..2af5cf77 100644
--- a/include/espconn.h
+++ b/include/espconn.h
@@ -91,6 +91,7 @@ struct espconn {
enum espconn_option{
ESPCONN_REUSEADDR = 1,
+ ESPCONN_NODELAY,
ESPCONN_END
};
@@ -371,5 +372,21 @@ sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
*******************************************************************************/
sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
+/******************************************************************************
+ * FunctionName : espconn_recv_hold
+ * Description : hold tcp receive
+ * Parameters : espconn -- espconn to hold
+ * Returns : none
+*******************************************************************************/
+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
diff --git a/include/ip_addr.h b/include/ip_addr.h
index bd757a49..728a75c4 100644
--- a/include/ip_addr.h
+++ b/include/ip_addr.h
@@ -52,6 +52,11 @@ struct ip_info {
#define ip4_addr3_16(ipaddr) ((uint16)ip4_addr3(ipaddr))
#define ip4_addr4_16(ipaddr) ((uint16)ip4_addr4(ipaddr))
+
+/** 255.255.255.255 */
+#define IPADDR_NONE ((uint32)0xffffffffUL)
+/** 0.0.0.0 */
+#define IPADDR_ANY ((uint32)0x00000000UL)
uint32 ipaddr_addr(const char *cp);
#define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \
diff --git a/include/osapi.h b/include/osapi.h
index 055085f0..5fbdf0da 100644
--- a/include/osapi.h
+++ b/include/osapi.h
@@ -44,5 +44,14 @@
#define os_sprintf ets_sprintf
#define os_update_cpu_frequency ets_update_cpu_frequency
+#ifdef USE_OPTIMIZE_PRINTF
+#define os_printf(fmt, ...) do { \
+ static const char flash_str[] ICACHE_RODATA_ATTR = fmt; \
+ os_printf_plus(flash_str, ##__VA_ARGS__); \
+ } while(0)
+#else
+#define os_printf os_printf_plus
+#endif
+
#endif
diff --git a/include/ping.h b/include/ping.h
new file mode 100644
index 00000000..4ecd032b
--- /dev/null
+++ b/include/ping.h
@@ -0,0 +1,32 @@
+#ifndef __PING_H__
+#define __PING_H__
+
+
+typedef void (* ping_recv_function)(void* arg, void *pdata);
+typedef void (* ping_sent_function)(void* arg, void *pdata);
+
+struct ping_option{
+ uint32 count;
+ uint32 ip;
+ uint32 coarse_time;
+ ping_recv_function recv_function;
+ ping_sent_function sent_function;
+ void* reverse;
+};
+
+struct ping_resp{
+ uint32 total_count;
+ uint32 resp_time;
+ uint32 seqno;
+ uint32 timeout_count;
+ uint32 bytes;
+ uint32 total_bytes;
+ uint32 total_time;
+ sint8 ping_err;
+};
+
+bool ping_start(struct ping_option *ping_opt);
+bool ping_regist_recv(struct ping_option *ping_opt, ping_recv_function ping_recv);
+bool ping_regist_sent(struct ping_option *ping_opt, ping_sent_function ping_sent);
+
+#endif /* __PING_H__ */
diff --git a/include/smartconfig.h b/include/smartconfig.h
new file mode 100644
index 00000000..02a1e317
--- /dev/null
+++ b/include/smartconfig.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2015 -2018 Espressif System
+ *
+ */
+
+#ifndef __SMARTCONFIG_H__
+#define __SMARTCONFIG_H__
+
+typedef void (*sc_callback_t)(void *data);
+
+typedef enum {
+ SC_STATUS_FIND_CHANNEL = 0,
+ SC_STATUS_GETTING_SSID_PSWD,
+ SC_STATUS_GOT_SSID_PSWD,
+ SC_STATUS_LINK,
+} sc_status;
+
+typedef enum {
+ SC_TYPE_ESPTOUCH = 0,
+ SC_TYPE_AIRKISS,
+} sc_type;
+
+sc_status smartconfig_get_status(void);
+const char *smartconfig_get_version(void);
+bool smartconfig_start(sc_type type, sc_callback_t cb);
+bool smartconfig_stop(void);
+
+#endif
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 5918c6b3..12dd6e17 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -24,8 +24,6 @@ typedef struct{
#define SPI_FLASH_SEC_SIZE 4096
uint32 spi_flash_get_id(void);
-SpiFlashOpResult spi_flash_read_status(uint32 *status);
-SpiFlashOpResult spi_flash_write_status(uint32 status_value);
SpiFlashOpResult spi_flash_erase_sector(uint16 sec);
SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size);
diff --git a/include/user_interface.h b/include/user_interface.h
index 1306dfce..d64c1795 100644
--- a/include/user_interface.h
+++ b/include/user_interface.h
@@ -43,11 +43,15 @@ struct rst_info{
void system_restore(void);
void system_restart(void);
+
+bool system_deep_sleep_set_option(uint8 option);
void system_deep_sleep(uint32 time_in_us);
+
uint8 system_upgrade_userbin_check(void);
void system_upgrade_reboot(void);
uint8 system_upgrade_flag_check();
void system_upgrade_flag_set(uint8 flag);
+
void system_timer_reinit(void);
uint32 system_get_time(void);
@@ -59,13 +63,14 @@ enum {
USER_TASK_PRIO_MAX
};
-void system_os_task(os_task_t task, uint8 prio, os_event_t *queue, uint8 qlen);
-void system_os_post(uint8 prio, os_signal_t sig, os_param_t par);
+bool system_os_task(os_task_t task, uint8 prio, os_event_t *queue, uint8 qlen);
+bool system_os_post(uint8 prio, os_signal_t sig, os_param_t par);
void system_print_meminfo(void);
uint32 system_get_free_heap_size(void);
void system_set_os_print(uint8 onoff);
+uint8 system_get_os_print();
uint64 system_mktime(uint32 year, uint32 mon, uint32 day, uint32 hour, uint32 min, uint32 sec);
@@ -92,6 +97,15 @@ const char *system_get_sdk_version(void);
#define SOFTAP_MODE 0x02
#define STATIONAP_MODE 0x03
+typedef enum _auth_mode {
+ AUTH_OPEN = 0,
+ AUTH_WEP,
+ AUTH_WPA_PSK,
+ AUTH_WPA2_PSK,
+ AUTH_WPA_WPA2_PSK,
+ AUTH_MAX
+} AUTH_MODE;
+
uint8 wifi_get_opmode(void);
bool wifi_set_opmode(uint8 opmode);
@@ -102,7 +116,7 @@ struct bss_info {
uint8 ssid[32];
uint8 channel;
sint8 rssi;
- uint8 authmode;
+ AUTH_MODE authmode;
uint8 is_hidden;
};
@@ -120,7 +134,8 @@ typedef void (* scan_done_cb_t)(void *arg, STATUS status);
struct station_config {
uint8 ssid[32];
uint8 password[64];
- uint8 bssid_set;
+ uint8 bssid_set; // Note: If bssid_set is 1, station will just connect to the router
+ // with both ssid[] and bssid[] matched. Please check about this.
uint8 bssid[6];
};
@@ -131,10 +146,10 @@ bool wifi_station_connect(void);
bool wifi_station_disconnect(void);
struct scan_config {
- uint8 *ssid;
- uint8 *bssid;
- uint8 channel;
- uint8 show_hidden;
+ uint8 *ssid; // Note: ssid == NULL, don't filter ssid.
+ uint8 *bssid; // Note: bssid == NULL, don't filter bssid.
+ uint8 channel; // Note: channel == 0, scan all channels, otherwise scan set channel.
+ uint8 show_hidden; // Note: show_hidden == 1, can get hidden ssid routers' info.
};
bool wifi_station_scan(struct scan_config *config, scan_done_cb_t cb);
@@ -166,22 +181,15 @@ bool wifi_station_dhcpc_start(void);
bool wifi_station_dhcpc_stop(void);
enum dhcp_status wifi_station_dhcpc_status(void);
-typedef enum _auth_mode {
- AUTH_OPEN = 0,
- AUTH_WEP,
- AUTH_WPA_PSK,
- AUTH_WPA2_PSK,
- AUTH_WPA_WPA2_PSK
-} AUTH_MODE;
-
struct softap_config {
uint8 ssid[32];
uint8 password[64];
- uint8 ssid_len;
- uint8 channel;
- uint8 authmode;
- uint8 ssid_hidden;
- uint8 max_connection;
+ uint8 ssid_len; // Note: Recommend to set it according to your ssid
+ uint8 channel; // Note: support 1 ~ 13
+ AUTH_MODE authmode; // Note: Don't support AUTH_WEP in softAP mode.
+ uint8 ssid_hidden; // Note: default 0
+ uint8 max_connection; // Note: default 4, max 4
+ uint8 beacon_interval; // Note: support 100 ~ 60000 ms, default 100
};
bool wifi_softap_get_config(struct softap_config *config);
@@ -220,6 +228,7 @@ uint8 wifi_get_channel(void);
bool wifi_set_channel(uint8 channel);
void wifi_status_led_install(uint8 gpio_id, uint32 gpio_name, uint8 gpio_func);
+void wifi_status_led_uninstall();
/** Get the absolute difference between 2 u32_t values (correcting overflows)
* 'a' is expected to be 'higher' (without overflow) than 'b'. */
diff --git a/ld/eagle.rom.addr.v6.ld b/ld/eagle.rom.addr.v6.ld
index 0ca83963..076a240d 100644
--- a/ld/eagle.rom.addr.v6.ld
+++ b/ld/eagle.rom.addr.v6.ld
@@ -18,6 +18,7 @@ PROVIDE ( SHA1Transform = 0x4000a364 );
PROVIDE ( SHA1Update = 0x4000b5a8 );
PROVIDE ( SPI_read_status = 0x400043c8 );
PROVIDE ( SPI_write_status = 0x40004400 );
+PROVIDE ( SPI_write_enable = 0x4000443c );
PROVIDE ( Wait_SPI_Idle = 0x4000448c );
PROVIDE ( SPIEraseArea = 0x40004b44 );
PROVIDE ( SPIEraseBlock = 0x400049b4 );
diff --git a/lib/libat.a b/lib/libat.a
new file mode 100644
index 00000000..e1db9fa8
Binary files /dev/null and b/lib/libat.a differ
diff --git a/lib/libjson.a b/lib/libjson.a
index a9492522..f32c329d 100644
Binary files a/lib/libjson.a and b/lib/libjson.a differ
diff --git a/lib/liblwip.a b/lib/liblwip.a
index 04dd604a..6ef795bb 100644
Binary files a/lib/liblwip.a and b/lib/liblwip.a differ
diff --git a/lib/libmain.a b/lib/libmain.a
index 271a35fd..2d520b0c 100644
Binary files a/lib/libmain.a and b/lib/libmain.a differ
diff --git a/lib/libnet80211.a b/lib/libnet80211.a
index 7bcb84f0..5ae2da5c 100644
Binary files a/lib/libnet80211.a and b/lib/libnet80211.a differ
diff --git a/lib/libphy.a b/lib/libphy.a
index 5679e419..1598f206 100644
Binary files a/lib/libphy.a and b/lib/libphy.a differ
diff --git a/lib/libpp.a b/lib/libpp.a
index bf1a397d..17466205 100644
Binary files a/lib/libpp.a and b/lib/libpp.a differ
diff --git a/lib/libsmartconfig.a b/lib/libsmartconfig.a
new file mode 100644
index 00000000..f402b5f3
Binary files /dev/null and b/lib/libsmartconfig.a differ
diff --git a/lib/libssl.a b/lib/libssl.a
index 3fd56320..36b78fe2 100644
Binary files a/lib/libssl.a and b/lib/libssl.a differ
diff --git a/lib/libupgrade.a b/lib/libupgrade.a
index a4206383..051d683b 100644
Binary files a/lib/libupgrade.a and b/lib/libupgrade.a differ
diff --git a/lib/libwpa.a b/lib/libwpa.a
index 85f334ef..abd611b4 100644
Binary files a/lib/libwpa.a and b/lib/libwpa.a differ
diff --git a/pre_build/0.9.5/nodemcu_20150123.bin b/pre_build/0.9.5/nodemcu_20150123.bin
new file mode 100644
index 00000000..05966712
Binary files /dev/null and b/pre_build/0.9.5/nodemcu_20150123.bin differ
diff --git a/pre_build/latest/nodemcu_latest.bin b/pre_build/latest/nodemcu_latest.bin
index 05966712..cd4faa96 100644
Binary files a/pre_build/latest/nodemcu_latest.bin and b/pre_build/latest/nodemcu_latest.bin differ