wifi_common.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef APP_MODULES_WIFI_COMMON_H_
  2. #define APP_MODULES_WIFI_COMMON_H_
  3. #include "module.h"
  4. #include "lauxlib.h"
  5. #include "platform.h"
  6. #include <string.h>
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include "user_interface.h"
  10. #include "user_config.h"
  11. #include "task/task.h"
  12. //#define WIFI_DEBUG
  13. //#define EVENT_DEBUG
  14. void wifi_add_sprintf_field(lua_State* L, char* name, char* string, ...);
  15. void wifi_add_int_field(lua_State* L, char* name, lua_Integer integer);
  16. static inline void register_lua_cb(lua_State* L,int* cb_ref){
  17. int ref=luaL_ref(L, LUA_REGISTRYINDEX);
  18. if( *cb_ref != LUA_NOREF){
  19. luaL_unref(L, LUA_REGISTRYINDEX, *cb_ref);
  20. }
  21. *cb_ref = ref;
  22. }
  23. static inline void unregister_lua_cb(lua_State* L, int* cb_ref){
  24. if(*cb_ref != LUA_NOREF){
  25. luaL_unref(L, LUA_REGISTRYINDEX, *cb_ref);
  26. *cb_ref = LUA_NOREF;
  27. }
  28. }
  29. void wifi_change_default_host_name(void);
  30. #if defined(WIFI_DEBUG) || defined(NODE_DEBUG)
  31. #define WIFI_DBG(...) printf(__VA_ARGS__)
  32. #else
  33. #define WIFI_DBG(...) //printf(__VA_ARGS__)
  34. #endif
  35. #if defined(EVENT_DEBUG) || defined(NODE_DEBUG)
  36. #define EVENT_DBG(fmt, ...) printf("\n EVENT_DBG(%s): "fmt"\n", __FUNCTION__, ##__VA_ARGS__)
  37. #else
  38. #define EVENT_DBG(...) //printf(__VA_ARGS__)
  39. #endif
  40. enum wifi_suspension_state{
  41. WIFI_AWAKE = 0,
  42. WIFI_SUSPENSION_PENDING = 1,
  43. WIFI_SUSPENDED = 2
  44. };
  45. #ifdef WIFI_SDK_EVENT_MONITOR_ENABLE
  46. extern LROT_TABLE(wifi_event_monitor);
  47. void wifi_eventmon_init();
  48. int wifi_event_monitor_register(lua_State* L);
  49. #endif
  50. #ifdef LUA_USE_MODULES_WIFI_MONITOR
  51. extern LROT_TABLE(wifi_monitor);
  52. int wifi_monitor_init(lua_State *L);
  53. #endif
  54. #endif /* APP_MODULES_WIFI_COMMON_H_ */