Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
3328c66f
Commit
3328c66f
authored
Aug 27, 2016
by
dnc40085
Committed by
Marcel Stör
Aug 27, 2016
Browse files
Add function `wifi.nullmodesleep()` (#1475)
Enable auto sleep in NULL_MODE by default.
parent
cd6862f7
Changes
3
Show whitespace changes
Inline
Side-by-side
app/modules/wifi.c
View file @
3328c66f
...
@@ -372,6 +372,26 @@ static int wifi_sleep(lua_State* L)
...
@@ -372,6 +372,26 @@ static int wifi_sleep(lua_State* L)
return
2
;
return
2
;
}
}
//wifi.nullmodesleep()
static
int
wifi_null_mode_auto_sleep
(
lua_State
*
L
)
{
if
(
!
lua_isnone
(
L
,
1
))
{
bool
auto_sleep_setting
=
lua_toboolean
(
L
,
1
);
if
(
auto_sleep_setting
!=
(
bool
)
get_fpm_auto_sleep_flag
())
{
wifi_fpm_auto_sleep_set_in_null_mode
((
uint8
)
auto_sleep_setting
);
//if esp is already in NULL_MODE, auto sleep setting won't take effect until next wifi_set_opmode(NULL_MODE) call.
if
(
wifi_get_opmode
()
==
NULL_MODE
)
{
wifi_set_opmode_current
(
NULL_MODE
);
}
}
}
lua_pushboolean
(
L
,
(
bool
)
get_fpm_auto_sleep_flag
());
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
)
{
{
...
@@ -1268,6 +1288,7 @@ static const LUA_REG_TYPE wifi_map[] = {
...
@@ -1268,6 +1288,7 @@ static const LUA_REG_TYPE wifi_map[] = {
{
LSTRKEY
(
"setphymode"
),
LFUNCVAL
(
wifi_setphymode
)
},
{
LSTRKEY
(
"setphymode"
),
LFUNCVAL
(
wifi_setphymode
)
},
{
LSTRKEY
(
"getphymode"
),
LFUNCVAL
(
wifi_getphymode
)
},
{
LSTRKEY
(
"getphymode"
),
LFUNCVAL
(
wifi_getphymode
)
},
{
LSTRKEY
(
"sleep"
),
LFUNCVAL
(
wifi_sleep
)
},
{
LSTRKEY
(
"sleep"
),
LFUNCVAL
(
wifi_sleep
)
},
{
LSTRKEY
(
"nullmodesleep"
),
LFUNCVAL
(
wifi_null_mode_auto_sleep
)
},
#ifdef WIFI_SMART_ENABLE
#ifdef WIFI_SMART_ENABLE
{
LSTRKEY
(
"startsmart"
),
LFUNCVAL
(
wifi_start_smart
)
},
{
LSTRKEY
(
"startsmart"
),
LFUNCVAL
(
wifi_start_smart
)
},
{
LSTRKEY
(
"stopsmart"
),
LFUNCVAL
(
wifi_exit_smart
)
},
{
LSTRKEY
(
"stopsmart"
),
LFUNCVAL
(
wifi_exit_smart
)
},
...
@@ -1349,6 +1370,12 @@ void wifi_change_default_host_name(void)
...
@@ -1349,6 +1370,12 @@ void wifi_change_default_host_name(void)
int
luaopen_wifi
(
lua_State
*
L
)
int
luaopen_wifi
(
lua_State
*
L
)
{
{
wifi_fpm_auto_sleep_set_in_null_mode
(
1
);
//if esp is already in NULL_MODE, auto sleep setting won't take effect until next wifi_set_opmode(NULL_MODE) call.
if
(
wifi_get_opmode
()
==
NULL_MODE
)
{
wifi_set_opmode_current
(
NULL_MODE
);
}
#if defined(WIFI_SDK_EVENT_MONITOR_ENABLE)
#if defined(WIFI_SDK_EVENT_MONITOR_ENABLE)
wifi_eventmon_init
();
wifi_eventmon_init
();
#endif
#endif
...
...
docs/en/modules/wifi.md
View file @
3328c66f
...
@@ -128,6 +128,21 @@ physical mode after setup
...
@@ -128,6 +128,21 @@ physical mode after setup
#### See also
#### See also
[
`wifi.getphymode()`
](
#wifigetphymode
)
[
`wifi.getphymode()`
](
#wifigetphymode
)
## wifi.nullmodesleep()
Configures whether or not WiFi automatically goes to sleep in NULL_MODE. Enabled by default.
#### Syntax
`wifi.nullmodesleep(enable)`
#### Parameters
-
`enable`
-
true: Enable WiFi auto sleep in NULL_MODE. (Default setting)
-
false: Disable WiFi auto sleep in NULL_MODE.
#### Returns
Current/new NULL_MODE sleep setting.
## wifi.sleeptype()
## wifi.sleeptype()
Configures the WiFi modem sleep type.
Configures the WiFi modem sleep type.
...
...
sdk-overrides/include/user_interface.h
View file @
3328c66f
...
@@ -4,5 +4,7 @@
...
@@ -4,5 +4,7 @@
#include_next "user_interface.h"
#include_next "user_interface.h"
bool
wifi_softap_deauth
(
uint8
mac
[
6
]);
bool
wifi_softap_deauth
(
uint8
mac
[
6
]);
uint8
get_fpm_auto_sleep_flag
(
void
);
#endif
/* SDK_OVERRIDES_INCLUDE_USER_INTERFACE_H_ */
#endif
/* SDK_OVERRIDES_INCLUDE_USER_INTERFACE_H_ */
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