Skip to content

Commit

Permalink
Added node.chipmodel().
Browse files Browse the repository at this point in the history
Updated and removed incorrect node module documentation.
  • Loading branch information
Jade Mattsson committed May 12, 2024
1 parent cfac448 commit 3e7b772
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 40 deletions.
8 changes: 8 additions & 0 deletions components/modules/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ static int node_chipid( lua_State *L )
}
#endif

// Lua: node.chipmodel()
static int node_chipmodel(lua_State *L)
{
lua_pushstring(L, CONFIG_IDF_TARGET);
return 1;
}

// Lua: node.heap()
static int node_heap( lua_State* L )
{
Expand Down Expand Up @@ -868,6 +875,7 @@ LROT_BEGIN(node, NULL, 0)
#if defined(CONFIG_IDF_TARGET_ESP32)
LROT_FUNCENTRY( chipid, node_chipid )
#endif
LROT_FUNCENTRY( chipmodel, node_chipmodel )
LROT_FUNCENTRY( compile, node_compile )
LROT_FUNCENTRY( dsleep, node_dsleep )
#if defined(CONFIG_LUA_VERSION_51)
Expand Down
54 changes: 14 additions & 40 deletions docs/modules/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if reset_reason == 0 then print("Power UP!") end

## node.chipid()

Returns the ESP chip ID.
Returns the ESP chip ID. Only available on the base ESP32 model.

#### Syntax
`node.chipid()`
Expand All @@ -85,6 +85,19 @@ chip ID (string)
Note that due to the chip id being a much larger value on the ESP32, it is
reported as a string now. E.g. `"0x1818fe346a88"`.

## node.chipmodel()

Returns the model of the ESP chip.

#### Syntax
`node.chipmodel()`

#### Parameters
none

#### Returns
The chip model as a string, e.g. "esp32c3". This is the string corresponding to the IDF's Kconfig parameter `IDF_TARGET`.

## node.compile()

Compiles a Lua text file into Lua bytecode, and saves it as .lc file.
Expand Down Expand Up @@ -153,20 +166,6 @@ node.dsleep({ gpio = 13, level = 0, pull = true })
- [`node.sleep()`](#nodesleep)


## node.flashid()

Returns the flash chip ID.

#### Syntax
`node.flashid()`

#### Parameters
none

#### Returns
flash ID (number)


## node.flashindex() --deprecated

Deprecated synonym for [`node.LFS.get()`](#nodelfsget) to return an LFS function reference.
Expand All @@ -191,31 +190,6 @@ none
#### Returns
system heap size left in bytes (number)

## node.info()

Returns NodeMCU version, chipid, flashid, flash size, flash mode, flash speed.

#### Syntax
`node.info()`

#### Parameters
none

#### Returns
- `majorVer` (number)
- `minorVer` (number)
- `devVer` (number)
- `chipid` (number)
- `flashid` (number)
- `flashsize` (number)
- `flashmode` (number)
- `flashspeed` (number)

#### Example
```lua
majorVer, minorVer, devVer, chipid, flashid, flashsize, flashmode, flashspeed = node.info()
print("NodeMCU "..majorVer.."."..minorVer.."."..devVer)
```

## node.input()

Expand Down

0 comments on commit 3e7b772

Please sign in to comment.