Skip to content

Commit

Permalink
Shortened swtmr disabled message
Browse files Browse the repository at this point in the history
Added swtimer debug module option to user_modules.h.
Added comments to user_config.h.
  • Loading branch information
dnc40085 committed Mar 7, 2018
1 parent 43b7d88 commit 520eeb0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/include/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ extern void luaL_assertfail(const char *file, int line, const char *message);
#define WIFI_SDK_EVENT_MONITOR_ENABLE
#define WIFI_EVENT_MONITOR_DISCONNECT_REASON_LIST_ENABLE

//#define TIMER_SUSPEND_ENABLE
//#define PMSLEEP_ENABLE
//#define PMSLEEP_ENABLE // Enable wifi.suspend() and node.sleep() (NOTE: node.sleep() is dependent on TIMER_SUSPEND_ENABLE)
//#define TIMER_SUSPEND_ENABLE //Required by node.sleep()


#define STRBUF_DEFAULT_INCREMENT 32
Expand Down
4 changes: 4 additions & 0 deletions app/include/user_modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,9 @@
//#define LUA_USE_MODULES_WS2812_EFFECTS
//#define LUA_USE_MODULES_XPT2046

//debug modules
//#define LUA_USE_MODULES_SWTMR_DBG //SWTMR timer suspend Debug functions


#endif /* LUA_CROSS_COMPILER */
#endif /* __USER_MODULES_H__ */
3 changes: 1 addition & 2 deletions app/modules/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ static int node_sleep( lua_State* L )
cfg.resume_cb_ptr = &node_sleep_resume_cb;
pmSleep_suspend(&cfg);
#else
c_printf("\nERROR! Light sleep functionality is unavailable in this firmware build!\n"
"To enable light sleep functionality,\nPlease uncomment \"timer_suspend_enable\" in \"app/include/user_config.h\" and rebuild the NodeMCU firmware.\n\n");
c_printf("\n The option \"timer_suspend_enable\" in \"app/include/user_config.h\" was disabled during FW build!\n");
return luaL_error(L, "light sleep is unavailable");
#endif
return 0;
Expand Down
15 changes: 13 additions & 2 deletions app/modules/wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,19 @@ static int wifi_resume(lua_State* L)
}

/* End WiFi suspend functions*/
#else
static char *susp_note_str = "\n The option \"pmsleep_enable\" in \"app/include/user_config.h\" was disabled during FW build!\n";
static char *susp_unavailable_str = "wifi.suspend is unavailable";

static int wifi_suspend(lua_State* L){
c_sprintf("%s", susp_note_str);
return luaL_error(L, susp_unavailable_str);
}

static int wifi_resume(lua_State* L){
c_sprintf("%s", susp_note_str);
return luaL_error(L, susp_unavailable_str);
}
#endif

// Lua: wifi.nullmodesleep()
Expand Down Expand Up @@ -1808,10 +1821,8 @@ static const LUA_REG_TYPE wifi_map[] = {
{ 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 ) },
#endif
{ LSTRKEY( "nullmodesleep" ), LFUNCVAL( wifi_null_mode_auto_sleep ) },
#ifdef WIFI_SMART_ENABLE
{ LSTRKEY( "startsmart" ), LFUNCVAL( wifi_start_smart ) },
Expand Down
5 changes: 4 additions & 1 deletion app/pm/swtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
#include "c_types.h"

//#define SWTMR_DEBUG
#if !defined(SWTMR_DBG) && defined(LUA_USE_MODULES_SWTMR_DBG)
#define SWTMR_DEBUG
#endif

//this section specifies which lua registry to use. LUA_GLOBALSINDEX or LUA_REGISTRYINDEX
#ifdef SWTMR_DEBUG
Expand Down Expand Up @@ -536,7 +539,7 @@ static const LUA_REG_TYPE test_swtimer_debug_map[] = {
{ LNILKEY, LNILVAL }
};

NODEMCU_MODULE(TIMER_SUSPEND_DEBUG, "timer_suspend_debug", test_swtimer_debug_map, NULL);
NODEMCU_MODULE(SWTMR_DBG, "SWTMR_DBG", test_swtimer_debug_map, NULL);

#endif

0 comments on commit 520eeb0

Please sign in to comment.