add node.info() to get version, chipid, flash info
This commit is contained in:
parent
2553795b1e
commit
04a5e67443
|
@ -1,6 +1,11 @@
|
|||
#ifndef __USER_CONFIG_H__
|
||||
#define __USER_CONFIG_H__
|
||||
|
||||
#define NODE_VERSION_MAJOR 0U
|
||||
#define NODE_VERSION_MINOR 9U
|
||||
#define NODE_VERSION_REVISION 4U
|
||||
#define NODE_VERSION_INTERNAL 0U
|
||||
|
||||
#define NODE_VERSION "NodeMcu 0.9.4"
|
||||
#define BUILD_DATE "build 20141230"
|
||||
// #define FLASH_512K
|
||||
|
|
|
@ -32,6 +32,20 @@ static int ICACHE_FLASH_ATTR node_deepsleep( lua_State* L )
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Lua: info()
|
||||
static int ICACHE_FLASH_ATTR node_info( lua_State* L )
|
||||
{
|
||||
lua_pushinteger(L, NODE_VERSION_MAJOR);
|
||||
lua_pushinteger(L, NODE_VERSION_MINOR);
|
||||
lua_pushinteger(L, NODE_VERSION_REVISION);
|
||||
lua_pushinteger(L, system_get_chip_id()); // chip id
|
||||
lua_pushinteger(L, spi_flash_get_id()); // flash id
|
||||
lua_pushinteger(L, flash_get_size_byte() / 1024); // flash size in KB
|
||||
lua_pushinteger(L, flash_get_mode());
|
||||
lua_pushinteger(L, flash_get_speed());
|
||||
return 8;
|
||||
}
|
||||
|
||||
// Lua: chipid()
|
||||
static int ICACHE_FLASH_ATTR node_chipid( lua_State* L )
|
||||
{
|
||||
|
@ -264,6 +278,7 @@ const LUA_REG_TYPE node_map[] =
|
|||
{
|
||||
{ LSTRKEY( "restart" ), LFUNCVAL( node_restart ) },
|
||||
{ LSTRKEY( "dsleep" ), LFUNCVAL( node_deepsleep ) },
|
||||
{ LSTRKEY( "info" ), LFUNCVAL( node_info ) },
|
||||
{ LSTRKEY( "chipid" ), LFUNCVAL( node_chipid ) },
|
||||
{ LSTRKEY( "flashid" ), LFUNCVAL( node_flashid ) },
|
||||
{ LSTRKEY( "flashsize" ), LFUNCVAL( node_flashsize) },
|
||||
|
|
Loading…
Reference in New Issue