From 2fdaa9b171d8487a187abd7bdb65a4afbf8a2d42 Mon Sep 17 00:00:00 2001 From: dnc40085 Date: Fri, 27 May 2016 04:25:42 -0700 Subject: [PATCH] Moved call to set default wifi hostname (#1317) Moved call from `luaopen_wifi (wifi.c)` to `user_rf_pre_init (user_main.c)` Note: This change adds ~440 us to boot time --- app/modules/wifi.c | 3 +-- app/modules/wifi_common.h | 2 ++ app/user/user_main.c | 10 ++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/modules/wifi.c b/app/modules/wifi.c index ddf573dd..e8bd484a 100644 --- a/app/modules/wifi.c +++ b/app/modules/wifi.c @@ -1309,7 +1309,7 @@ static const LUA_REG_TYPE wifi_map[] = { { LNILKEY, LNILVAL } }; -static void wifi_change_default_host_name(task_param_t param, uint8 priority) +void wifi_change_default_host_name(void) { #ifndef WIFI_STA_HOSTNAME char temp[32]; @@ -1344,7 +1344,6 @@ static void wifi_change_default_host_name(task_param_t param, uint8 priority) int luaopen_wifi( lua_State *L ) { - task_post_low(task_get_id(wifi_change_default_host_name), FALSE); #if defined(WIFI_SDK_EVENT_MONITOR_ENABLE) wifi_eventmon_init(); #endif diff --git a/app/modules/wifi_common.h b/app/modules/wifi_common.h index 758115fe..633fd3a4 100644 --- a/app/modules/wifi_common.h +++ b/app/modules/wifi_common.h @@ -35,6 +35,8 @@ static inline void unregister_lua_cb(lua_State* L, int* cb_ref) } } +void wifi_change_default_host_name(void); + #ifdef NODE_DEBUG #define EVENT_DBG(...) c_printf(__VA_ARGS__) #else diff --git a/app/user/user_main.c b/app/user/user_main.c index aa6fdb93..be229825 100644 --- a/app/user/user_main.c +++ b/app/user/user_main.c @@ -117,6 +117,16 @@ void nodemcu_init(void) task_post_low(task_get_id(start_lua),'s'); } +#ifdef LUA_USE_MODULES_WIFI +#include "../modules/wifi_common.h" + +void user_rf_pre_init(void) +{ +//set WiFi hostname before RF initialization (adds ~440 us to boot time) + wifi_change_default_host_name(); +} +#endif + /****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here