소스 검색

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
dnc40085 8 년 전
부모
커밋
2fdaa9b171
3개의 변경된 파일13개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 2
      app/modules/wifi.c
  2. 2 0
      app/modules/wifi_common.h
  3. 10 0
      app/user/user_main.c

+ 1 - 2
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

+ 2 - 0
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

+ 10 - 0
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