WiFi method to adjust maximum TX power (#2171)

This commit is contained in:
Mark Deneen 2017-11-19 14:00:20 -05:00 committed by Marcel Stör
parent b2ce0e8581
commit 4af68d8360
2 changed files with 26 additions and 0 deletions

View File

@ -298,6 +298,17 @@ static int wifi_getphymode( lua_State* L )
return 1; 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 #ifdef PMSLEEP_ENABLE
/* Begin WiFi suspend functions*/ /* Begin WiFi suspend functions*/
#include "pmSleep.h" #include "pmSleep.h"
@ -1796,6 +1807,7 @@ static const LUA_REG_TYPE wifi_map[] = {
{ LSTRKEY( "getchannel" ), LFUNCVAL( wifi_getchannel ) }, { LSTRKEY( "getchannel" ), LFUNCVAL( wifi_getchannel ) },
{ LSTRKEY( "setphymode" ), LFUNCVAL( wifi_setphymode ) }, { LSTRKEY( "setphymode" ), LFUNCVAL( wifi_setphymode ) },
{ LSTRKEY( "getphymode" ), LFUNCVAL( wifi_getphymode ) }, { LSTRKEY( "getphymode" ), LFUNCVAL( wifi_getphymode ) },
{ LSTRKEY( "setmaxtxpower" ), LFUNCVAL( wifi_setmaxtxpower ) },
#ifdef PMSLEEP_ENABLE #ifdef PMSLEEP_ENABLE
{ LSTRKEY( "suspend" ), LFUNCVAL( wifi_suspend ) }, { LSTRKEY( "suspend" ), LFUNCVAL( wifi_suspend ) },
{ LSTRKEY( "resume" ), LFUNCVAL( wifi_resume ) }, { LSTRKEY( "resume" ), LFUNCVAL( wifi_resume ) },

View File

@ -211,6 +211,20 @@ physical mode after setup
#### See also #### See also
[`wifi.getphymode()`](#wifigetphymode) [`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() ## wifi.startsmart()
Starts to auto configuration, if success set up SSID and password automatically. Starts to auto configuration, if success set up SSID and password automatically.