Commit 7d20dd74 authored by devsaurus's avatar devsaurus
Browse files

Merge remote-tracking branch 'upstream/dev' into dev

parents 388a0b4e dce0d2c2
...@@ -35,6 +35,15 @@ Tencent QQ group: 309957875<br /> ...@@ -35,6 +35,15 @@ Tencent QQ group: 309957875<br />
- add coap module (done) - add coap module (done)
- cross compiler (done) - cross compiler (done)
# Change log
2015-06-27<br />
fixed ap/station-ap cannot connect to the device.<br />
added wifi.ap.getconfig().<br />
fixed net.dns.getdnsserver().<br />
added new base64 lua example.<br />
added node.bootreason() to inspect boot cause.<br />
optimization of u8g.<br />
# Change log # Change log
2015-06-25<br /> 2015-06-25<br />
move constants to ROM. Frees up 16k+ of RAM.<br /> move constants to ROM. Frees up 16k+ of RAM.<br />
......
...@@ -39,6 +39,9 @@ extern unsigned char * base64_decode(const unsigned char *src, size_t len, size_ ...@@ -39,6 +39,9 @@ extern unsigned char * base64_decode(const unsigned char *src, size_t len, size_
extern void mem_init(void * start_addr); extern void mem_init(void * start_addr);
// 2, 3 = reset (module dependent?), 4 = wdt
int rtc_get_reset_reason (void);
// Hardware exception handling // Hardware exception handling
struct exception_frame struct exception_frame
{ {
......
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
#define NODE_VERSION_INTERNAL 0U #define NODE_VERSION_INTERNAL 0U
#define NODE_VERSION "NodeMCU 0.9.6" #define NODE_VERSION "NodeMCU 0.9.6"
#define BUILD_DATE "build 20150625" #define BUILD_DATE "build 20150627"
#endif /* __USER_VERSION_H__ */ #endif /* __USER_VERSION_H__ */
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "user_interface.h" #include "user_interface.h"
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
static const uint8_t xid[4] = {0xad, 0xde, 0x12, 0x23}; static uint8_t xid[4] = {0xad, 0xde, 0x12, 0x23};
static u8_t old_xid[4] = {0}; static u8_t old_xid[4] = {0};
static const uint8_t magic_cookie[4] = {99, 130, 83, 99}; static const uint8_t magic_cookie[4] = {99, 130, 83, 99};
static struct udp_pcb *pcb_dhcps = NULL; static struct udp_pcb *pcb_dhcps = NULL;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "c_types.h" #include "c_types.h"
#include "mem.h" #include "mem.h"
#include "espconn.h" #include "espconn.h"
#include "lwip/dns.h"
#ifdef CLIENT_SSL_ENABLE #ifdef CLIENT_SSL_ENABLE
unsigned char *default_certificate; unsigned char *default_certificate;
...@@ -1447,14 +1448,16 @@ static int net_getdnsserver( lua_State* L ) ...@@ -1447,14 +1448,16 @@ static int net_getdnsserver( lua_State* L )
if (numdns >= DNS_MAX_SERVERS) if (numdns >= DNS_MAX_SERVERS)
return luaL_error( L, "server index out of range [0-%d]", DNS_MAX_SERVERS - 1); return luaL_error( L, "server index out of range [0-%d]", DNS_MAX_SERVERS - 1);
ip_addr_t ipaddr; // ip_addr_t ipaddr;
dns_getserver(numdns,&ipaddr); // dns_getserver(numdns,&ipaddr);
// Bug fix by @md5crypt https://github.com/nodemcu/nodemcu-firmware/pull/500
ip_addr_t ipaddr = dns_getserver(numdns);
if ( ip_addr_isany(&ipaddr) ) { if ( ip_addr_isany(&ipaddr) ) {
lua_pushnil( L ); lua_pushnil( L );
} else { } else {
char temp[20] = {0}; char temp[20] = {0};
c_sprintf(temp, IPSTR, IP2STR( &ipaddr ) ); c_sprintf(temp, IPSTR, IP2STR( &ipaddr.addr ) );
lua_pushstring( L, temp ); lua_pushstring( L, temp );
} }
......
...@@ -414,6 +414,13 @@ static int node_setcpufreq(lua_State* L) ...@@ -414,6 +414,13 @@ static int node_setcpufreq(lua_State* L)
return 1; return 1;
} }
// Lua: code = bootreason()
static int node_bootreason (lua_State *L)
{
lua_pushnumber (L, rtc_get_reset_reason ());
return 1;
}
// Module function map // Module function map
#define MIN_OPT_LEVEL 2 #define MIN_OPT_LEVEL 2
#include "lrodefs.h" #include "lrodefs.h"
...@@ -438,6 +445,7 @@ const LUA_REG_TYPE node_map[] = ...@@ -438,6 +445,7 @@ const LUA_REG_TYPE node_map[] =
{ LSTRKEY( "CPU80MHZ" ), LNUMVAL( CPU80MHZ ) }, { LSTRKEY( "CPU80MHZ" ), LNUMVAL( CPU80MHZ ) },
{ LSTRKEY( "CPU160MHZ" ), LNUMVAL( CPU160MHZ ) }, { LSTRKEY( "CPU160MHZ" ), LNUMVAL( CPU160MHZ ) },
{ LSTRKEY( "setcpufreq" ), LFUNCVAL( node_setcpufreq) }, { LSTRKEY( "setcpufreq" ), LFUNCVAL( node_setcpufreq) },
{ LSTRKEY( "bootreason" ), LFUNCVAL( node_bootreason) },
// Combined to dsleep(us, option) // Combined to dsleep(us, option)
// { LSTRKEY( "dsleepsetoption" ), LFUNCVAL( node_deepsleep_setoption) }, // { LSTRKEY( "dsleepsetoption" ), LFUNCVAL( node_deepsleep_setoption) },
#if LUA_OPTIMIZE_MEMORY > 0 #if LUA_OPTIMIZE_MEMORY > 0
......
...@@ -815,6 +815,19 @@ static int wifi_ap_getbroadcast( lua_State* L ){ ...@@ -815,6 +815,19 @@ static int wifi_ap_getbroadcast( lua_State* L ){
return wifi_getbroadcast(L, SOFTAP_IF); return wifi_getbroadcast(L, SOFTAP_IF);
} }
// Lua: wifi.ap.getconfig()
static int wifi_ap_getconfig( lua_State* L )
{
struct softap_config config;
wifi_softap_get_config(&config);
lua_pushstring( L, config.ssid );
if(config.authmode = AUTH_OPEN)
lua_pushnil(L);
else
lua_pushstring( L, config.password );
return 2;
}
// Lua: wifi.ap.config(table) // Lua: wifi.ap.config(table)
static int wifi_ap_config( lua_State* L ) static int wifi_ap_config( lua_State* L )
{ {
...@@ -1030,6 +1043,7 @@ static const LUA_REG_TYPE wifi_station_map[] = ...@@ -1030,6 +1043,7 @@ static const LUA_REG_TYPE wifi_station_map[] =
{ LSTRKEY( "connect" ), LFUNCVAL ( wifi_station_connect4lua ) }, { LSTRKEY( "connect" ), LFUNCVAL ( wifi_station_connect4lua ) },
{ LSTRKEY( "disconnect" ), LFUNCVAL ( wifi_station_disconnect4lua ) }, { LSTRKEY( "disconnect" ), LFUNCVAL ( wifi_station_disconnect4lua ) },
{ LSTRKEY( "autoconnect" ), LFUNCVAL ( wifi_station_setauto ) }, { LSTRKEY( "autoconnect" ), LFUNCVAL ( wifi_station_setauto ) },
{ LSTRKEY( "getconfig" ), LFUNCVAL( wifi_ap_getconfig ) },
{ LSTRKEY( "getip" ), LFUNCVAL ( wifi_station_getip ) }, { LSTRKEY( "getip" ), LFUNCVAL ( wifi_station_getip ) },
{ LSTRKEY( "setip" ), LFUNCVAL ( wifi_station_setip ) }, { LSTRKEY( "setip" ), LFUNCVAL ( wifi_station_setip ) },
{ LSTRKEY( "getbroadcast" ), LFUNCVAL ( wifi_station_getbroadcast) }, { LSTRKEY( "getbroadcast" ), LFUNCVAL ( wifi_station_getbroadcast) },
......
--this version actually works
local tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
base64 = {
enc = function(data)
local l,out = 0,''
local m = (3-data:len()%3)%3
local d = data..string.rep('\0',m)
for i=1,d:len() do
l = bit.lshift(l,8)
l = l+d:byte(i,i)
if i%3==0 then
for j=1,4 do
local a = bit.rshift(l,18)+1
out = out..tab:sub(a,a)
l = bit.band(bit.lshift(l,6),0xFFFFFF)
end
end
end
return out:sub(1,-1-m)..string.rep('=',m)
end,
dec = function(data)
local a,b = data:gsub('=','A')
local out = ''
local l = 0
for i=1,a:len() do
l=l+tab:find(a:sub(i,i))-1
if i%4==0 then
out=out..string.char(bit.rshift(l,16),bit.band(bit.rshift(l,8),255),bit.band(l,255))
l=0
end
l=bit.lshift(l,6)
end
return out:sub(1,-b-1)
end
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment