wifi_common.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 "c_string.h"
  7. #include "c_stdlib.h"
  8. #include "c_types.h"
  9. #include "user_interface.h"
  10. #include "user_config.h"
  11. #include "c_stdio.h"
  12. #include "task/task.h"
  13. //#define WIFI_DEBUG
  14. //#define EVENT_DEBUG
  15. void wifi_add_sprintf_field(lua_State* L, char* name, char* string, ...);
  16. void wifi_add_int_field(lua_State* L, char* name, lua_Integer integer);
  17. static inline void register_lua_cb(lua_State* L,int* cb_ref)
  18. {
  19. int ref=luaL_ref(L, LUA_REGISTRYINDEX);
  20. if( *cb_ref != LUA_NOREF)
  21. {
  22. luaL_unref(L, LUA_REGISTRYINDEX, *cb_ref);
  23. }
  24. *cb_ref = ref;
  25. }
  26. static inline void unregister_lua_cb(lua_State* L, int* cb_ref)
  27. {
  28. if(*cb_ref != LUA_NOREF)
  29. {
  30. luaL_unref(L, LUA_REGISTRYINDEX, *cb_ref);
  31. *cb_ref = LUA_NOREF;
  32. }
  33. }
  34. void wifi_change_default_host_name(void);
  35. #if defined(WIFI_DEBUG) || defined(NODE_DEBUG)
  36. #define WIFI_DBG(...) c_printf(__VA_ARGS__)
  37. #else
  38. #define WIFI_DBG(...) //c_printf(__VA_ARGS__)
  39. #endif
  40. #if defined(EVENT_DEBUG) || defined(NODE_DEBUG)
  41. #define EVENT_DBG(...) c_printf(__VA_ARGS__)
  42. #else
  43. #define EVENT_DBG(...) //c_printf(__VA_ARGS__)
  44. #endif
  45. enum wifi_suspension_state
  46. {
  47. WIFI_AWAKE = 0,
  48. WIFI_SUSPENSION_PENDING = 1,
  49. WIFI_SUSPENDED = 2
  50. };
  51. #ifdef WIFI_SDK_EVENT_MONITOR_ENABLE
  52. extern const LUA_REG_TYPE wifi_event_monitor_map[];
  53. void wifi_eventmon_init();
  54. #endif
  55. #ifdef WIFI_STATION_STATUS_MONITOR_ENABLE
  56. int wifi_station_event_mon_start(lua_State* L);
  57. int wifi_station_event_mon_reg(lua_State* L);
  58. void wifi_station_event_mon_stop(lua_State* L);
  59. #endif
  60. #endif /* APP_MODULES_WIFI_COMMON_H_ */