Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
8637661e
Commit
8637661e
authored
May 01, 2015
by
Vowstar
Browse files
Merge pull request #390 from dnc40085/dev096-phymode
Add setphymode and getphymode to wifi module
parents
d5731dd9
f4a9de48
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/modules/wifi.c
View file @
8637661e
...
@@ -149,6 +149,7 @@ static int wifi_setmode( lua_State* L )
...
@@ -149,6 +149,7 @@ static int wifi_setmode( lua_State* L )
}
}
// Lua: realmode = getmode()
// Lua: realmode = getmode()
static
int
wifi_getmode
(
lua_State
*
L
)
static
int
wifi_getmode
(
lua_State
*
L
)
{
{
unsigned
mode
;
unsigned
mode
;
...
@@ -157,6 +158,55 @@ static int wifi_getmode( lua_State* L )
...
@@ -157,6 +158,55 @@ static int wifi_getmode( lua_State* L )
return
1
;
return
1
;
}
}
/**
* wifi.setphymode()
* Description:
* Set wifi physical mode(802.11 b/g/n)
* Note: SoftAP only supports 802.11 b/g.
* Syntax:
* wifi.setphymode(mode)
* Parameters:
* mode:
* wifi.PHYMODE_B
* wifi.PHYMODE_G
* wifi.PHYMODE_N
* Returns:
* Current physical mode after setup
*/
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
;
}
/**
* wifi.getphymode()
* Description:
* Get wifi physical mode(802.11 b/g/n)
* Syntax:
* wifi.getphymode()
* Parameters:
* nil
* Returns:
* Current physical mode.
*
*/
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()
// Lua: mac = wifi.xx.getmac()
static
int
wifi_getmac
(
lua_State
*
L
,
uint8_t
mode
)
static
int
wifi_getmac
(
lua_State
*
L
,
uint8_t
mode
)
...
@@ -524,6 +574,8 @@ const LUA_REG_TYPE wifi_map[] =
...
@@ -524,6 +574,8 @@ const LUA_REG_TYPE wifi_map[] =
{
{
{
LSTRKEY
(
"setmode"
),
LFUNCVAL
(
wifi_setmode
)
},
{
LSTRKEY
(
"setmode"
),
LFUNCVAL
(
wifi_setmode
)
},
{
LSTRKEY
(
"getmode"
),
LFUNCVAL
(
wifi_getmode
)
},
{
LSTRKEY
(
"getmode"
),
LFUNCVAL
(
wifi_getmode
)
},
{
LSTRKEY
(
"setphymode"
),
LFUNCVAL
(
wifi_setphymode
)
},
{
LSTRKEY
(
"getphymode"
),
LFUNCVAL
(
wifi_getphymode
)
},
{
LSTRKEY
(
"startsmart"
),
LFUNCVAL
(
wifi_start_smart
)
},
{
LSTRKEY
(
"startsmart"
),
LFUNCVAL
(
wifi_start_smart
)
},
{
LSTRKEY
(
"stopsmart"
),
LFUNCVAL
(
wifi_exit_smart
)
},
{
LSTRKEY
(
"stopsmart"
),
LFUNCVAL
(
wifi_exit_smart
)
},
{
LSTRKEY
(
"sleeptype"
),
LFUNCVAL
(
wifi_sleeptype
)
},
{
LSTRKEY
(
"sleeptype"
),
LFUNCVAL
(
wifi_sleeptype
)
},
...
@@ -536,6 +588,10 @@ const LUA_REG_TYPE wifi_map[] =
...
@@ -536,6 +588,10 @@ const LUA_REG_TYPE wifi_map[] =
{
LSTRKEY
(
"SOFTAP"
),
LNUMVAL
(
SOFTAP_MODE
)
},
{
LSTRKEY
(
"SOFTAP"
),
LNUMVAL
(
SOFTAP_MODE
)
},
{
LSTRKEY
(
"STATIONAP"
),
LNUMVAL
(
STATIONAP_MODE
)
},
{
LSTRKEY
(
"STATIONAP"
),
LNUMVAL
(
STATIONAP_MODE
)
},
{
LSTRKEY
(
"PHYMODE_B"
),
LNUMVAL
(
PHY_MODE_B
)
},
{
LSTRKEY
(
"PHYMODE_G"
),
LNUMVAL
(
PHY_MODE_G
)
},
{
LSTRKEY
(
"PHYMODE_N"
),
LNUMVAL
(
PHY_MODE_N
)
},
{
LSTRKEY
(
"NONE_SLEEP"
),
LNUMVAL
(
NONE_SLEEP_T
)
},
{
LSTRKEY
(
"NONE_SLEEP"
),
LNUMVAL
(
NONE_SLEEP_T
)
},
{
LSTRKEY
(
"LIGHT_SLEEP"
),
LNUMVAL
(
LIGHT_SLEEP_T
)
},
{
LSTRKEY
(
"LIGHT_SLEEP"
),
LNUMVAL
(
LIGHT_SLEEP_T
)
},
{
LSTRKEY
(
"MODEM_SLEEP"
),
LNUMVAL
(
MODEM_SLEEP_T
)
},
{
LSTRKEY
(
"MODEM_SLEEP"
),
LNUMVAL
(
MODEM_SLEEP_T
)
},
...
...
include/user_interface.h
View file @
8637661e
...
@@ -98,6 +98,7 @@ const char *system_get_sdk_version(void);
...
@@ -98,6 +98,7 @@ const char *system_get_sdk_version(void);
#define SOFTAP_MODE 0x02
#define SOFTAP_MODE 0x02
#define STATIONAP_MODE 0x03
#define STATIONAP_MODE 0x03
typedef
enum
_auth_mode
{
typedef
enum
_auth_mode
{
AUTH_OPEN
=
0
,
AUTH_OPEN
=
0
,
AUTH_WEP
,
AUTH_WEP
,
...
@@ -241,6 +242,10 @@ typedef void (* wifi_promiscuous_cb_t)(uint8 *buf, uint16 len);
...
@@ -241,6 +242,10 @@ typedef void (* wifi_promiscuous_cb_t)(uint8 *buf, uint16 len);
void
wifi_set_promiscuous_rx_cb
(
wifi_promiscuous_cb_t
cb
);
void
wifi_set_promiscuous_rx_cb
(
wifi_promiscuous_cb_t
cb
);
#define PHY_MODE_B 0x01
#define PHY_MODE_G 0x02
#define PHY_MODE_N 0x03
enum
phy_mode
{
enum
phy_mode
{
PHY_MODE_11B
=
1
,
PHY_MODE_11B
=
1
,
PHY_MODE_11G
=
2
,
PHY_MODE_11G
=
2
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment