Commit 4af68d83 authored by Mark Deneen's avatar Mark Deneen Committed by Marcel Stör
Browse files

WiFi method to adjust maximum TX power (#2171)

parent b2ce0e85
......@@ -298,6 +298,17 @@ static int wifi_getphymode( lua_State* L )
return 1;
}
// Lua: wifi.setmaxtxpower()
static int wifi_setmaxtxpower( lua_State* L )
{
unsigned power;
power = luaL_checkinteger( L, 1 );
luaL_argcheck(L, (power > 0 && power < 83), 1, "tx power out of range (0->82)");
system_phy_set_max_tpw( (uint8_t) power);
return 1;
}
#ifdef PMSLEEP_ENABLE
/* Begin WiFi suspend functions*/
#include "pmSleep.h"
......@@ -1796,6 +1807,7 @@ static const LUA_REG_TYPE wifi_map[] = {
{ LSTRKEY( "getchannel" ), LFUNCVAL( wifi_getchannel ) },
{ LSTRKEY( "setphymode" ), LFUNCVAL( wifi_setphymode ) },
{ LSTRKEY( "getphymode" ), LFUNCVAL( wifi_getphymode ) },
{ LSTRKEY( "setmaxtxpower" ), LFUNCVAL( wifi_setmaxtxpower ) },
#ifdef PMSLEEP_ENABLE
{ LSTRKEY( "suspend" ), LFUNCVAL( wifi_suspend ) },
{ LSTRKEY( "resume" ), LFUNCVAL( wifi_resume ) },
......
......@@ -211,6 +211,20 @@ physical mode after setup
#### See also
[`wifi.getphymode()`](#wifigetphymode)
## wifi.setmaxtxpower()
Sets WiFi maximum tx power. This setting is not persisted across power cycles, and the documentation does not specify if the setting persists after deep sleep. The default value used is read from flash at boot time as part of the esp8266 init data, and its value is set by the Espressif SDK.
#### Syntax
`wifi.setmaxtxpower(max_tpw)`
#### Parameters
`max_tpw` maximum value of RF Tx Power, unit: 0.25 dBm, range [0, 82].
#### Returns
`nil`
## wifi.startsmart()
Starts to auto configuration, if success set up SSID and password automatically.
......
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