diff --git a/README.md b/README.md index d4f88930..3e8b5998 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ Tencent QQ group: 309957875
- fix wifi smart connect - add spi module (done) - add mqtt module (done) -- add coap module -- cross compiler +- add coap module (in coap branch) +- cross compiler (done) # Change log 2015-02-13
diff --git a/app/include/user_config.h b/app/include/user_config.h index c6ec1e0e..74d1ff6e 100644 --- a/app/include/user_config.h +++ b/app/include/user_config.h @@ -7,7 +7,7 @@ #define NODE_VERSION_INTERNAL 0U #define NODE_VERSION "NodeMCU 0.9.5" -#define BUILD_DATE "build 20150213" +#define BUILD_DATE "build 20150214" // #define DEVKIT_VERSION_0_9 1 // define this only if you use NodeMCU devkit v0.9 diff --git a/app/lua/lauxlib.c b/app/lua/lauxlib.c index fedd7c56..00e740be 100644 --- a/app/lua/lauxlib.c +++ b/app/lua/lauxlib.c @@ -692,6 +692,8 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) { lf.f = fs_open(filename, FS_RDONLY); if (lf.f < FS_OPEN_OK) return errfsfile(L, "open", fnameindex); } + // if(fs_size(lf.f)>LUAL_BUFFERSIZE) + // return luaL_error(L, "file is too big"); c = fs_getc(lf.f); if (c == '#') { /* Unix exec. file? */ lf.extraline = 1; diff --git a/app/lua/luaconf.h b/app/lua/luaconf.h index 3a57e1e7..1a1760c7 100644 --- a/app/lua/luaconf.h +++ b/app/lua/luaconf.h @@ -542,7 +542,7 @@ extern int readline4lua(const char *prompt, char *buffer, int length); /* @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. */ -#define LUAL_BUFFERSIZE (BUFSIZ*4) +#define LUAL_BUFFERSIZE ((BUFSIZ)*4) /* }================================================================== */ diff --git a/app/modules/net.c b/app/modules/net.c index 51639b54..5b9dba9d 100644 --- a/app/modules/net.c +++ b/app/modules/net.c @@ -1241,6 +1241,31 @@ static int net_socket_unhold( lua_State* L ) return 0; } +// Lua: ip,port = sk:getpeer() +static int net_socket_getpeer( lua_State* L ) +{ + lnet_userdata *nud; + const char *mt = "net.socket"; + nud = (lnet_userdata *)luaL_checkudata(L, 1, mt); + luaL_argcheck(L, nud, 1, "Server/Socket expected"); + + if(nud!=NULL && nud->pesp_conn!=NULL ){ + char temp[20] = {0}; + c_sprintf(temp, IPSTR, IP2STR( &(nud->pesp_conn->proto.tcp->remote_ip) ) ); + if ( nud->pesp_conn->proto.tcp->remote_port != 0 ) { + lua_pushstring( L, temp ); + lua_pushinteger( L, nud->pesp_conn->proto.tcp->remote_port ); + } else { + lua_pushnil( L ); + lua_pushnil( L ); + } + } else { + lua_pushnil( L ); + lua_pushnil( L ); + } + return 2; +} + // Lua: socket:dns( string, function(ip) ) static int net_socket_dns( lua_State* L ) { @@ -1302,6 +1327,7 @@ static const LUA_REG_TYPE net_socket_map[] = { LSTRKEY( "hold" ), LFUNCVAL ( net_socket_hold ) }, { LSTRKEY( "unhold" ), LFUNCVAL ( net_socket_unhold ) }, { LSTRKEY( "dns" ), LFUNCVAL ( net_socket_dns ) }, + { LSTRKEY( "getpeer" ), LFUNCVAL ( net_socket_getpeer ) }, // { LSTRKEY( "delete" ), LFUNCVAL ( net_socket_delete ) }, { LSTRKEY( "__gc" ), LFUNCVAL ( net_socket_delete ) }, #if LUA_OPTIMIZE_MEMORY > 0 diff --git a/app/platform/flash_fs.h b/app/platform/flash_fs.h index 3f7d4710..9d9da7c7 100644 --- a/app/platform/flash_fs.h +++ b/app/platform/flash_fs.h @@ -69,6 +69,7 @@ #define fs_format myspiffs_format #define fs_check myspiffs_check #define fs_rename myspiffs_rename +#define fs_size myspiffs_size #define FS_NAME_MAX_LENGTH SPIFFS_OBJ_NAME_LEN diff --git a/app/spiffs/spiffs.c b/app/spiffs/spiffs.c index 5434e68d..df749e09 100644 --- a/app/spiffs/spiffs.c +++ b/app/spiffs/spiffs.c @@ -165,6 +165,9 @@ void myspiffs_clearerr( int fd ){ int myspiffs_rename( const char *old, const char *newname ){ return SPIFFS_rename(&fs, (char *)old, (char *)newname); } +size_t myspiffs_size( int fd ){ + return SPIFFS_size(&fs, (spiffs_file)fd); +} #if 0 void test_spiffs() { char buf[12]; diff --git a/app/spiffs/spiffs.h b/app/spiffs/spiffs.h index ca5200fd..23228446 100644 --- a/app/spiffs/spiffs.h +++ b/app/spiffs/spiffs.h @@ -423,6 +423,7 @@ s32_t SPIFFS_check(spiffs *fs); */ s32_t SPIFFS_eof(spiffs *fs, spiffs_file fh); s32_t SPIFFS_tell(spiffs *fs, spiffs_file fh); +s32_t SPIFFS_size(spiffs *fs, spiffs_file fh); #if SPIFFS_TEST_VISUALISATION /** @@ -465,5 +466,6 @@ int myspiffs_error( int fd ); void myspiffs_clearerr( int fd ); int myspiffs_check( void ); int myspiffs_rename( const char *old, const char *newname ); +size_t myspiffs_size( int fd ); #endif /* SPIFFS_H_ */ diff --git a/app/spiffs/spiffs_hydrogen.c b/app/spiffs/spiffs_hydrogen.c index 50777b73..20e45ecf 100644 --- a/app/spiffs/spiffs_hydrogen.c +++ b/app/spiffs/spiffs_hydrogen.c @@ -798,6 +798,25 @@ s32_t SPIFFS_tell(spiffs *fs, spiffs_file fh) { return res; } +s32_t SPIFFS_size(spiffs *fs, spiffs_file fh) { + SPIFFS_API_CHECK_MOUNT(fs); + SPIFFS_LOCK(fs); + + spiffs_fd *fd; + s32_t res; + res = spiffs_fd_get(fs, fh, &fd); + SPIFFS_API_CHECK_RES(fs, res); + +#if SPIFFS_CACHE_WR + spiffs_fflush_cache(fs, fh); +#endif + + res = fd->size; + + SPIFFS_UNLOCK(fs); + return res; +} + #if SPIFFS_TEST_VISUALISATION s32_t SPIFFS_vis(spiffs *fs) { s32_t res = SPIFFS_OK; diff --git a/pre_build/0.9.5/nodemcu_20150213.bin b/pre_build/0.9.5/nodemcu_20150213.bin new file mode 100644 index 00000000..cb4fa0b1 Binary files /dev/null and b/pre_build/0.9.5/nodemcu_20150213.bin differ diff --git a/pre_build/latest/nodemcu_latest.bin b/pre_build/latest/nodemcu_latest.bin index cb4fa0b1..acc14e99 100644 Binary files a/pre_build/latest/nodemcu_latest.bin and b/pre_build/latest/nodemcu_latest.bin differ