From 520eeb0ee460331fb69a796c780ef3189fbf4910 Mon Sep 17 00:00:00 2001 From: dnc40085 Date: Tue, 6 Mar 2018 19:28:47 -0800 Subject: [PATCH] Shortened swtmr disabled message Added swtimer debug module option to user_modules.h. Added comments to user_config.h. --- app/include/user_config.h | 4 ++-- app/include/user_modules.h | 4 ++++ app/modules/node.c | 3 +-- app/modules/wifi.c | 15 +++++++++++++-- app/pm/swtimer.c | 5 ++++- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/include/user_config.h b/app/include/user_config.h index c779932006..fc11d6a6ee 100644 --- a/app/include/user_config.h +++ b/app/include/user_config.h @@ -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 diff --git a/app/include/user_modules.h b/app/include/user_modules.h index 1afdde13f4..0d4b9e918e 100644 --- a/app/include/user_modules.h +++ b/app/include/user_modules.h @@ -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__ */ diff --git a/app/modules/node.c b/app/modules/node.c index 3a0957af88..2ddcdfa8d7 100644 --- a/app/modules/node.c +++ b/app/modules/node.c @@ -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; diff --git a/app/modules/wifi.c b/app/modules/wifi.c index ba8050cbcb..8f5d9d90a5 100644 --- a/app/modules/wifi.c +++ b/app/modules/wifi.c @@ -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() @@ -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 ) }, diff --git a/app/pm/swtimer.c b/app/pm/swtimer.c index 4093d61d74..bedbf954eb 100644 --- a/app/pm/swtimer.c +++ b/app/pm/swtimer.c @@ -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 @@ -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