migrate to sdk 0.9.5 release version

This commit is contained in:
funshine 2015-01-24 23:36:04 +08:00
parent 360fb59e63
commit ad966146fc
35 changed files with 340 additions and 103 deletions

View File

@ -1,7 +1,7 @@
# **NodeMcu** # # **NodeMcu** #
version 0.9.5 version 0.9.5
###A lua based firmware for wifi-soc esp8266 ###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)<br /> Build on [ESP8266 sdk 0.9.5](http://bbs.espressif.com/viewtopic.php?f=5&t=154)<br />
Lua core based on [eLua project](http://www.eluaproject.net/)<br /> Lua core based on [eLua project](http://www.eluaproject.net/)<br />
File system based on [spiffs](https://github.com/pellepl/spiffs)<br /> File system based on [spiffs](https://github.com/pellepl/spiffs)<br />
Open source development kit for NodeMCU [nodemcu-devkit](https://github.com/nodemcu/nodemcu-devkit)<br /> Open source development kit for NodeMCU [nodemcu-devkit](https://github.com/nodemcu/nodemcu-devkit)<br />
@ -16,16 +16,22 @@ Tencent QQ group: 309957875<br />
- Easy to access wireless router - Easy to access wireless router
- Based on Lua 5.1.4 (without *io, math, debug, os* module.) - Based on Lua 5.1.4 (without *io, math, debug, os* module.)
- Event-Drive programming preferred. - 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. - GPIO pin re-mapped, use the index to access gpio, i2c, pwm.
# To Do List (pull requests are very welcomed) # To Do List (pull requests are very welcomed)
- fix wifi smart connect - fix wifi smart connect
- add spi module - add spi module (done)
- add mqtt module - add mqtt module (done)
- add coap module - add coap module
- cross compiler
# Change log # Change log
2015-01-24<br />
migrate to sdk 0.9.5 release.<br />
tmr.time() now return second(not precise yet). <br />
build pre_build bin.
2015-01-23<br /> 2015-01-23<br />
merge mqtt branch to master.<br /> merge mqtt branch to master.<br />
build pre_build bin. build pre_build bin.
@ -80,39 +86,6 @@ pre_build/latest/nodemcu_512k_latest.bin is removed. use pre_build/latest/nodemc
</table> </table>
#### [*] D0(GPIO16) can only be used as gpio read/write. no interrupt supported. no pwm/i2c/ow supported. #### [*] D0(GPIO16) can only be used as gpio read/write. no interrupt supported. no pwm/i2c/ow supported.
##GPIO OLD TABLE (Before build 20141212)
<a id="old_gpio_map"></a>
<table>
<tr>
<th scope="col">IO index</th><th scope="col">ESP8266 pin</th><th scope="col">IO index</th><th scope="col">ESP8266 pin</th>
</tr>
<tr>
<td>0</td><td>GPIO12</td><td>8</td><td>GPIO0</td>
</tr>
<tr>
<td>1</td><td>GPIO13</td><td>9</td><td>GPIO2</td>
</tr>
<tr>
<td>2</td><td>GPIO14</td><td>10</td><td>GPIO4</td>
</tr>
<tr>
<td>3</td><td>GPIO15</td><td>11</td><td>GPIO5</td>
</tr>
<tr>
<td>4</td><td>GPIO3</td><td></td><td></td>
</tr>
<tr>
<td>5</td><td>GPIO1</td><td></td><td></td>
</tr>
<tr>
<td>6</td><td>GPIO9</td><td></td><td></td>
</tr>
<tr>
<td>7</td><td>GPIO10</td<td></td><td></td>
</tr>
</table>
#Build option #Build option
####file ./app/include/user_config.h ####file ./app/include/user_config.h
```c ```c
@ -145,10 +118,8 @@ for most esp8266 modules, just pull GPIO0 down and restart.<br />
You can use the [nodemcu-flasher](https://github.com/nodemcu/nodemcu-flasher) to burn the firmware. 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.<br /> Or, if you build your own bin from source code.<br />
eagle.app.v6.flash.bin: 0x00000<br /> 0x00000.bin: 0x00000<br />
eagle.app.v6.irom0text.bin: 0x10000<br /> 0x10000.bin: 0x10000<br />
esp_init_data_default.bin: 0x7c000<br />
blank.bin: 0x7e000<br />
*Better run file.format() after flash* *Better run file.format() after flash*

View File

@ -42,6 +42,7 @@ endif # } PDIR
APPDIR = . APPDIR = .
LDDIR = ../ld LDDIR = ../ld
CCFLAGS += -Os
TARGET_LDFLAGS = \ TARGET_LDFLAGS = \
-nostdlib \ -nostdlib \
@ -49,7 +50,6 @@ TARGET_LDFLAGS = \
--longcalls \ --longcalls \
--text-section-literals --text-section-literals
ifeq ($(FLAVOR),debug) ifeq ($(FLAVOR),debug)
TARGET_LDFLAGS += -g -O2 TARGET_LDFLAGS += -g -O2
endif endif
@ -101,6 +101,7 @@ LINKFLAGS_eagle.app.v6 = \
-lwpa \ -lwpa \
-lmain \ -lmain \
-ljson \ -ljson \
-lsmartconfig \
$(DEP_LIBS_eagle.app.v6) \ $(DEP_LIBS_eagle.app.v6) \
-Wl,--end-group -Wl,--end-group

View File

@ -219,6 +219,45 @@ i2c_master_getAck(void)
return retVal; 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 * FunctionName : i2c_master_readByte
* Description : read Byte from i2c bus * Description : read Byte from i2c bus

View File

@ -349,11 +349,6 @@ pwm_init(uint16 freq, uint16 *duty)
{ {
uint8 i; 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| RTC_REG_WRITE(FRC1_CTRL_ADDRESS, //FRC2_AUTO_RELOAD|
DIVDED_BY_16 DIVDED_BY_16
| FRC1_ENABLE_TIMER | FRC1_ENABLE_TIMER
@ -377,6 +372,10 @@ pwm_init(uint16 freq, uint16 *duty)
// pwm_set_freq_duty(freq, duty); // pwm_set_freq_duty(freq, duty);
pwm_start(); pwm_start();
ETS_FRC_TIMER1_INTR_ATTACH(pwm_tim1_intr_handler, NULL);
TM1_EDGE_INT_ENABLE();
ETS_FRC1_INTR_ENABLE();
} }
bool ICACHE_FLASH_ATTR bool ICACHE_FLASH_ATTR

View File

@ -63,6 +63,11 @@ void i2c_master_setAck(uint8 level);
uint8 i2c_master_getAck(void); uint8 i2c_master_getAck(void);
uint8 i2c_master_readByte(void); uint8 i2c_master_readByte(void);
void i2c_master_writeByte(uint8 wrdata); 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_pinSDA();
uint8 i2c_master_get_pinSCL(); uint8 i2c_master_get_pinSCL();

View File

@ -7,7 +7,7 @@
#define NODE_VERSION_INTERNAL 0U #define NODE_VERSION_INTERNAL 0U
#define NODE_VERSION "NodeMCU 0.9.5" #define NODE_VERSION "NodeMCU 0.9.5"
#define BUILD_DATE "build 20150123" #define BUILD_DATE "build 20150124"
// #define FLASH_512K // #define FLASH_512K
// #define FLASH_1M // #define FLASH_1M
@ -18,6 +18,9 @@
#define FULL_VERSION_FOR_USER #define FULL_VERSION_FOR_USER
#ifdef DEVELOP_VERSION #ifdef DEVELOP_VERSION
#define USE_OPTIMIZE_PRINTF
#define NODE_DEBUG #define NODE_DEBUG
#endif /* DEVELOP_VERSION */ #endif /* DEVELOP_VERSION */
@ -38,7 +41,7 @@
#define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed)) #define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
#define ICACHE_STORE_ATTR __attribute__((aligned(4))) #define ICACHE_STORE_ATTR __attribute__((aligned(4)))
#define ICACHE_RAM_ATTR __attribute__((section(".iram0.text"))) #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 CLIENT_SSL_ENABLE
#define GPIO_INTERRUPT_ENABLE #define GPIO_INTERRUPT_ENABLE

View File

@ -47,6 +47,10 @@ extern int c_stderr;
#define SEEK_END 2 /* set file offset to EOF plus offset */ #define SEEK_END 2 /* set file offset to EOF plus offset */
#endif #endif
#define c_malloc os_malloc
#define c_zalloc os_zalloc
#define c_free os_free
extern void output_redirect(const char *str); extern void output_redirect(const char *str);
#define c_puts output_redirect #define c_puts output_redirect

View File

@ -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 // make sure there is enough memory before real malloc, otherwise malloc will panic and reset
void *c_malloc(size_t __size){ // void *c_malloc(size_t __size){
if(__size>system_get_free_heap_size()){ // if(__size>system_get_free_heap_size()){
NODE_ERR("malloc: not enough memory\n"); // NODE_ERR("malloc: not enough memory\n");
return NULL; // return NULL;
} // }
return (void *)os_malloc(__size); // return (void *)os_malloc(__size);
} // }
void *c_zalloc(size_t __size){ // void *c_zalloc(size_t __size){
if(__size>system_get_free_heap_size()){ // if(__size>system_get_free_heap_size()){
NODE_ERR("zalloc: not enough memory\n"); // NODE_ERR("zalloc: not enough memory\n");
return NULL; // return NULL;
} // }
return (void *)os_zalloc(__size); // return (void *)os_zalloc(__size);
} // }
void c_free(void *p){ // void c_free(void *p){
// NODE_ERR("free1: %d\n", system_get_free_heap_size()); // // NODE_ERR("free1: %d\n", system_get_free_heap_size());
os_free(p); // os_free(p);
// NODE_ERR("-free1: %d\n", system_get_free_heap_size()); // // NODE_ERR("-free1: %d\n", system_get_free_heap_size());
} // }
// int c_rand(void){ // int c_rand(void){

View File

@ -5,6 +5,7 @@
*/ */
#include "c_string.h" #include "c_string.h"
#include "c_types.h"
#define lundump_c #define lundump_c
#define LUA_CORE #define LUA_CORE
@ -141,13 +142,11 @@ static lua_Number LoadNumber(LoadState* S)
LoadVar(S,y); LoadVar(S,y);
x = (lua_Number)y; x = (lua_Number)y;
} break; } break;
#if 0
case 8: { case 8: {
int64_t y; int64_t y;
LoadVar(S,y); LoadVar(S,y);
x = (lua_Number)y; x = (lua_Number)y;
} break; } break;
#endif
default: lua_assert(0); default: lua_assert(0);
} }
} }

