From 900c43d520180a86eec1dbb2a2c39adb7c61afe0 Mon Sep 17 00:00:00 2001 From: dnc40085 Date: Sun, 26 Apr 2015 20:03:44 -0700 Subject: [PATCH] Add setphymode and getphymode to wifi module --- app/modules/wifi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/modules/wifi.c b/app/modules/wifi.c index 635625c6..5b30092a 100644 --- a/app/modules/wifi.c +++ b/app/modules/wifi.c @@ -157,6 +157,29 @@ static int wifi_getmode( lua_State* L ) return 1; } +// Lua: wifi.setphymode(mode) +static int wifi_setphymode( lua_State* L ) +{ + unsigned mode; + + mode = luaL_checkinteger( L, 1 ); + + if ( mode != PHY_MODE_11B && mode != PHY_MODE_11G && mode != PHY_MODE_11N ) + return luaL_error( L, "wrong arg type" ); + wifi_set_phy_mode( (uint8_t)mode); + mode = (unsigned)wifi_get_phy_mode(); + lua_pushinteger( L, mode ); + return 1; +} + +// Lua: wifi.getphymode() +static int wifi_getphymode( lua_State* L ) +{ + unsigned mode; + mode = (unsigned)wifi_get_phy_mode(); + lua_pushinteger( L, mode ); + return 1; +} // Lua: mac = wifi.xx.getmac() static int wifi_getmac( lua_State* L, uint8_t mode ) @@ -524,6 +547,8 @@ const LUA_REG_TYPE wifi_map[] = { { LSTRKEY( "setmode" ), LFUNCVAL( wifi_setmode ) }, { LSTRKEY( "getmode" ), LFUNCVAL( wifi_getmode ) }, + { LSTRKEY( "setphymode" ), LFUNCVAL( wifi_setphymode ) }, + { LSTRKEY( "getphymode" ), LFUNCVAL( wifi_getphymode ) }, { LSTRKEY( "startsmart" ), LFUNCVAL( wifi_start_smart ) }, { LSTRKEY( "stopsmart" ), LFUNCVAL( wifi_exit_smart ) }, { LSTRKEY( "sleeptype" ), LFUNCVAL( wifi_sleeptype ) },