mirror of
https://github.com/nodemcu/nodemcu-firmware.git
synced 2025-01-30 21:12:55 +08:00
526d21dab4
The PR removed the bulk of non-newlib headers from the NodeMCU source base. app/libc has now been cut down to the bare minimum overrides to shadow the corresponding functions in the SDK's libc. The old c_xyz.h headerfiles have been nuked in favour of the standard <xyz.h> headers, with a few exceptions over in sdk-overrides. Again, shipping a libc.a without headers is a terrible thing to do. We're still living on a prayer that libc was configured the same was as a default-configured xtensa gcc toolchain assumes it is. That part I cannot do anything about, unfortunately, but it's no worse than it has been before. This enables our source files to compile successfully using the standard header files, and use the typical malloc()/calloc()/realloc()/free(), the strwhatever()s and memwhatever()s. These end up, through macro and linker magic, mapped to the appropriate SDK or ROM functions.
71 lines
1.6 KiB
C
71 lines
1.6 KiB
C
#ifndef APP_MODULES_WIFI_COMMON_H_
|
|
#define APP_MODULES_WIFI_COMMON_H_
|
|
|
|
#include "module.h"
|
|
#include "lauxlib.h"
|
|
#include "platform.h"
|
|
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include "user_interface.h"
|
|
#include "user_config.h"
|
|
#include "task/task.h"
|
|
|
|
//#define WIFI_DEBUG
|
|
//#define EVENT_DEBUG
|
|
|
|
void wifi_add_sprintf_field(lua_State* L, char* name, char* string, ...);
|
|
void wifi_add_int_field(lua_State* L, char* name, lua_Integer integer);
|
|
|
|
static inline void register_lua_cb(lua_State* L,int* cb_ref){
|
|
int ref=luaL_ref(L, LUA_REGISTRYINDEX);
|
|
if( *cb_ref != LUA_NOREF){
|
|
luaL_unref(L, LUA_REGISTRYINDEX, *cb_ref);
|
|
}
|
|
*cb_ref = ref;
|
|
}
|
|
|
|
static inline void unregister_lua_cb(lua_State* L, int* cb_ref){
|
|
if(*cb_ref != LUA_NOREF){
|
|
luaL_unref(L, LUA_REGISTRYINDEX, *cb_ref);
|
|
*cb_ref = LUA_NOREF;
|
|
}
|
|
}
|
|
|
|
void wifi_change_default_host_name(void);
|
|
|
|
#if defined(WIFI_DEBUG) || defined(NODE_DEBUG)
|
|
#define WIFI_DBG(...) printf(__VA_ARGS__)
|
|
#else
|
|
#define WIFI_DBG(...) //printf(__VA_ARGS__)
|
|
#endif
|
|
|
|
#if defined(EVENT_DEBUG) || defined(NODE_DEBUG)
|
|
#define EVENT_DBG(fmt, ...) printf("\n EVENT_DBG(%s): "fmt"\n", __FUNCTION__, ##__VA_ARGS__)
|
|
|
|
#else
|
|
#define EVENT_DBG(...) //printf(__VA_ARGS__)
|
|
#endif
|
|
|
|
enum wifi_suspension_state{
|
|
WIFI_AWAKE = 0,
|
|
WIFI_SUSPENSION_PENDING = 1,
|
|
WIFI_SUSPENDED = 2
|
|
};
|
|
|
|
|
|
|
|
#ifdef WIFI_SDK_EVENT_MONITOR_ENABLE
|
|
LROT_EXTERN(wifi_event_monitor);
|
|
void wifi_eventmon_init();
|
|
int wifi_event_monitor_register(lua_State* L);
|
|
#endif
|
|
|
|
#ifdef LUA_USE_MODULES_WIFI_MONITOR
|
|
LROT_EXTERN(wifi_monitor);
|
|
int wifi_monitor_init(lua_State *L);
|
|
#endif
|
|
|
|
#endif /* APP_MODULES_WIFI_COMMON_H_ */
|