Skip to content

Commit

Permalink
node.chipid() returns "0x_unknown" for ESP32xx chips
Browse files Browse the repository at this point in the history
  • Loading branch information
serg3295 committed May 11, 2024
1 parent 6036c8a commit 0491963
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions components/modules/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ static int node_bootreason( lua_State *L)
return 2;
}

#if defined(CONFIG_IDF_TARGET_ESP32)
// Lua: node.chipid()
static int node_chipid( lua_State *L )
{
#if defined(CONFIG_IDF_TARGET_ESP32)
// This matches the way esptool.py generates a chipid for the ESP32 as of
// esptool commit e9e9179f6fc3f2ecfc568987d3224b5e53a05f06
// Oddly, this drops the lowest byte what's effectively the MAC address, so
Expand All @@ -169,10 +169,12 @@ static int node_chipid( lua_State *L )
uint64_t cid = ((word17 & MAX_UINT24) << 24) | ((word16 >> 8) & MAX_UINT24);
char chipid[17] = { 0 };
sprintf(chipid, "0x%llx", cid);
#else
const char *chipid = "0x_unknown";
#endif
lua_pushstring(L, chipid);
return 1;
}
#endif

// Lua: node.heap()
static int node_heap( lua_State* L )
Expand Down Expand Up @@ -865,9 +867,7 @@ LROT_END(node_wakeup, NULL, 0)

LROT_BEGIN(node, NULL, 0)
LROT_FUNCENTRY( bootreason, node_bootreason )
#if defined(CONFIG_IDF_TARGET_ESP32)
LROT_FUNCENTRY( chipid, node_chipid )
#endif
LROT_FUNCENTRY( compile, node_compile )
LROT_FUNCENTRY( dsleep, node_dsleep )
#if defined(CONFIG_LUA_VERSION_51)
Expand Down

0 comments on commit 0491963

Please sign in to comment.