View File

@ -812,10 +812,6 @@ espconn_tcp_accept(void *arg, struct tcp_pcb *pcb, err_t err)
remot_info *pinfo = NULL; remot_info *pinfo = NULL;
LWIP_UNUSED_ARG(err); LWIP_UNUSED_ARG(err);
if(4096>system_get_free_heap_size()){
return ERR_MEM;
}
paccept = (espconn_msg *)os_zalloc(sizeof(espconn_msg)); paccept = (espconn_msg *)os_zalloc(sizeof(espconn_msg));
tcp_arg(pcb, paccept); tcp_arg(pcb, paccept);
tcp_err(pcb, esponn_server_err); tcp_err(pcb, esponn_server_err);

View File

@ -147,14 +147,33 @@ static int tmr_wdclr( lua_State* L )
return 0; 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 // Lua: time() , return rtc time in us
static int tmr_time( lua_State* L ) static int tmr_time( lua_State* L )
{ {
unsigned t = 0xFFFFFFFF & system_get_rtc_time(); lua_pushinteger( L, rtc_second & 0x7FFFFFFF );
unsigned c = 0xFFFFFFFF & system_rtc_clock_cali_proc(); return 1;
lua_pushinteger( L, t );
lua_pushinteger( L, c );
return 2;
} }
// Module function map // 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_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 #if LUA_OPTIMIZE_MEMORY > 0
return 0; return 0;
#else // #if LUA_OPTIMIZE_MEMORY > 0 #else // #if LUA_OPTIMIZE_MEMORY > 0

