Commit 224788b6 authored by Johny Mattsson's avatar Johny Mattsson
Browse files

Make NodeMCU compile and link for ESP32.

A fair bit of reshuffling with include paths and overrides was necessary, as
the two RTOS SDKs (ESP8266 and ESP32) don't have the same header structure
(or even libraries for that matter). Uses the xtensa-esp108-elf toolchain
to build.

Completely untested beyond linking, as I still can't flash the ESP32 module
I have :(  I'd be most surprised if it does anything useful at this point
considering I've spent almost no time on the linker script or UART setup.

Anything using espconn has been ifdef'd out since espconn is not (and
probably will not be) available. Notably this includes the entire net module
as well as coap, mqtt and enduser_setup.

Many (most?) hardware bus drivers and related modules are also ifdef'd
out for now due to hardware differences. Functions surrounding sleep,
rtc and RF modes have also been hit by the ifdef hammer. Grep'ing for
__ESP8266__ and/or FIXME is a quick way of finding these places. With
time I hope all of these will be reinstated.
parent 0df2eda6
#ifndef SPI_APP_H
#define SPI_APP_H
#include "spi_register.h"
#ifdef __ESP8266__
# include "spi_register.h"
#endif
#include "eagle_soc.h"
#include "rom.h"
#include "osapi.h"
#include "uart.h"
......
......@@ -6,6 +6,26 @@
#include "c_types.h"
#include "ets_sys.h"
/* Change GPIO pin output by setting, clearing, or disabling pins.
* In general, it is expected that a bit will be set in at most one
* of these masks. If a bit is clear in all masks, the output state
* remains unchanged.
*
* There is no particular ordering guaranteed; so if the order of
* writes is significant, calling code should divide a single call
* into multiple calls.
*/
void gpio_output_set(uint32_t set_mask, uint32_t clear_mask, uint32_t enable_mask, uint32_t disable_mask);
/* Set the specified GPIO register to the specified value.
* This is a very general and powerful interface that is not
* expected to be used during normal operation. It is intended
* mainly for debug, or for unusual requirements.
*/
void gpio_register_set(uint32_t reg_id, uint32_t value);
// SHA1 is assumed to match the netbsd sha1.h headers
#define SHA1_DIGEST_LENGTH 20
#define SHA1_DIGEST_STRING_LENGTH 41
......@@ -125,6 +145,17 @@ int ets_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)))
void ets_str2macaddr (uint8_t *dst, const char *str);
typedef void (*ETSTimerFunc)(void *arg);
typedef struct ETSTimer
{
struct ETSTimer *timer_next;
void *timer_handle;
uint32_t timer_expire;
uint32_t timer_period;
ETSTimerFunc timer_func;
bool timer_repeat_flag;
void *timer_arg;
} ETSTimer;
void ets_timer_disarm (ETSTimer *a);
void ets_timer_setfn (ETSTimer *t, ETSTimerFunc *fn, void *parg);
......@@ -134,8 +165,6 @@ void Cache_Read_Disable(void);
void ets_intr_lock(void);
void ets_intr_unlock(void);
void ets_install_putc1(void *routine);
int rand(void);
void srand(unsigned int);
......
......@@ -343,7 +343,7 @@ static inline uint32_t rtc_time_get_calibration(void)
if (!cal)
{
// Make a first guess, most likely to be rather bad, but better then nothing.
#ifndef BOOTLOADER_CODE // This will pull in way too much of the system for the bootloader to handle.
#if !defined(BOOTLOADER_CODE) && defined(__ESP8266__) // This will pull in way too much of the system for the bootloader to handle.
ets_delay_us(200);
cal=system_rtc_clock_cali_proc();
rtc_mem_write(RTC_CALIBRATION_POS,cal);
......@@ -583,7 +583,7 @@ static inline void rtc_time_tmrfn(void* arg)
static inline void rtc_time_install_timer(void)
{
static ETSTimer tmr;
static os_timer_t tmr;
os_timer_setfn(&tmr,rtc_time_tmrfn,NULL);
os_timer_arm(&tmr,10000,1);
......
......@@ -47,7 +47,7 @@
//#define LUA_USE_MODULES_RTCMEM
//#define LUA_USE_MODULES_RTCTIME
//#define LUA_USE_MODULES_SIGMA_DELTA
//#define LUA_USE_MODULES_SNTP
#define LUA_USE_MODULES_SNTP
#define LUA_USE_MODULES_SPI
//#define LUA_USE_MODULES_STRUCT
#define LUA_USE_MODULES_TMR
......
......@@ -6,13 +6,19 @@
#include "c_types.h"
#include "user_interface.h"
#include <stdlib.h>
// Lua: read(id) , return system adc
static int adc_sample( lua_State* L )
{
unsigned id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( adc, id );
#if defined(__ESP8266__)
unsigned val = 0xFFFF & system_adc_read();
#elif defined(__ESP32__)
// TODO: support reading the 8 ADC channels via system_adc1_read()
unsigned val = 0;
#endif
lua_pushinteger( L, val );
return 1;
}
......
// Module for coapwork
// No espconn on ESP32
#ifdef __ESP8266__
#include "module.h"
#include "lauxlib.h"
#include "platform.h"
......@@ -607,3 +610,4 @@ int luaopen_coap( lua_State *L )
}
NODEMCU_MODULE(COAP, "coap", coap_map, luaopen_coap);
#endif
......@@ -5,6 +5,7 @@
#include "lauxlib.h"
#include "platform.h"
#include "c_types.h"
#include "esp_libc.h"
#include <stdlib.h>
#include "flash_fs.h"
#include "../crypto/digests.h"
......
......@@ -3,7 +3,6 @@
#include "module.h"
#include "lauxlib.h"
#include "platform.h"
#include "cpu_esp8266.h"
#include "dht.h"
#define NUM_DHT GPIO_PIN_NUM
......
......@@ -33,6 +33,9 @@
* Additions & fixes: Johny Mattsson <jmattsson@dius.com.au>
*/
// No espconn on ESP32
#ifdef __ESP8266__
#include "module.h"
#include "lauxlib.h"
#include "lwip/tcp.h"
......@@ -1528,3 +1531,4 @@ static const LUA_REG_TYPE enduser_setup_map[] = {
};
NODEMCU_MODULE(ENDUSER_SETUP, "enduser_setup", enduser_setup_map, NULL);
#endif
......@@ -22,10 +22,15 @@
#ifdef GPIO_INTERRUPT_ENABLE
#if defined(__ESP8266__)
// We also know that the non-level interrupt types are < LOLEVEL, and that
// HILEVEL is > LOLEVEL. Since this is burned into the hardware it is not
// going to change.
#define INTERRUPT_TYPE_IS_LEVEL(x) ((x) >= GPIO_PIN_INTR_LOLEVEL)
# define INTERRUPT_TYPE_IS_LEVEL(x) ((x) >= GPIO_PIN_INTR_LOLEVEL)
#elif defined(__ESP32__)
// There appears to be no level interrupt support on the ESP32?
# define INTERRUPT_TYPE_IS_LEVEL(x) 0
#endif
static int gpio_cb_ref[GPIO_PIN_NUM];
......@@ -65,10 +70,17 @@ static void gpio_intr_callback_task (task_param_t param, task_prio_t priority)
static int lgpio_trig( lua_State* L )
{
unsigned pin = luaL_checkinteger( L, 1 );
static const char * const opts[] = {"none", "up", "down", "both", "low", "high", NULL};
static const char * const opts[] = {"none", "up", "down", "both",
#ifdef __ESP8266__
"low", "high",
#endif
NULL};
static const int opts_type[] = {
GPIO_PIN_INTR_DISABLE, GPIO_PIN_INTR_POSEDGE, GPIO_PIN_INTR_NEGEDGE,
GPIO_PIN_INTR_ANYEDGE, GPIO_PIN_INTR_LOLEVEL, GPIO_PIN_INTR_HILEVEL
GPIO_PIN_INTR_ANYEDGE
#ifdef __ESP8266__
,GPIO_PIN_INTR_LOLEVEL, GPIO_PIN_INTR_HILEVEL
#endif
};
luaL_argcheck(L, platform_gpio_exists(pin) && pin>0, 1, "Invalid interrupt pin");
......
......@@ -6,7 +6,6 @@
#include "module.h"
#include "lauxlib.h"
#include "platform.h"
#include "cpu_esp8266.h"
#include "httpclient.h"
static int http_callback_registry = LUA_NOREF;
......
// No espconn on ESP32
#ifdef __ESP8266__
// Module for mqtt
#include "module.h"
......@@ -74,7 +77,7 @@ typedef struct lmqtt_userdata
uint8_t secure;
#endif
bool connected; // indicate socket connected, not mqtt prot connected.
ETSTimer mqttTimer;
os_timer_t mqttTimer;
tConnState connState;
}lmqtt_userdata;
......@@ -687,7 +690,7 @@ static int mqtt_socket_client( lua_State* L )
mud->event_timeout = 0;
mud->connState = MQTT_INIT;
mud->connected = false;
memset(&mud->mqttTimer, 0, sizeof(ETSTimer));
memset(&mud->mqttTimer, 0, sizeof(os_timer_t));
memset(&mud->mqtt_state, 0, sizeof(mqtt_state_t));
memset(&mud->connect_info, 0, sizeof(mqtt_connect_info_t));
......@@ -1615,3 +1618,4 @@ int luaopen_mqtt( lua_State *L )
}
NODEMCU_MODULE(MQTT, "mqtt", mqtt_map, luaopen_mqtt);
#endif
// Module for network
// No espconn on ESP32
#ifdef __ESP8266__
#include "module.h"
#include "lauxlib.h"
#include "platform.h"
......@@ -1788,3 +1791,4 @@ int luaopen_net( lua_State *L ) {
}
NODEMCU_MODULE(NET, "net", net_map, luaopen_net);
#endif
......@@ -47,6 +47,7 @@ static int node_restart( lua_State* L )
return 0;
}
#ifdef __ESP8266__
// Lua: dsleep( us, option )
static int node_deepsleep( lua_State* L )
{
......@@ -89,13 +90,33 @@ static int node_deepsleep( lua_State* L )
// }
// Lua: info()
#endif
static uint32_t system_chip_id (lua_State *L)
{
#if defined(__ESP8266__)
(void)L;
return system_get_chip_id ();
#elif defined(__ESP32__)
uint8_t id = 0;
if (!system_get_chip_id (&id))
return luaL_error (L, "failed to read chip id");
return id;
#endif
}
static int node_info( lua_State* L )
{
lua_pushinteger(L, NODE_VERSION_MAJOR);
lua_pushinteger(L, NODE_VERSION_MINOR);
lua_pushinteger(L, NODE_VERSION_REVISION);
lua_pushinteger(L, system_get_chip_id()); // chip id
lua_pushinteger(L, system_chip_id(L)); // chip id
#if defined(__ESP8266__)
lua_pushinteger(L, spi_flash_get_id()); // flash id
#elif defined(__ESP32__)
lua_pushinteger (L, 0); // flash id not readable on ESP32?
#endif
#if defined(FLASH_SAFE_API)
lua_pushinteger(L, flash_safe_get_size_byte() / 1024); // flash size in KB
#else
......@@ -109,8 +130,7 @@ static int node_info( lua_State* L )
// Lua: chipid()
static int node_chipid( lua_State* L )
{
uint32_t id = system_get_chip_id();
lua_pushinteger(L, id);
lua_pushinteger(L, system_chip_id (L));
return 1;
}
......@@ -123,6 +143,7 @@ static int node_chipid( lua_State* L )
// return 1;
// }
#ifdef __ESP8266__
// Lua: flashid()
static int node_flashid( lua_State* L )
{
......@@ -130,6 +151,7 @@ static int node_flashid( lua_State* L )
lua_pushinteger( L, id );
return 1;
}
#endif
// Lua: flashsize()
static int node_flashsize( lua_State* L )
......@@ -558,6 +580,7 @@ static int node_setcpufreq(lua_State* L)
return 1;
}
#ifdef __ESP8266__
// Lua: code, reason [, exccause, epc1, epc2, epc3, excvaddr, depc ] = bootreason()
static int node_bootreason (lua_State *L)
{
......@@ -572,6 +595,7 @@ static int node_bootreason (lua_State *L)
lua_pushinteger (L, arr[i]);
return n;
}
#endif
// Lua: restore()
static int node_restore (lua_State *L)
......@@ -692,10 +716,13 @@ static const LUA_REG_TYPE node_task_map[] = {
static const LUA_REG_TYPE node_map[] =
{
{ LSTRKEY( "restart" ), LFUNCVAL( node_restart ) },
#ifdef __ESP8266__
{ LSTRKEY( "dsleep" ), LFUNCVAL( node_deepsleep ) },
{ LSTRKEY( "flashid" ), LFUNCVAL( node_flashid ) },
{ LSTRKEY( "bootreason" ), LFUNCVAL( node_bootreason) },
#endif
{ LSTRKEY( "info" ), LFUNCVAL( node_info ) },
{ LSTRKEY( "chipid" ), LFUNCVAL( node_chipid ) },
{ LSTRKEY( "flashid" ), LFUNCVAL( node_flashid ) },
{ LSTRKEY( "flashsize" ), LFUNCVAL( node_flashsize) },
{ LSTRKEY( "heap" ), LFUNCVAL( node_heap ) },
#ifdef DEVKIT_VERSION_0_9
......@@ -710,13 +737,13 @@ static const LUA_REG_TYPE node_map[] =
{ LSTRKEY( "CPU80MHZ" ), LNUMVAL( CPU80MHZ ) },
{ LSTRKEY( "CPU160MHZ" ), LNUMVAL( CPU160MHZ ) },
{ LSTRKEY( "setcpufreq" ), LFUNCVAL( node_setcpufreq) },
{ LSTRKEY( "bootreason" ), LFUNCVAL( node_bootreason) },
{ LSTRKEY( "restore" ), LFUNCVAL( node_restore) },
#ifdef LUA_OPTIMIZE_DEBUG
{ LSTRKEY( "stripdebug" ), LFUNCVAL( node_stripdebug ) },
#endif
{ LSTRKEY( "egc" ), LROVAL( node_egc_map ) },
{ LSTRKEY( "task" ), LROVAL( node_task_map ) },
#define DEVELOPMENT_TOOLS
#ifdef DEVELOPMENT_TOOLS
{ LSTRKEY( "osprint" ), LFUNCVAL( node_osprint ) },
#endif
......
......@@ -15,7 +15,7 @@
#include "lauxlib.h"
#include "platform.h"
#include "hw_timer.h"
#include "cpu_esp8266.h"
#include "platform.h"
typedef struct {
int ref;
......@@ -31,9 +31,9 @@ typedef struct {
static DATA *data;
extern char _flash_used_end[];
#define TIMER_OWNER ((os_param_t) 'p')
#define TIMER_OWNER ((uint32_t) 'p')
static void ICACHE_RAM_ATTR hw_timer_cb(os_param_t p)
static void ICACHE_RAM_ATTR hw_timer_cb(uint32_t p)
{
(void) p;
uint32_t stackaddr;
......
......@@ -6,6 +6,8 @@
* Philip Gladstone, N1DQ
*/
#ifdef __ESP8266__
#include "module.h"
#include "lauxlib.h"
#include "platform.h"
......@@ -47,7 +49,7 @@ typedef struct {
int longpress_delay_us;
uint32_t last_event_time;
int callback[CALLBACK_COUNT];
ETSTimer timer;
os_timer_t timer;
} DATA;
static DATA *data[ROTARY_CHANNEL_COUNT];
......@@ -403,3 +405,4 @@ static const LUA_REG_TYPE rotary_map[] = {
};
NODEMCU_MODULE(ROTARY, "rotary", rotary_map, rotary_open);
#endif
......@@ -80,6 +80,7 @@ static int rtctime_get (lua_State *L)
return 2;
}
#ifdef __ESP8266__
static void do_sleep_opt (lua_State *L, int idx)
{
if (lua_isnumber (L, idx))
......@@ -113,14 +114,17 @@ static int rtctime_dsleep_aligned (lua_State *L)
rtctime_deep_sleep_until_aligned_us (align_us, min_us); // does not return
return 0;
}
#endif
// Module function map
static const LUA_REG_TYPE rtctime_map[] = {
{ LSTRKEY("set"), LFUNCVAL(rtctime_set) },
{ LSTRKEY("get"), LFUNCVAL(rtctime_get) },
#ifdef __ESP8266__
{ LSTRKEY("dsleep"), LFUNCVAL(rtctime_dsleep) },
{ LSTRKEY("dsleep_aligned"), LFUNCVAL(rtctime_dsleep_aligned) },
#endif
{ LNILKEY, LNILVAL }
};
......
// Module for interfacing with sigma-delta hardware
#ifdef __ESP8266__
#include "module.h"
#include "lauxlib.h"
#include "platform.h"
......@@ -85,3 +87,4 @@ static const LUA_REG_TYPE sigma_delta_map[] =
};
NODEMCU_MODULE(SIGMA_DELTA, "sigma_delta", sigma_delta_map, NULL);
#endif
......@@ -78,6 +78,7 @@ typedef struct{
}timer_struct_t;
typedef timer_struct_t* ptimer_t;
#ifdef __ESP8266__
// The previous implementation extended the rtc counter to 64 bits, and then
// applied rtc2sec with the current calibration value to that 64 bit value.
// This means that *ALL* clock ticks since bootup are counted with the *current*
......@@ -90,10 +91,12 @@ typedef timer_struct_t* ptimer_t;
static uint32_t rtc_time_cali=0;
static uint32_t last_rtc_time=0;
static uint64_t last_rtc_time_us=0;
static os_timer_t rtc_timer;
static sint32_t soft_watchdog = -1;
#endif
static timer_struct_t alarm_timers[NUM_TMR];
static os_timer_t rtc_timer;
static task_handle_t callback_task;
......@@ -161,14 +164,14 @@ static int tmr_register(lua_State* L){
sint32_t ref = luaL_ref(L, LUA_REGISTRYINDEX);
ptimer_t tmr = &alarm_timers[id];
if(!(tmr->mode & TIMER_IDLE_FLAG) && tmr->mode != TIMER_MODE_OFF)
ets_timer_disarm(&tmr->os);
os_timer_disarm(&tmr->os);
//there was a bug in this part, the second part of the following condition was missing
if(tmr->lua_ref != LUA_NOREF && tmr->lua_ref != ref)
luaL_unref(L, LUA_REGISTRYINDEX, tmr->lua_ref);
tmr->lua_ref = ref;
tmr->mode = mode|TIMER_IDLE_FLAG;
tmr->interval = interval;
ets_timer_setfn(&tmr->os, alarm_timer_common, (void*)id);
os_timer_setfn(&tmr->os, alarm_timer_common, (void*)id);
return 0;
}
......@@ -182,7 +185,7 @@ static int tmr_start(lua_State* L){
lua_pushboolean(L, 0);
}else{
tmr->mode &= ~TIMER_IDLE_FLAG;
ets_timer_arm_new(&tmr->os, tmr->interval, tmr->mode==TIMER_MODE_AUTO, 1);
os_timer_arm(&tmr->os, tmr->interval, tmr->mode==TIMER_MODE_AUTO);
lua_pushboolean(L, 1);
}
return 1;
......@@ -202,7 +205,7 @@ static int tmr_stop(lua_State* L){
//we return false if the timer is idle (of not registered)
if(!(tmr->mode & TIMER_IDLE_FLAG) && tmr->mode != TIMER_MODE_OFF){
tmr->mode |= TIMER_IDLE_FLAG;
ets_timer_disarm(&tmr->os);
os_timer_disarm(&tmr->os);
lua_pushboolean(L, 1);
}else{
lua_pushboolean(L, 0);
......@@ -216,7 +219,7 @@ static int tmr_unregister(lua_State* L){
MOD_CHECK_ID(tmr,id);
ptimer_t tmr = &alarm_timers[id];
if(!(tmr->mode & TIMER_IDLE_FLAG) && tmr->mode != TIMER_MODE_OFF)
ets_timer_disarm(&tmr->os);
os_timer_disarm(&tmr->os);
if(tmr->lua_ref != LUA_NOREF)
luaL_unref(L, LUA_REGISTRYINDEX, tmr->lua_ref);
tmr->lua_ref = LUA_NOREF;
......@@ -234,8 +237,8 @@ static int tmr_interval(lua_State* L){
if(tmr->mode != TIMER_MODE_OFF){
tmr->interval = interval;
if(!(tmr->mode&TIMER_IDLE_FLAG)){
ets_timer_disarm(&tmr->os);
ets_timer_arm_new(&tmr->os, tmr->interval, tmr->mode==TIMER_MODE_AUTO, 1);
os_timer_disarm(&tmr->os);
os_timer_arm(&tmr->os, tmr->interval, tmr->mode==TIMER_MODE_AUTO);
}
}
return 0;
......@@ -266,6 +269,7 @@ static int tmr_wdclr( lua_State* L ){
return 0;
}
#ifdef __ESP8266__
//system_rtc_clock_cali_proc() returns
//a fixed point value (12 bit fraction part)
//it tells how many rtc clock ticks represent 1us.
......@@ -317,6 +321,7 @@ static int tmr_softwd( lua_State* L ){
soft_watchdog = luaL_checkinteger(L, 1);
return 0;
}
#endif
// Module function map
......@@ -324,8 +329,10 @@ static const LUA_REG_TYPE tmr_map[] = {
{ LSTRKEY( "delay" ), LFUNCVAL( tmr_delay ) },
{ LSTRKEY( "now" ), LFUNCVAL( tmr_now ) },
{ LSTRKEY( "wdclr" ), LFUNCVAL( tmr_wdclr ) },
#ifdef __ESP8266__
{ LSTRKEY( "softwd" ), LFUNCVAL( tmr_softwd ) },
{ LSTRKEY( "time" ), LFUNCVAL( tmr_time ) },
#endif
{ LSTRKEY( "register" ), LFUNCVAL( tmr_register ) },
{ LSTRKEY( "alarm" ), LFUNCVAL( tmr_alarm ) },
{ LSTRKEY( "start" ), LFUNCVAL( tmr_start ) },
......@@ -344,14 +351,16 @@ int luaopen_tmr( lua_State *L ){
for(i=0; i<NUM_TMR; i++){
alarm_timers[i].lua_ref = LUA_NOREF;
alarm_timers[i].mode = TIMER_MODE_OFF;
ets_timer_disarm(&alarm_timers[i].os);
os_timer_disarm(&alarm_timers[i].os);
}
#ifdef __ESP8266__
last_rtc_time=system_get_rtc_time(); // Right now is time 0
last_rtc_time_us=0;
ets_timer_disarm(&rtc_timer);
ets_timer_setfn(&rtc_timer, rtc_callback, NULL);
ets_timer_arm_new(&rtc_timer, 1000, 1, 1);
os_timer_disarm(&rtc_timer);
os_timer_setfn(&rtc_timer, rtc_callback, NULL);
os_timer_arm(&rtc_timer, 1000, 1);
#endif
callback_task = task_get_id (run_callback);
return 0;
......
......@@ -262,6 +262,7 @@ static int wifi_getchannel( lua_State* L )
return 1;
}
#ifdef __ESP8266__
/**
* wifi.setphymode()
* Description:
......@@ -372,6 +373,7 @@ static int wifi_sleep(lua_State* L)
}
return 2;
}
#endif
// Lua: mac = wifi.xx.getmac()
static int wifi_getmac( lua_State* L, uint8_t mode )
......@@ -487,6 +489,7 @@ static int wifi_setip( lua_State* L, uint8_t mode )
return 1;
}
#ifdef __ESP8266__
// Lua: realtype = sleeptype(type)
static int wifi_sleeptype( lua_State* L )
{
......@@ -506,6 +509,7 @@ static int wifi_sleeptype( lua_State* L )
lua_pushinteger( L, type );
return 1;
}
#endif
// Lua: wifi.sta.getmac()
static int wifi_station_getmac( lua_State* L ){
......@@ -897,6 +901,7 @@ static int wifi_station_listap( lua_State* L )
unregister_lua_cb(L, &wifi_scan_succeed);
}
}
#ifdef __ESP8266__
// Lua: wifi.sta.gethostname()
static int wifi_sta_gethostname( lua_State* L )
......@@ -933,6 +938,7 @@ static int wifi_sta_sethostname_lua( lua_State* L )
luaL_argcheck(L, wifi_sta_sethostname(hostname, len), 1, "Invalid hostname");
return 0;
}
#endif
// Lua: wifi.sta.status()
static int wifi_station_status( lua_State* L )
......@@ -1228,8 +1234,10 @@ static const LUA_REG_TYPE wifi_station_map[] = {
{ LSTRKEY( "getmac" ), LFUNCVAL( wifi_station_getmac ) },
{ LSTRKEY( "setmac" ), LFUNCVAL( wifi_station_setmac ) },
{ LSTRKEY( "getap" ), LFUNCVAL( wifi_station_listap ) },
#ifdef __ESP8266__
{ LSTRKEY( "sethostname" ), LFUNCVAL( wifi_sta_sethostname_lua ) },
{ LSTRKEY( "gethostname" ), LFUNCVAL( wifi_sta_gethostname ) },
#endif
{ LSTRKEY( "getrssi" ), LFUNCVAL( wifi_station_getrssi ) },
{ LSTRKEY( "status" ), LFUNCVAL( wifi_station_status ) },
#if defined(WIFI_STATION_STATUS_MONITOR_ENABLE)
......@@ -1266,14 +1274,16 @@ static const LUA_REG_TYPE wifi_map[] = {
{ LSTRKEY( "setmode" ), LFUNCVAL( wifi_setmode ) },
{ LSTRKEY( "getmode" ), LFUNCVAL( wifi_getmode ) },
{ LSTRKEY( "getchannel" ), LFUNCVAL( wifi_getchannel ) },
#ifdef __ESP8266__
{ LSTRKEY( "setphymode" ), LFUNCVAL( wifi_setphymode ) },
{ LSTRKEY( "getphymode" ), LFUNCVAL( wifi_getphymode ) },
{ LSTRKEY( "sleep" ), LFUNCVAL( wifi_sleep ) },
{ LSTRKEY( "sleeptype" ), LFUNCVAL( wifi_sleeptype ) },
#endif
#ifdef WIFI_SMART_ENABLE
{ LSTRKEY( "startsmart" ), LFUNCVAL( wifi_start_smart ) },
{ LSTRKEY( "stopsmart" ), LFUNCVAL( wifi_exit_smart ) },
#endif
{ LSTRKEY( "sleeptype" ), LFUNCVAL( wifi_sleeptype ) },
{ LSTRKEY( "sta" ), LROVAL( wifi_station_map ) },
{ LSTRKEY( "ap" ), LROVAL( wifi_ap_map ) },
......@@ -1285,6 +1295,7 @@ static const LUA_REG_TYPE wifi_map[] = {
{ LSTRKEY( "SOFTAP" ), LNUMVAL( SOFTAP_MODE ) },
{ LSTRKEY( "STATIONAP" ), LNUMVAL( STATIONAP_MODE ) },
#ifdef __ESP8266__
{ LSTRKEY( "PHYMODE_B" ), LNUMVAL( PHY_MODE_11B ) },
{ LSTRKEY( "PHYMODE_G" ), LNUMVAL( PHY_MODE_11G ) },
{ LSTRKEY( "PHYMODE_N" ), LNUMVAL( PHY_MODE_11N ) },
......@@ -1292,6 +1303,7 @@ static const LUA_REG_TYPE wifi_map[] = {
{ LSTRKEY( "NONE_SLEEP" ), LNUMVAL( NONE_SLEEP_T ) },
{ LSTRKEY( "LIGHT_SLEEP" ), LNUMVAL( LIGHT_SLEEP_T ) },
{ LSTRKEY( "MODEM_SLEEP" ), LNUMVAL( MODEM_SLEEP_T ) },
#endif
{ LSTRKEY( "OPEN" ), LNUMVAL( AUTH_OPEN ) },
//{ LSTRKEY( "WEP" ), LNUMVAL( AUTH_WEP ) },
......@@ -1310,6 +1322,7 @@ static const LUA_REG_TYPE wifi_map[] = {
{ LNILKEY, LNILVAL }
};
#ifdef __ESP8266__
static void wifi_change_default_host_name(task_param_t param, task_prio_t priority)
{
#ifndef WIFI_STA_HOSTNAME
......@@ -1342,10 +1355,13 @@ static void wifi_change_default_host_name(task_param_t param, task_prio_t priori
#endif
}
#endif
int luaopen_wifi( lua_State *L )
{
#ifdef __ESP8266__
task_post_low(task_get_id(wifi_change_default_host_name), FALSE);
#endif
#if defined(WIFI_SDK_EVENT_MONITOR_ENABLE)
wifi_eventmon_init();
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment