mirror of
https://github.com/nodemcu/nodemcu-firmware.git
synced 2025-01-30 21:12:55 +08:00
Merge branch 'dev096' of https://github.com/nodemcu/nodemcu-firmware into dev
This commit is contained in:
commit
47bbbb8d38
@ -3,10 +3,10 @@
|
||||
|
||||
#define NODE_VERSION_MAJOR 0U
|
||||
#define NODE_VERSION_MINOR 9U
|
||||
#define NODE_VERSION_REVISION 5U
|
||||
#define NODE_VERSION_REVISION 6U
|
||||
#define NODE_VERSION_INTERNAL 0U
|
||||
|
||||
#define NODE_VERSION "NodeMCU 0.9.5"
|
||||
#define NODE_VERSION "NodeMCU 0.9.6"
|
||||
#define BUILD_DATE "build 20150405"
|
||||
|
||||
#endif /* __USER_VERSION_H__ */
|
||||
|
@ -336,7 +336,7 @@ const LUA_REG_TYPE math_map[] = {
|
||||
{LSTRKEY("floor"), LFUNCVAL(math_floor)},
|
||||
// {LSTRKEY("fmod"), LFUNCVAL(math_fmod)},
|
||||
#if LUA_OPTIMIZE_MEMORY > 0 && defined(LUA_COMPAT_MOD)
|
||||
{LSTRKEY("mod"), LFUNCVAL(math_fmod)},
|
||||
// {LSTRKEY("mod"), LFUNCVAL(math_fmod)},
|
||||
#endif
|
||||
// {LSTRKEY("frexp"), LFUNCVAL(math_frexp)},
|
||||
// {LSTRKEY("ldexp"), LFUNCVAL(math_ldexp)},
|
||||
|
10
app/lwip/app/dummy.c
Normal file
10
app/lwip/app/dummy.c
Normal file
@ -0,0 +1,10 @@
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_init
|
||||
* Description : dummy the espconn_init
|
||||
* Parameters : none
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
void espconn_init()
|
||||
{
|
||||
// dummy function, do nothing.
|
||||
}
|
@ -24,18 +24,23 @@ static int adc_sample( lua_State* L )
|
||||
static int adc_readvdd33( lua_State* L )
|
||||
{
|
||||
uint32_t vdd33 = 0;
|
||||
|
||||
if(STATION_MODE == wifi_get_opmode())
|
||||
{
|
||||
// Bug fix
|
||||
wifi_set_opmode( STATIONAP_MODE );
|
||||
vdd33 = readvdd33();
|
||||
wifi_set_opmode( STATION_MODE );
|
||||
if (wifi_station_get_connect_status()!=0)
|
||||
{
|
||||
return luaL_error( L, "Can't read vdd33 while station is connected" );
|
||||
}
|
||||
else
|
||||
{
|
||||
vdd33 = readvdd33();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vdd33 = readvdd33();
|
||||
}
|
||||
|
||||
lua_pushinteger(L, vdd33);
|
||||
return 1;
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ READPACKET:
|
||||
if(mud->mqtt_state.message_length < mud->mqtt_state.message_length_read)
|
||||
{
|
||||
length -= mud->mqtt_state.message_length;
|
||||
pdata += mud->mqtt_state.message_length;
|
||||
in_buffer += mud->mqtt_state.message_length;
|
||||
|
||||
NODE_DBG("Get another published message\r\n");
|
||||
goto READPACKET;
|
||||
|
@ -11,11 +11,18 @@
|
||||
|
||||
static os_timer_t alarm_timer[NUM_TMR];
|
||||
static int alarm_timer_cb_ref[NUM_TMR] = {LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF};
|
||||
static bool alarm_timer_repeat[NUM_TMR]= {0,0,0,0,0,0,0};
|
||||
|
||||
void alarm_timer_common(lua_State* L, unsigned id){
|
||||
if(alarm_timer_cb_ref[id] == LUA_NOREF)
|
||||
return;
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, alarm_timer_cb_ref[id]);
|
||||
if(alarm_timer_repeat[id]==0)
|
||||
{
|
||||
if(alarm_timer_cb_ref[id] != LUA_NOREF)
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, alarm_timer_cb_ref[id]);
|
||||
|
||||
}
|
||||
lua_call(L, 0, 0);
|
||||
}
|
||||
|
||||
@ -118,6 +125,7 @@ static int tmr_alarm( lua_State* L )
|
||||
stack++;
|
||||
if ( repeat != 1 && repeat != 0 )
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
alarm_timer_repeat[id]=repeat;
|
||||
}
|
||||
|
||||
// luaL_checkanyfunction(L, stack);
|
||||
@ -141,6 +149,9 @@ static int tmr_stop( lua_State* L )
|
||||
MOD_CHECK_ID( tmr, id );
|
||||
|
||||
os_timer_disarm(&(alarm_timer[id]));
|
||||
if(alarm_timer_cb_ref[id] != LUA_NOREF)
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, alarm_timer_cb_ref[id]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "smartconfig.h"
|
||||
|
||||
static int wifi_smart_succeed = LUA_NOREF;
|
||||
static uint8 getap_output_format=0;
|
||||
|
||||
static void wifi_smart_succeed_cb(void *arg){
|
||||
NODE_DBG("wifi_smart_succeed_cb is called.\n");
|
||||
@ -71,22 +72,35 @@ static void wifi_scan_done(void *arg, STATUS status)
|
||||
{
|
||||
c_memcpy(ssid, bss_link->ssid, 32);
|
||||
}
|
||||
c_sprintf(temp,"%d,%d,"MACSTR",%d", bss_link->authmode, bss_link->rssi,
|
||||
MAC2STR(bss_link->bssid),bss_link->channel);
|
||||
|
||||
lua_pushstring(gL, temp);
|
||||
lua_setfield( gL, -2, ssid );
|
||||
|
||||
// NODE_DBG(temp);
|
||||
if(getap_output_format==1) //use new format(BSSID : SSID, RSSI, Authmode, Channel)
|
||||
{
|
||||
c_sprintf(temp,"%s,%d,%d,%d", ssid, bss_link->rssi, bss_link->authmode, bss_link->channel);
|
||||
lua_pushstring(gL, temp);
|
||||
NODE_DBG(MACSTR" : %s\n",MAC2STR(bss_link->bssid) , temp);
|
||||
c_sprintf(temp,MACSTR, MAC2STR(bss_link->bssid));
|
||||
lua_setfield( gL, -2, temp);
|
||||
}
|
||||
else//use old format(SSID : Authmode, RSSI, BSSID, Channel)
|
||||
{
|
||||
c_sprintf(temp,"%d,%d,"MACSTR",%d", bss_link->authmode, bss_link->rssi, MAC2STR(bss_link->bssid),bss_link->channel);
|
||||
lua_pushstring(gL, temp);
|
||||
lua_setfield( gL, -2, ssid );
|
||||
NODE_DBG("%s : %s\n", ssid, temp);
|
||||
}
|
||||
|
||||
bss_link = bss_link->next.stqe_next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnil(gL);
|
||||
lua_newtable( gL );
|
||||
}
|
||||
lua_call(gL, 1, 0);
|
||||
if(wifi_scan_succeed != LUA_NOREF)
|
||||
{
|
||||
luaL_unref(gL, LUA_REGISTRYINDEX, wifi_scan_succeed);
|
||||
wifi_scan_succeed = LUA_NOREF;
|
||||
}
|
||||
}
|
||||
|
||||
// Lua: smart(channel, function succeed_cb)
|
||||
@ -150,6 +164,7 @@ static int wifi_setmode( lua_State* L )
|
||||
}
|
||||
|
||||
// Lua: realmode = getmode()
|
||||
|
||||
static int wifi_getmode( lua_State* L )
|
||||
{
|
||||
unsigned mode;
|
||||
@ -157,7 +172,77 @@ static int wifi_getmode( lua_State* L )
|
||||
lua_pushinteger( L, mode );
|
||||
return 1;
|
||||
}
|
||||
/**
|
||||
* wifi.getchannel()
|
||||
* Description:
|
||||
* Get current wifi Channel
|
||||
*
|
||||
* Syntax:
|
||||
* wifi.getchannel()
|
||||
* Parameters:
|
||||
* nil
|
||||
*
|
||||
* Returns:
|
||||
* Current wifi channel
|
||||
*/
|
||||
|
||||
static int wifi_getchannel( lua_State* L )
|
||||
{
|
||||
unsigned channel;
|
||||
channel = (unsigned)wifi_get_channel();
|
||||
lua_pushinteger( L, channel );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* wifi.setphymode()
|
||||
* Description:
|
||||
* Set wifi physical mode(802.11 b/g/n)
|
||||
* Note: SoftAP only supports 802.11 b/g.
|
||||
* Syntax:
|
||||
* wifi.setphymode(mode)
|
||||
* Parameters:
|
||||
* mode:
|
||||
* wifi.PHYMODE_B
|
||||
* wifi.PHYMODE_G
|
||||
* wifi.PHYMODE_N
|
||||
* Returns:
|
||||
* Current physical mode after setup
|
||||
*/
|
||||
|
||||
static int wifi_setphymode( lua_State* L )
|
||||
{
|
||||
unsigned mode;
|
||||
|
||||
mode = luaL_checkinteger( L, 1 );
|
||||
|
||||
if ( mode != PHY_MODE_11B && mode != PHY_MODE_11G && mode != PHY_MODE_11N )
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
wifi_set_phy_mode( (uint8_t)mode);
|
||||
mode = (unsigned)wifi_get_phy_mode();
|
||||
lua_pushinteger( L, mode );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* wifi.getphymode()
|
||||
* Description:
|
||||
* Get wifi physical mode(802.11 b/g/n)
|
||||
* Syntax:
|
||||
* wifi.getphymode()
|
||||
* Parameters:
|
||||
* nil
|
||||
* Returns:
|
||||
* Current physical mode.
|
||||
*
|
||||
*/
|
||||
static int wifi_getphymode( lua_State* L )
|
||||
{
|
||||
unsigned mode;
|
||||
mode = (unsigned)wifi_get_phy_mode();
|
||||
lua_pushinteger( L, mode );
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Lua: mac = wifi.xx.getmac()
|
||||
static int wifi_getmac( lua_State* L, uint8_t mode )
|
||||
@ -165,7 +250,7 @@ static int wifi_getmac( lua_State* L, uint8_t mode )
|
||||
char temp[64];
|
||||
uint8_t mac[6];
|
||||
wifi_get_macaddr(mode, mac);
|
||||
c_sprintf(temp, "%02X-%02X-%02X-%02X-%02X-%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] );
|
||||
c_sprintf(temp, MACSTR, MAC2STR(mac));
|
||||
lua_pushstring( L, temp );
|
||||
return 1;
|
||||
}
|
||||
@ -173,11 +258,13 @@ static int wifi_getmac( lua_State* L, uint8_t mode )
|
||||
// Lua: mac = wifi.xx.setmac()
|
||||
static int wifi_setmac( lua_State* L, uint8_t mode )
|
||||
{
|
||||
uint8_t mac[6];
|
||||
unsigned len = 0;
|
||||
const char *mac = luaL_checklstring( L, 1, &len );
|
||||
if(len!=6)
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
const char *macaddr = luaL_checklstring( L, 1, &len );
|
||||
if(len!=17)
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
|
||||
os_str2macaddr(mac, macaddr);
|
||||
lua_pushboolean(L,wifi_set_macaddr(mode, (uint8 *)mac));
|
||||
return 1;
|
||||
}
|
||||
@ -255,7 +342,7 @@ static int wifi_setip( lua_State* L, uint8_t mode )
|
||||
pTempIp.netmask.addr = ip;
|
||||
|
||||
ip = parse_key(L, "gateway");
|
||||
if(ip!=0)
|
||||
if(mode==SOFTAP_IF || ip!=0)
|
||||
pTempIp.gw.addr = ip;
|
||||
|
||||
if(STATION_IF == mode)
|
||||
@ -318,12 +405,83 @@ static int wifi_station_getbroadcast( lua_State* L ){
|
||||
return wifi_getbroadcast(L, STATION_IF);
|
||||
}
|
||||
|
||||
// Lua: wifi.sta.config(ssid, password)
|
||||
/**
|
||||
* wifi.sta.getconfig()
|
||||
* Description:
|
||||
* Get current Station configuration.
|
||||
* Note: if bssid_set==1 STATION is configured to connect to specified BSSID
|
||||
* if bssid_set==0 specified BSSID address is irrelevant.
|
||||
* Syntax:
|
||||
* ssid, pwd, bssid_set, bssid=wifi.sta.getconfig()
|
||||
* Parameters:
|
||||
* none
|
||||
* Returns:
|
||||
* SSID, Password, BSSID_set, BSSID
|
||||
*/
|
||||
static int wifi_station_getconfig( lua_State* L )
|
||||
{
|
||||
struct station_config sta_conf;
|
||||
char bssid[17];
|
||||
wifi_station_get_config(&sta_conf);
|
||||
if(sta_conf.ssid==0)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushstring( L, sta_conf.ssid );
|
||||
lua_pushstring( L, sta_conf.password );
|
||||
lua_pushinteger( L, sta_conf.bssid_set);
|
||||
c_sprintf(bssid, MACSTR, MAC2STR(sta_conf.bssid));
|
||||
lua_pushstring( L, bssid);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* wifi.sta.config()
|
||||
* Description:
|
||||
* Set current Station configuration.
|
||||
* Note: If there are multiple APs with the same ssid, you can connect to a specific one by entering it's MAC address into the "bssid" field.
|
||||
* Syntax:
|
||||
* wifi.sta.getconfig(ssid, password) --Set STATION configuration, Auto-connect by default, Connects to any BSSID
|
||||
* wifi.sta.getconfig(ssid, password, Auto_connect) --Set STATION configuration, Auto-connect(0 or 1), Connects to any BSSID
|
||||
* wifi.sta.getconfig(ssid, password, bssid) --Set STATION configuration, Auto-connect by default, Connects to specific BSSID
|
||||
* wifi.sta.getconfig(ssid, password, Auto_connect, bssid) --Set STATION configuration, Auto-connect(0 or 1), Connects to specific BSSID
|
||||
* Parameters:
|
||||
* ssid: string which is less than 32 bytes.
|
||||
* Password: string which is less than 64 bytes.
|
||||
* Auto_connect: 0 (disable Auto-connect) or 1 (to enable Auto-connect).
|
||||
* bssid: MAC address of Access Point you would like to connect to.
|
||||
* Returns:
|
||||
* Nothing.
|
||||
*
|
||||
* Example:
|
||||
--Connect to Access Point automatically when in range
|
||||
wifi.sta.getconfig("myssid", "password")
|
||||
|
||||
--Connect to Access Point, User decides when to connect/disconnect to/from AP
|
||||
wifi.sta.getconfig("myssid", "mypassword", 0)
|
||||
wifi.sta.connect()
|
||||
--do some wifi stuff
|
||||
wifi.sta.disconnect()
|
||||
|
||||
--Connect to specific Access Point automatically when in range
|
||||
wifi.sta.getconfig("myssid", "mypassword", "12:34:56:78:90:12")
|
||||
|
||||
--Connect to specific Access Point, User decides when to connect/disconnect to/from AP
|
||||
wifi.sta.getconfig("myssid", "mypassword", 0)
|
||||
wifi.sta.connect()
|
||||
--do some wifi stuff
|
||||
wifi.sta.disconnect()
|
||||
*
|
||||
*/
|
||||
static int wifi_station_config( lua_State* L )
|
||||
{
|
||||
size_t sl, pl;
|
||||
size_t sl, pl, ml;
|
||||
struct station_config sta_conf;
|
||||
int i;
|
||||
int auto_connect=0;
|
||||
const char *ssid = luaL_checklstring( L, 1, &sl );
|
||||
if (sl>32 || ssid == NULL)
|
||||
return luaL_error( L, "ssid:<32" );
|
||||
@ -331,23 +489,77 @@ static int wifi_station_config( lua_State* L )
|
||||
if (pl!=0 && (pl<8 || pl>64) || password == NULL)
|
||||
return luaL_error( L, "pwd:0,8~64" );
|
||||
|
||||
if(lua_isnumber(L, 3))
|
||||
{
|
||||
auto_connect=luaL_checkinteger( L, 3 );;
|
||||
if ( auto_connect != 0 && auto_connect != 1)
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
}
|
||||
else if (lua_isstring(L, 3)&& !(lua_isnumber(L, 3)))
|
||||
{
|
||||
lua_pushnil(L);
|
||||
lua_insert(L, 3);
|
||||
auto_connect=1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(lua_isnil(L, 3))
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
auto_connect=1;
|
||||
}
|
||||
|
||||
if(lua_isnumber(L, 4))
|
||||
{
|
||||
sta_conf.bssid_set = 0;
|
||||
c_memset(sta_conf.bssid, 0, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lua_isstring(L, 4))
|
||||
{
|
||||
const char *macaddr = luaL_checklstring( L, 4, &ml );
|
||||
if (ml!=17)
|
||||
return luaL_error( L, "MAC:FF:FF:FF:FF:FF:FF" );
|
||||
c_memset(sta_conf.bssid, 0, 6);
|
||||
os_str2macaddr(sta_conf.bssid, macaddr);
|
||||
sta_conf.bssid_set = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sta_conf.bssid_set = 0;
|
||||
c_memset(sta_conf.bssid, 0, 6);
|
||||
}
|
||||
}
|
||||
|
||||
c_memset(sta_conf.ssid, 0, 32);
|
||||
c_memset(sta_conf.password, 0, 64);
|
||||
c_memset(sta_conf.bssid, 0, 6);
|
||||
c_memcpy(sta_conf.ssid, ssid, sl);
|
||||
c_memcpy(sta_conf.password, password, pl);
|
||||
sta_conf.bssid_set = 0;
|
||||
|
||||
NODE_DBG(sta_conf.ssid);
|
||||
NODE_DBG(" %d\n", sl);
|
||||
NODE_DBG(sta_conf.password);
|
||||
NODE_DBG(" %d\n", pl);
|
||||
NODE_DBG(" %d\n", sta_conf.bssid_set);
|
||||
NODE_DBG( MACSTR, MAC2STR(sta_conf.bssid));
|
||||
NODE_DBG("\n");
|
||||
|
||||
|
||||
wifi_station_set_config(&sta_conf);
|
||||
wifi_station_set_auto_connect(true);
|
||||
wifi_station_disconnect();
|
||||
wifi_station_connect();
|
||||
// station_check_connect(0);
|
||||
|
||||
if(auto_connect==0)
|
||||
{
|
||||
wifi_station_set_auto_connect(false);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
wifi_station_set_auto_connect(true);
|
||||
wifi_station_connect();
|
||||
}
|
||||
// station_check_connect(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -381,7 +593,42 @@ static int wifi_station_setauto( lua_State* L )
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Lua: table = wifi.sta.getap()
|
||||
/**
|
||||
* wifi.sta.listap()
|
||||
* Description:
|
||||
* scan and get ap list as a lua table into callback function.
|
||||
* Syntax:
|
||||
* wifi.sta.getap(function(table))
|
||||
* wifi.sta.getap(format, function(table))
|
||||
* wifi.sta.getap(cfg, function(table))
|
||||
* wifi.sta.getap(cfg, format, function(table))
|
||||
* Parameters:
|
||||
* cfg: table that contains scan configuration
|
||||
* Format:Select output table format.
|
||||
* 0 for the old format (SSID : Authmode, RSSI, BSSID, Channel) (Default)
|
||||
* 1 for the new format (BSSID : SSID, RSSI, Authmode, Channel)
|
||||
* function(table): a callback function to receive ap table when scan is done
|
||||
this function receive a table, the key is the ssid,
|
||||
value is other info in format: authmode,rssi,bssid,channel
|
||||
* Returns:
|
||||
* nil
|
||||
*
|
||||
* Example:
|
||||
--original function left intact to preserve backward compatibility
|
||||
wifi.sta.getap(function(T) for k,v in pairs(T) do print(k..":"..v) end end)
|
||||
|
||||
--if no scan configuration is desired cfg can be set to nil or previous example can be used
|
||||
wifi.sta.getap(nil, function(T) for k,v in pairs(T) do print(k..":"..v) end end)
|
||||
|
||||
--scan configuration
|
||||
scan_cfg={}
|
||||
scan_cfg.ssid="myssid" --if set to nil, ssid is not filtered
|
||||
scan_cfg.bssid="AA:AA:AA:AA:AA:AA" --if set to nil, MAC address is not filtered
|
||||
scan_cfg.channel=0 --if set to nil, channel will default to 0(scans all channels), if set scan will be faster
|
||||
scan_cfg.show_hidden=1 --if set to nil, show_hidden will default to 0
|
||||
wifi.sta.getap(scan_cfg, function(T) for k,v in pairs(T) do print(k..":"..v) end end)
|
||||
|
||||
*/
|
||||
static int wifi_station_listap( lua_State* L )
|
||||
{
|
||||
if(wifi_get_opmode() == SOFTAP_MODE)
|
||||
@ -389,14 +636,146 @@ static int wifi_station_listap( lua_State* L )
|
||||
return luaL_error( L, "Can't list ap in SOFTAP mode" );
|
||||
}
|
||||
gL = L;
|
||||
// luaL_checkanyfunction(L, 1);
|
||||
if (lua_type(L, 1) == LUA_TFUNCTION || lua_type(L, 1) == LUA_TLIGHTFUNCTION){
|
||||
lua_pushvalue(L, 1); // copy argument (func) to the top of stack
|
||||
struct scan_config scan_cfg;
|
||||
getap_output_format=0;
|
||||
|
||||
if (lua_type(L, 1)==LUA_TTABLE)
|
||||
{
|
||||
char ssid[32];
|
||||
char bssid[6];
|
||||
uint8 channel=0;
|
||||
uint8 show_hidden=0;
|
||||
size_t len;
|
||||
|
||||
lua_getfield(L, 1, "ssid");
|
||||
if (!lua_isnil(L, -1)){ /* found? */
|
||||
if( lua_isstring(L, -1) ) // deal with the ssid string
|
||||
{
|
||||
const char *ssidstr = luaL_checklstring( L, -1, &len );
|
||||
if(len>32)
|
||||
return luaL_error( L, "ssid:<32" );
|
||||
c_memset(ssid, 0, 32);
|
||||
c_memcpy(ssid, ssidstr, len);
|
||||
scan_cfg.ssid=ssid;
|
||||
NODE_DBG(scan_cfg.ssid);
|
||||
NODE_DBG("\n");
|
||||
}
|
||||
else
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
}
|
||||
else
|
||||
scan_cfg.ssid=NULL;
|
||||
|
||||
lua_getfield(L, 1, "bssid");
|
||||
if (!lua_isnil(L, -1)){ /* found? */
|
||||
if( lua_isstring(L, -1) ) // deal with the ssid string
|
||||
{
|
||||
const char *macaddr = luaL_checklstring( L, -1, &len );
|
||||
if(len!=17)
|
||||
return luaL_error( L, "bssid: FF:FF:FF:FF:FF:FF" );
|
||||
c_memset(bssid, 0, 6);
|
||||
os_str2macaddr(bssid, macaddr);
|
||||
scan_cfg.bssid=bssid;
|
||||
NODE_DBG(MACSTR, MAC2STR(scan_cfg.bssid));
|
||||
NODE_DBG("\n");
|
||||
|
||||
}
|
||||
else
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
}
|
||||
else
|
||||
scan_cfg.bssid=NULL;
|
||||
|
||||
|
||||
lua_getfield(L, 1, "channel");
|
||||
if (!lua_isnil(L, -1)){ /* found? */
|
||||
if( lua_isnumber(L, -1) ) // deal with the ssid string
|
||||
{
|
||||
channel = luaL_checknumber( L, -1);
|
||||
if(!(channel>=0 && channel<=13))
|
||||
return luaL_error( L, "channel: 0 or 1-13" );
|
||||
scan_cfg.channel=channel;
|
||||
NODE_DBG("%d\n", scan_cfg.channel);
|
||||
}
|
||||
else
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
}
|
||||
else
|
||||
scan_cfg.channel=0;
|
||||
|
||||
lua_getfield(L, 1, "show_hidden");
|
||||
if (!lua_isnil(L, -1)){ /* found? */
|
||||
if( lua_isnumber(L, -1) ) // deal with the ssid string
|
||||
{
|
||||
show_hidden = luaL_checknumber( L, -1);
|
||||
if(show_hidden!=0 && show_hidden!=1)
|
||||
return luaL_error( L, "show_hidden: 0 or 1" );
|
||||
scan_cfg.show_hidden=show_hidden;
|
||||
NODE_DBG("%d\n", scan_cfg.show_hidden);
|
||||
|
||||
}
|
||||
else
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
}
|
||||
else
|
||||
scan_cfg.show_hidden=0;
|
||||
if (lua_type(L, 2) == LUA_TFUNCTION || lua_type(L, 2) == LUA_TLIGHTFUNCTION)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
lua_insert(L, 2);
|
||||
}
|
||||
lua_pop(L, -4);
|
||||
}
|
||||
else if (lua_type(L, 1) == LUA_TNUMBER)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
lua_insert(L, 1);
|
||||
}
|
||||
else if (lua_type(L, 1) == LUA_TFUNCTION || lua_type(L, 1) == LUA_TLIGHTFUNCTION)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
lua_insert(L, 1);
|
||||
lua_pushnil(L);
|
||||
lua_insert(L, 1);
|
||||
}
|
||||
else if(lua_isnil(L, 1))
|
||||
{
|
||||
if (lua_type(L, 2) == LUA_TFUNCTION || lua_type(L, 2) == LUA_TLIGHTFUNCTION)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
lua_insert(L, 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
}
|
||||
|
||||
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) //this section changes the output format
|
||||
{
|
||||
getap_output_format=luaL_checkinteger( L, 2 );
|
||||
if ( getap_output_format != 0 && getap_output_format != 1)
|
||||
return luaL_error( L, "wrong arg type" );
|
||||
}
|
||||
NODE_DBG("Use alternate output format: %d\n", getap_output_format);
|
||||
if (lua_type(L, 3) == LUA_TFUNCTION || lua_type(L, 3) == LUA_TLIGHTFUNCTION)
|
||||
{
|
||||
lua_pushvalue(L, 3); // copy argument (func) to the top of stack
|
||||
if(wifi_scan_succeed != LUA_NOREF)
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, wifi_scan_succeed);
|
||||
wifi_scan_succeed = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
wifi_station_scan(NULL,wifi_scan_done);
|
||||
} else {
|
||||
if (lua_type(L, 1)==LUA_TTABLE)
|
||||
{
|
||||
wifi_station_scan(&scan_cfg,wifi_scan_done);
|
||||
}
|
||||
else
|
||||
{
|
||||
wifi_station_scan(NULL,wifi_scan_done);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(wifi_scan_succeed != LUA_NOREF)
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, wifi_scan_succeed);
|
||||
wifi_scan_succeed = LUA_NOREF;
|
||||
@ -491,8 +870,7 @@ static int wifi_ap_config( lua_State* L )
|
||||
if (!lua_isnil(L, -1))
|
||||
{
|
||||
config.authmode = (uint8_t)luaL_checkinteger(L, -1);
|
||||
NODE_DBG(config.authmode);
|
||||
NODE_DBG("\n");
|
||||
NODE_DBG("%d\n", config.authmode);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -507,8 +885,7 @@ static int wifi_ap_config( lua_State* L )
|
||||
return luaL_error( L, "channel:1~13" );
|
||||
|
||||
config.channel = (uint8_t)channel;
|
||||
NODE_DBG(config.channel);
|
||||
NODE_DBG("\n");
|
||||
NODE_DBG("%d\n", config.channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -519,7 +896,7 @@ static int wifi_ap_config( lua_State* L )
|
||||
if (!lua_isnil(L, -1))
|
||||
{
|
||||
config.ssid_hidden = (uint8_t)luaL_checkinteger(L, -1);
|
||||
NODE_DBG(config.ssid_hidden);
|
||||
NODE_DBG("%d\n", config.ssid_hidden);
|
||||
NODE_DBG("\n");
|
||||
}
|
||||
else
|
||||
@ -535,8 +912,7 @@ static int wifi_ap_config( lua_State* L )
|
||||
return luaL_error( L, "max:1~4" );
|
||||
|
||||
config.max_connection = (uint8_t)max;
|
||||
NODE_DBG(config.max_connection);
|
||||
NODE_DBG("\n");
|
||||
NODE_DBG("%d\n", config.max_connection);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -551,8 +927,7 @@ static int wifi_ap_config( lua_State* L )
|
||||
return luaL_error( L, "beacon:100~60000" );
|
||||
|
||||
config.beacon_interval = (uint16_t)beacon;
|
||||
NODE_DBG(config.beacon_interval);
|
||||
NODE_DBG("\n");
|
||||
NODE_DBG("%d\n", config.beacon_interval);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -650,6 +1025,7 @@ static int wifi_ap_dhcp_stop( lua_State* L )
|
||||
#include "lrodefs.h"
|
||||
static const LUA_REG_TYPE wifi_station_map[] =
|
||||
{
|
||||
{ LSTRKEY( "getconfig" ), LFUNCVAL ( wifi_station_getconfig ) },
|
||||
{ LSTRKEY( "config" ), LFUNCVAL ( wifi_station_config ) },
|
||||
{ LSTRKEY( "connect" ), LFUNCVAL ( wifi_station_connect4lua ) },
|
||||
{ LSTRKEY( "disconnect" ), LFUNCVAL ( wifi_station_disconnect4lua ) },
|
||||
@ -693,6 +1069,9 @@ const LUA_REG_TYPE wifi_map[] =
|
||||
{
|
||||
{ LSTRKEY( "setmode" ), LFUNCVAL( wifi_setmode ) },
|
||||
{ LSTRKEY( "getmode" ), LFUNCVAL( wifi_getmode ) },
|
||||
{ LSTRKEY( "getchannel" ), LFUNCVAL( wifi_getchannel ) },
|
||||
{ LSTRKEY( "setphymode" ), LFUNCVAL( wifi_setphymode ) },
|
||||
{ LSTRKEY( "getphymode" ), LFUNCVAL( wifi_getphymode ) },
|
||||
{ LSTRKEY( "startsmart" ), LFUNCVAL( wifi_start_smart ) },
|
||||
{ LSTRKEY( "stopsmart" ), LFUNCVAL( wifi_exit_smart ) },
|
||||
{ LSTRKEY( "sleeptype" ), LFUNCVAL( wifi_sleeptype ) },
|
||||
@ -705,6 +1084,10 @@ const LUA_REG_TYPE wifi_map[] =
|
||||
{ LSTRKEY( "SOFTAP" ), LNUMVAL( SOFTAP_MODE ) },
|
||||
{ LSTRKEY( "STATIONAP" ), LNUMVAL( STATIONAP_MODE ) },
|
||||
|
||||
{ LSTRKEY( "PHYMODE_B" ), LNUMVAL( PHY_MODE_B ) },
|
||||
{ LSTRKEY( "PHYMODE_G" ), LNUMVAL( PHY_MODE_G ) },
|
||||
{ LSTRKEY( "PHYMODE_N" ), LNUMVAL( PHY_MODE_N ) },
|
||||
|
||||
{ LSTRKEY( "NONE_SLEEP" ), LNUMVAL( NONE_SLEEP_T ) },
|
||||
{ LSTRKEY( "LIGHT_SLEEP" ), LNUMVAL( LIGHT_SLEEP_T ) },
|
||||
{ LSTRKEY( "MODEM_SLEEP" ), LNUMVAL( MODEM_SLEEP_T ) },
|
||||
|
@ -1,392 +1,407 @@
|
||||
#ifndef __ESPCONN_H__
|
||||
#define __ESPCONN_H__
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
typedef sint8 err_t;
|
||||
|
||||
typedef void *espconn_handle;
|
||||
typedef void (* espconn_connect_callback)(void *arg);
|
||||
typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
|
||||
|
||||
/* Definitions for error constants. */
|
||||
|
||||
#define ESPCONN_OK 0 /* No error, everything OK. */
|
||||
#define ESPCONN_MEM -1 /* Out of memory error. */
|
||||
#define ESPCONN_TIMEOUT -3 /* Timeout. */
|
||||
#define ESPCONN_RTE -4 /* Routing problem. */
|
||||
#define ESPCONN_INPROGRESS -5 /* Operation in progress */
|
||||
|
||||
#define ESPCONN_ABRT -8 /* Connection aborted. */
|
||||
#define ESPCONN_RST -9 /* Connection reset. */
|
||||
#define ESPCONN_CLSD -10 /* Connection closed. */
|
||||
#define ESPCONN_CONN -11 /* Not connected. */
|
||||
|
||||
#define ESPCONN_ARG -12 /* Illegal argument. */
|
||||
#define ESPCONN_ISCONN -15 /* Already connected. */
|
||||
|
||||
/** Protocol family and type of the espconn */
|
||||
enum espconn_type {
|
||||
ESPCONN_INVALID = 0,
|
||||
/* ESPCONN_TCP Group */
|
||||
ESPCONN_TCP = 0x10,
|
||||
/* ESPCONN_UDP Group */
|
||||
ESPCONN_UDP = 0x20,
|
||||
};
|
||||
|
||||
/** Current state of the espconn. Non-TCP espconn are always in state ESPCONN_NONE! */
|
||||
enum espconn_state {
|
||||
ESPCONN_NONE,
|
||||
ESPCONN_WAIT,
|
||||
ESPCONN_LISTEN,
|
||||
ESPCONN_CONNECT,
|
||||
ESPCONN_WRITE,
|
||||
ESPCONN_READ,
|
||||
ESPCONN_CLOSE
|
||||
};
|
||||
|
||||
typedef struct _esp_tcp {
|
||||
int remote_port;
|
||||
int local_port;
|
||||
uint8 local_ip[4];
|
||||
uint8 remote_ip[4];
|
||||
espconn_connect_callback connect_callback;
|
||||
espconn_reconnect_callback reconnect_callback;
|
||||
espconn_connect_callback disconnect_callback;
|
||||
} esp_tcp;
|
||||
|
||||
typedef struct _esp_udp {
|
||||
int remote_port;
|
||||
int local_port;
|
||||
uint8 local_ip[4];
|
||||
uint8 remote_ip[4];
|
||||
} esp_udp;
|
||||
|
||||
typedef struct _remot_info{
|
||||
enum espconn_state state;
|
||||
int remote_port;
|
||||
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);
|
||||
typedef void (* espconn_sent_callback)(void *arg);
|
||||
|
||||
/** A espconn descriptor */
|
||||
struct espconn {
|
||||
/** type of the espconn (TCP, UDP) */
|
||||
enum espconn_type type;
|
||||
/** current state of the espconn */
|
||||
enum espconn_state state;
|
||||
union {
|
||||
esp_tcp *tcp;
|
||||
esp_udp *udp;
|
||||
} proto;
|
||||
/** A callback function that is informed about events for this espconn */
|
||||
espconn_recv_callback recv_callback;
|
||||
espconn_sent_callback sent_callback;
|
||||
uint8 link_cnt;
|
||||
void *reverse;
|
||||
};
|
||||
|
||||
enum espconn_option{
|
||||
ESPCONN_REUSEADDR = 1,
|
||||
ESPCONN_NODELAY,
|
||||
ESPCONN_END
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_connect
|
||||
* Description : The function given as the connect
|
||||
* Parameters : espconn -- the espconn used to listen the connection
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_connect(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_disconnect
|
||||
* Description : disconnect with host
|
||||
* Parameters : espconn -- the espconn used to disconnect the connection
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_disconnect(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_delete
|
||||
* Description : disconnect with host
|
||||
* Parameters : espconn -- the espconn used to disconnect the connection
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_delete(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_accept
|
||||
* Description : The function given as the listen
|
||||
* Parameters : espconn -- the espconn used to listen the connection
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_accept(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_create
|
||||
* Description : sent data for client or server
|
||||
* Parameters : espconn -- espconn to the data transmission
|
||||
* Returns : result
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_create(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_tcp_get_max_con
|
||||
* Description : get the number of simulatenously active TCP connections
|
||||
* Parameters : none
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
uint8 espconn_tcp_get_max_con(void);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_tcp_set_max_con
|
||||
* Description : set the number of simulatenously active TCP connections
|
||||
* Parameters : num -- total number
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_tcp_set_max_con(uint8 num);
|
||||
|
||||
/******************************************************************************
|
||||
* 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
|
||||
* Returns : result
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_tcp_set_max_con_allow
|
||||
* Description : set the count of simulatenously active connections on the server
|
||||
* Parameters : espconn -- espconn to set the count
|
||||
* num -- support the connection number
|
||||
* Returns : result
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_time
|
||||
* 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
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_time(struct espconn *espconn, uint32 interval, uint8 type_flag);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_get_connection_info
|
||||
* 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
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_sentcb
|
||||
* Description : Used to specify the function that should be called when data
|
||||
* has been successfully delivered to the remote host.
|
||||
* Parameters : 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
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_sent
|
||||
* Description : sent data for client or server
|
||||
* Parameters : espconn -- espconn to set for client or server
|
||||
* psent -- data to send
|
||||
* length -- length of data to send
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_connectcb
|
||||
* Description : used to specify the function that should be called when
|
||||
* connects to host.
|
||||
* Parameters : espconn -- espconn to set the connect callback
|
||||
* connect_cb -- connected callback function to call when connected
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_connectcb(struct espconn *espconn, espconn_connect_callback connect_cb);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_recvcb
|
||||
* Description : used to specify the function that should be called when recv
|
||||
* data from host.
|
||||
* Parameters : espconn -- espconn to set the recv callback
|
||||
* recv_cb -- recv callback function to call when recv data
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_recvcb(struct espconn *espconn, espconn_recv_callback recv_cb);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_reconcb
|
||||
* Description : used to specify the function that should be called when connection
|
||||
* because of err disconnect.
|
||||
* Parameters : espconn -- espconn to set the err callback
|
||||
* recon_cb -- err callback function to call when err
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_reconcb(struct espconn *espconn, espconn_reconnect_callback recon_cb);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_disconcb
|
||||
* 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
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_disconcb(struct espconn *espconn, espconn_connect_callback discon_cb);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_port
|
||||
* Description : access port value for client so that we don't end up bouncing
|
||||
* all connections at the same time .
|
||||
* Parameters : none
|
||||
* Returns : access port value
|
||||
*******************************************************************************/
|
||||
|
||||
uint32 espconn_port(void);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_set_opt
|
||||
* Description : access port value for client so that we don't end up bouncing
|
||||
* all connections at the same time .
|
||||
* Parameters : none
|
||||
* Returns : access port value
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_set_opt(struct espconn *espconn, uint8 opt);
|
||||
|
||||
/******************************************************************************
|
||||
* TypedefName : dns_found_callback
|
||||
* Description : Callback which is invoked when a hostname is found.
|
||||
* Parameters : name -- pointer to the name that was looked up.
|
||||
* 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).
|
||||
* callback_arg -- a user-specified callback argument passed to
|
||||
* dns_gethostbyname
|
||||
*******************************************************************************/
|
||||
|
||||
typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_gethostbyname
|
||||
* Description : Resolve a hostname (string) into an IP address.
|
||||
* 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
|
||||
* it is already cached in the dns_table (only valid if ESPCONN_OK
|
||||
* is returned!)
|
||||
* found -- a callback function to be called on success, failure
|
||||
* 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
|
||||
* 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.
|
||||
* - ESPCONN_ARG: dns client not initialized or invalid hostname
|
||||
*******************************************************************************/
|
||||
|
||||
err_t espconn_gethostbyname(struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_encry_connect
|
||||
* Description : The function given as connection
|
||||
* Parameters : espconn -- the espconn used to connect with the host
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_secure_connect(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_encry_disconnect
|
||||
* Description : The function given as the disconnection
|
||||
* Parameters : espconn -- the espconn used to disconnect with the host
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_secure_disconnect(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_encry_sent
|
||||
* Description : sent data for client or server
|
||||
* Parameters : espconn -- espconn to set for client or server
|
||||
* psent -- data to send
|
||||
* length -- length of data to send
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_secure_sent(struct espconn *espconn, uint8 *psent, uint16 length);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_secure_accept
|
||||
* Description : The function given as the listen
|
||||
* Parameters : espconn -- the espconn used to listen the connection
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_secure_accept(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_igmp_join
|
||||
* Description : join a multicast group
|
||||
* Parameters : host_ip -- the ip address of udp server
|
||||
* multicast_ip -- multicast ip given by user
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_igmp_leave
|
||||
* Description : leave a multicast group
|
||||
* Parameters : host_ip -- the ip address of udp server
|
||||
* multicast_ip -- multicast ip given by user
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
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
|
||||
|
||||
#ifndef __ESPCONN_H__
|
||||
#define __ESPCONN_H__
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
typedef sint8 err_t;
|
||||
|
||||
typedef void *espconn_handle;
|
||||
typedef void (* espconn_connect_callback)(void *arg);
|
||||
typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
|
||||
|
||||
/* Definitions for error constants. */
|
||||
|
||||
#define ESPCONN_OK 0 /* No error, everything OK. */
|
||||
#define ESPCONN_MEM -1 /* Out of memory error. */
|
||||
#define ESPCONN_TIMEOUT -3 /* Timeout. */
|
||||
#define ESPCONN_RTE -4 /* Routing problem. */
|
||||
#define ESPCONN_INPROGRESS -5 /* Operation in progress */
|
||||
|
||||
#define ESPCONN_ABRT -8 /* Connection aborted. */
|
||||
#define ESPCONN_RST -9 /* Connection reset. */
|
||||
#define ESPCONN_CLSD -10 /* Connection closed. */
|
||||
#define ESPCONN_CONN -11 /* Not connected. */
|
||||
|
||||
#define ESPCONN_ARG -12 /* Illegal argument. */
|
||||
#define ESPCONN_ISCONN -15 /* Already connected. */
|
||||
|
||||
/** Protocol family and type of the espconn */
|
||||
enum espconn_type {
|
||||
ESPCONN_INVALID = 0,
|
||||
/* ESPCONN_TCP Group */
|
||||
ESPCONN_TCP = 0x10,
|
||||
/* ESPCONN_UDP Group */
|
||||
ESPCONN_UDP = 0x20,
|
||||
};
|
||||
|
||||
/** Current state of the espconn. Non-TCP espconn are always in state ESPCONN_NONE! */
|
||||
enum espconn_state {
|
||||
ESPCONN_NONE,
|
||||
ESPCONN_WAIT,
|
||||
ESPCONN_LISTEN,
|
||||
ESPCONN_CONNECT,
|
||||
ESPCONN_WRITE,
|
||||
ESPCONN_READ,
|
||||
ESPCONN_CLOSE
|
||||
};
|
||||
|
||||
typedef struct _esp_tcp {
|
||||
int remote_port;
|
||||
int local_port;
|
||||
uint8 local_ip[4];
|
||||
uint8 remote_ip[4];
|
||||
espconn_connect_callback connect_callback;
|
||||
espconn_reconnect_callback reconnect_callback;
|
||||
espconn_connect_callback disconnect_callback;
|
||||
espconn_connect_callback write_finish_fn;
|
||||
} esp_tcp;
|
||||
|
||||
typedef struct _esp_udp {
|
||||
int remote_port;
|
||||
int local_port;
|
||||
uint8 local_ip[4];
|
||||
uint8 remote_ip[4];
|
||||
} esp_udp;
|
||||
|
||||
typedef struct _remot_info{
|
||||
enum espconn_state state;
|
||||
int remote_port;
|
||||
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);
|
||||
typedef void (* espconn_sent_callback)(void *arg);
|
||||
|
||||
/** A espconn descriptor */
|
||||
struct espconn {
|
||||
/** type of the espconn (TCP, UDP) */
|
||||
enum espconn_type type;
|
||||
/** current state of the espconn */
|
||||
enum espconn_state state;
|
||||
union {
|
||||
esp_tcp *tcp;
|
||||
esp_udp *udp;
|
||||
} proto;
|
||||
/** A callback function that is informed about events for this espconn */
|
||||
espconn_recv_callback recv_callback;
|
||||
espconn_sent_callback sent_callback;
|
||||
uint8 link_cnt;
|
||||
void *reverse;
|
||||
};
|
||||
|
||||
enum espconn_option{
|
||||
ESPCONN_START = 0x00,
|
||||
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
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_connect(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_disconnect
|
||||
* Description : disconnect with host
|
||||
* Parameters : espconn -- the espconn used to disconnect the connection
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_disconnect(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_delete
|
||||
* Description : disconnect with host
|
||||
* Parameters : espconn -- the espconn used to disconnect the connection
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_delete(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_accept
|
||||
* Description : The function given as the listen
|
||||
* Parameters : espconn -- the espconn used to listen the connection
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_accept(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_create
|
||||
* Description : sent data for client or server
|
||||
* Parameters : espconn -- espconn to the data transmission
|
||||
* Returns : result
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_create(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_tcp_get_max_con
|
||||
* Description : get the number of simulatenously active TCP connections
|
||||
* Parameters : none
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
uint8 espconn_tcp_get_max_con(void);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_tcp_set_max_con
|
||||
* Description : set the number of simulatenously active TCP connections
|
||||
* Parameters : num -- total number
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_tcp_set_max_con(uint8 num);
|
||||
|
||||
/******************************************************************************
|
||||
* 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
|
||||
* Returns : result
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_tcp_set_max_con_allow
|
||||
* Description : set the count of simulatenously active connections on the server
|
||||
* Parameters : espconn -- espconn to set the count
|
||||
* num -- support the connection number
|
||||
* Returns : result
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_time
|
||||
* 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
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_time(struct espconn *espconn, uint32 interval, uint8 type_flag);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_get_connection_info
|
||||
* 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
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_sentcb
|
||||
* Description : Used to specify the function that should be called when data
|
||||
* has been successfully delivered to the remote host.
|
||||
* Parameters : 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
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_sentcb
|
||||
* Description : Used to specify the function that should be called when data
|
||||
* has been successfully delivered to the remote host.
|
||||
* Parameters : espconn -- espconn to set the sent callback
|
||||
* sent_cb -- sent callback function to call for this espconn
|
||||
* when data is successfully sent
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_sent
|
||||
* Description : sent data for client or server
|
||||
* Parameters : espconn -- espconn to set for client or server
|
||||
* psent -- data to send
|
||||
* length -- length of data to send
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_connectcb
|
||||
* Description : used to specify the function that should be called when
|
||||
* connects to host.
|
||||
* Parameters : espconn -- espconn to set the connect callback
|
||||
* connect_cb -- connected callback function to call when connected
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_connectcb(struct espconn *espconn, espconn_connect_callback connect_cb);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_recvcb
|
||||
* Description : used to specify the function that should be called when recv
|
||||
* data from host.
|
||||
* Parameters : espconn -- espconn to set the recv callback
|
||||
* recv_cb -- recv callback function to call when recv data
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_recvcb(struct espconn *espconn, espconn_recv_callback recv_cb);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_reconcb
|
||||
* Description : used to specify the function that should be called when connection
|
||||
* because of err disconnect.
|
||||
* Parameters : espconn -- espconn to set the err callback
|
||||
* recon_cb -- err callback function to call when err
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_reconcb(struct espconn *espconn, espconn_reconnect_callback recon_cb);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_regist_disconcb
|
||||
* 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
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_regist_disconcb(struct espconn *espconn, espconn_connect_callback discon_cb);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_port
|
||||
* Description : access port value for client so that we don't end up bouncing
|
||||
* all connections at the same time .
|
||||
* Parameters : none
|
||||
* Returns : access port value
|
||||
*******************************************************************************/
|
||||
|
||||
uint32 espconn_port(void);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_set_opt
|
||||
* Description : access port value for client so that we don't end up bouncing
|
||||
* all connections at the same time .
|
||||
* Parameters : none
|
||||
* Returns : access port value
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_set_opt(struct espconn *espconn, uint8 opt);
|
||||
|
||||
/******************************************************************************
|
||||
* TypedefName : dns_found_callback
|
||||
* Description : Callback which is invoked when a hostname is found.
|
||||
* Parameters : name -- pointer to the name that was looked up.
|
||||
* 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).
|
||||
* callback_arg -- a user-specified callback argument passed to
|
||||
* dns_gethostbyname
|
||||
*******************************************************************************/
|
||||
|
||||
typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_gethostbyname
|
||||
* Description : Resolve a hostname (string) into an IP address.
|
||||
* 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
|
||||
* it is already cached in the dns_table (only valid if ESPCONN_OK
|
||||
* is returned!)
|
||||
* found -- a callback function to be called on success, failure
|
||||
* 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
|
||||
* 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.
|
||||
* - ESPCONN_ARG: dns client not initialized or invalid hostname
|
||||
*******************************************************************************/
|
||||
|
||||
err_t espconn_gethostbyname(struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_encry_connect
|
||||
* Description : The function given as connection
|
||||
* Parameters : espconn -- the espconn used to connect with the host
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_secure_connect(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_encry_disconnect
|
||||
* Description : The function given as the disconnection
|
||||
* Parameters : espconn -- the espconn used to disconnect with the host
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_secure_disconnect(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_encry_sent
|
||||
* Description : sent data for client or server
|
||||
* Parameters : espconn -- espconn to set for client or server
|
||||
* psent -- data to send
|
||||
* length -- length of data to send
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_secure_sent(struct espconn *espconn, uint8 *psent, uint16 length);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_secure_accept
|
||||
* Description : The function given as the listen
|
||||
* Parameters : espconn -- the espconn used to listen the connection
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
|
||||
sint8 espconn_secure_accept(struct espconn *espconn);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_igmp_join
|
||||
* Description : join a multicast group
|
||||
* Parameters : host_ip -- the ip address of udp server
|
||||
* multicast_ip -- multicast ip given by user
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : espconn_igmp_leave
|
||||
* Description : leave a multicast group
|
||||
* Parameters : host_ip -- the ip address of udp server
|
||||
* multicast_ip -- multicast ip given by user
|
||||
* Returns : none
|
||||
*******************************************************************************/
|
||||
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
|
||||
|
||||
|
@ -89,6 +89,7 @@ bool system_rtc_mem_write(uint8 des_addr, const void *src_addr, uint16 save_size
|
||||
void system_uart_swap(void);
|
||||
|
||||
uint16 system_adc_read(void);
|
||||
uint16 system_get_vdd33(void);
|
||||
|
||||
const char *system_get_sdk_version(void);
|
||||
|
||||
@ -97,6 +98,7 @@ const char *system_get_sdk_version(void);
|
||||
#define SOFTAP_MODE 0x02
|
||||
#define STATIONAP_MODE 0x03
|
||||
|
||||
|
||||
typedef enum _auth_mode {
|
||||
AUTH_OPEN = 0,
|
||||
AUTH_WEP,
|
||||
@ -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);
|
||||
|
||||
#define PHY_MODE_B 0x01
|
||||
#define PHY_MODE_G 0x02
|
||||
#define PHY_MODE_N 0x03
|
||||
|
||||
enum phy_mode {
|
||||
PHY_MODE_11B = 1,
|
||||
PHY_MODE_11G = 2,
|
||||
|
@ -71,7 +71,6 @@ SECTIONS
|
||||
_irom0_text_start = ABSOLUTE(.);
|
||||
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
|
||||
*(.literal.* .text.*)
|
||||
*(.rodata2.text)
|
||||
|
||||
/* put font and progmem data into irom0 */
|
||||
*(.u8g_progmem.*)
|
||||
|
BIN
lib/libat.a
BIN
lib/libat.a
Binary file not shown.
BIN
lib/libjson.a
BIN
lib/libjson.a
Binary file not shown.
BIN
lib/liblwip.a
BIN
lib/liblwip.a
Binary file not shown.
BIN
lib/libmain.a
BIN
lib/libmain.a
Binary file not shown.
Binary file not shown.
BIN
lib/libphy.a
BIN
lib/libphy.a
Binary file not shown.
BIN
lib/libpp.a
BIN
lib/libpp.a
Binary file not shown.
Binary file not shown.
BIN
lib/libssl.a
BIN
lib/libssl.a
Binary file not shown.
BIN
lib/libupgrade.a
BIN
lib/libupgrade.a
Binary file not shown.
BIN
lib/libwpa.a
BIN
lib/libwpa.a
Binary file not shown.
BIN
pre_build/0.9.6/nodemcu_20150216.bin
Normal file
BIN
pre_build/0.9.6/nodemcu_20150216.bin
Normal file
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user