View File

@ -12,6 +12,7 @@
#include "c_types.h" #include "c_types.h"
#include "user_interface.h" #include "user_interface.h"
#include "smart.h" #include "smart.h"
#include "smartconfig.h"
static int wifi_smart_succeed = LUA_NOREF; 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"); NODE_DBG("wifi_smart_succeed_cb is called.\n");
if( !arg ) if( !arg )
return; 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) if(wifi_smart_succeed == LUA_NOREF)
return; return;
lua_State* L = (lua_State *)arg; 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(channel, function succeed_cb)
// Lua: smart(type, function succeed_cb)
static int wifi_start_smart( lua_State* L ) static int wifi_start_smart( lua_State* L )
{ {
unsigned channel; unsigned channel;
@ -109,13 +118,15 @@ static int wifi_start_smart( lua_State* L )
}else{ }else{
smart_begin(channel, (smart_succeed )wifi_smart_succeed_cb, L); smart_begin(channel, (smart_succeed )wifi_smart_succeed_cb, L);
} }
// smartconfig_start(0, wifi_smart_succeed_cb);
return 0; return 0;
} }
// Lua: exit_smart(channel) // Lua: exit_smart()
static int wifi_exit_smart( lua_State* L ) static int wifi_exit_smart( lua_State* L )
{ {
smart_end(); smart_end();
// smartconfig_stop();
if(wifi_smart_succeed != LUA_NOREF) if(wifi_smart_succeed != LUA_NOREF)
luaL_unref(L, LUA_REGISTRYINDEX, wifi_smart_succeed); luaL_unref(L, LUA_REGISTRYINDEX, wifi_smart_succeed);
wifi_smart_succeed = LUA_NOREF; wifi_smart_succeed = LUA_NOREF;

85
include/at_custom.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -16,6 +16,7 @@ typedef unsigned long uint32_t;
typedef signed long sint32_t; typedef signed long sint32_t;
typedef signed long int32_t; typedef signed long int32_t;
typedef signed long long sint64_t; typedef signed long long sint64_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
typedef unsigned long long u_int64_t; typedef unsigned long long u_int64_t;
typedef float real32_t; typedef float real32_t;
@ -78,6 +79,7 @@ typedef enum {
#ifdef ICACHE_FLASH #ifdef ICACHE_FLASH
#define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text"))) #define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text")))
#define ICACHE_RODATA_ATTR __attribute__((section(".irom.text")))
#else #else
#define ICACHE_FLASH_ATTR #define ICACHE_FLASH_ATTR
#endif /* ICACHE_FLASH */ #endif /* ICACHE_FLASH */

View File

@ -91,6 +91,7 @@ struct espconn {
enum espconn_option{ enum espconn_option{
ESPCONN_REUSEADDR = 1, ESPCONN_REUSEADDR = 1,
ESPCONN_NODELAY,
ESPCONN_END 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); 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 #endif

View File

@ -52,6 +52,11 @@ struct ip_info {
#define ip4_addr3_16(ipaddr) ((uint16)ip4_addr3(ipaddr)) #define ip4_addr3_16(ipaddr) ((uint16)ip4_addr3(ipaddr))
#define ip4_addr4_16(ipaddr) ((uint16)ip4_addr4(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); uint32 ipaddr_addr(const char *cp);
#define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \ #define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \

View File

@ -44,5 +44,14 @@
#define os_sprintf ets_sprintf #define os_sprintf ets_sprintf
#define os_update_cpu_frequency ets_update_cpu_frequency #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 #endif

32
include/ping.h Normal file
View File

@ -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__ */

28
include/smartconfig.h Normal file
View File

@ -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

View File

@ -24,8 +24,6 @@ typedef struct{
#define SPI_FLASH_SEC_SIZE 4096 #define SPI_FLASH_SEC_SIZE 4096
uint32 spi_flash_get_id(void); 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_erase_sector(uint16 sec);
SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size); SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size); SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size);

View File

@ -43,11 +43,15 @@ struct rst_info{
void system_restore(void); void system_restore(void);
void system_restart(void); void system_restart(void);
bool system_deep_sleep_set_option(uint8 option);
void system_deep_sleep(uint32 time_in_us); void system_deep_sleep(uint32 time_in_us);
uint8 system_upgrade_userbin_check(void); uint8 system_upgrade_userbin_check(void);
void system_upgrade_reboot(void); void system_upgrade_reboot(void);
uint8 system_upgrade_flag_check(); uint8 system_upgrade_flag_check();
void system_upgrade_flag_set(uint8 flag); void system_upgrade_flag_set(uint8 flag);
void system_timer_reinit(void); void system_timer_reinit(void);
uint32 system_get_time(void); uint32 system_get_time(void);
@ -59,13 +63,14 @@ enum {
USER_TASK_PRIO_MAX USER_TASK_PRIO_MAX
}; };
void system_os_task(os_task_t task, uint8 prio, os_event_t *queue, uint8 qlen); bool 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_post(uint8 prio, os_signal_t sig, os_param_t par);
void system_print_meminfo(void); void system_print_meminfo(void);
uint32 system_get_free_heap_size(void); uint32 system_get_free_heap_size(void);
void system_set_os_print(uint8 onoff); 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); 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 SOFTAP_MODE 0x02
#define STATIONAP_MODE 0x03 #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); uint8 wifi_get_opmode(void);
bool wifi_set_opmode(uint8 opmode); bool wifi_set_opmode(uint8 opmode);
@ -102,7 +116,7 @@ struct bss_info {
uint8 ssid[32]; uint8 ssid[32];
uint8 channel; uint8 channel;
sint8 rssi; sint8 rssi;
uint8 authmode; AUTH_MODE authmode;
uint8 is_hidden; uint8 is_hidden;
}; };
@ -120,7 +134,8 @@ typedef void (* scan_done_cb_t)(void *arg, STATUS status);
struct station_config { struct station_config {
uint8 ssid[32]; uint8 ssid[32];
uint8 password[64]; 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]; uint8 bssid[6];
}; };
@ -131,10 +146,10 @@ bool wifi_station_connect(void);
bool wifi_station_disconnect(void); bool wifi_station_disconnect(void);
struct scan_config { struct scan_config {
uint8 *ssid; uint8 *ssid; // Note: ssid == NULL, don't filter ssid.
uint8 *bssid; uint8 *bssid; // Note: bssid == NULL, don't filter bssid.
uint8 channel; uint8 channel; // Note: channel == 0, scan all channels, otherwise scan set channel.
uint8 show_hidden; 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); 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); bool wifi_station_dhcpc_stop(void);
enum dhcp_status wifi_station_dhcpc_status(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 { struct softap_config {
uint8 ssid[32]; uint8 ssid[32];
uint8 password[64]; uint8 password[64];
uint8 ssid_len; uint8 ssid_len; // Note: Recommend to set it according to your ssid
uint8 channel; uint8 channel; // Note: support 1 ~ 13
uint8 authmode; AUTH_MODE authmode; // Note: Don't support AUTH_WEP in softAP mode.
uint8 ssid_hidden; uint8 ssid_hidden; // Note: default 0
uint8 max_connection; 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); bool wifi_softap_get_config(struct softap_config *config);
@ -220,6 +228,7 @@ uint8 wifi_get_channel(void);
bool wifi_set_channel(uint8 channel); bool wifi_set_channel(uint8 channel);
void wifi_status_led_install(uint8 gpio_id, uint32 gpio_name, uint8 gpio_func); 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) /** Get the absolute difference between 2 u32_t values (correcting overflows)
* 'a' is expected to be 'higher' (without overflow) than 'b'. */ * 'a' is expected to be 'higher' (without overflow) than 'b'. */

View File

@ -18,6 +18,7 @@ PROVIDE ( SHA1Transform = 0x4000a364 );
PROVIDE ( SHA1Update = 0x4000b5a8 ); PROVIDE ( SHA1Update = 0x4000b5a8 );
PROVIDE ( SPI_read_status = 0x400043c8 ); PROVIDE ( SPI_read_status = 0x400043c8 );
PROVIDE ( SPI_write_status = 0x40004400 ); PROVIDE ( SPI_write_status = 0x40004400 );
PROVIDE ( SPI_write_enable = 0x4000443c );
PROVIDE ( Wait_SPI_Idle = 0x4000448c ); PROVIDE ( Wait_SPI_Idle = 0x4000448c );
PROVIDE ( SPIEraseArea = 0x40004b44 ); PROVIDE ( SPIEraseArea = 0x40004b44 );
PROVIDE ( SPIEraseBlock = 0x400049b4 ); PROVIDE ( SPIEraseBlock = 0x400049b4 );

BIN
lib/libat.a Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/libsmartconfig.a Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.