Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
e58b7671
Commit
e58b7671
authored
Jul 06, 2015
by
devsaurus
Browse files
Merge remote-tracking branch 'upstream/dev' into dev
parents
414a0478
67d785ff
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/include/user_modules.h
View file @
e58b7671
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#define LUA_USE_MODULES_MQTT
#define LUA_USE_MODULES_MQTT
#define LUA_USE_MODULES_COAP
#define LUA_USE_MODULES_COAP
#define LUA_USE_MODULES_U8G
#define LUA_USE_MODULES_U8G
#define LUA_USE_MODULES_WS2801
//
#define LUA_USE_MODULES_WS2801
#define LUA_USE_MODULES_WS2812
#define LUA_USE_MODULES_WS2812
#define LUA_USE_MODULES_CJSON
#define LUA_USE_MODULES_CJSON
#define LUA_USE_MODULES_CRYPTO
#define LUA_USE_MODULES_CRYPTO
...
...
app/modules/node.c
View file @
e58b7671
...
@@ -421,6 +421,15 @@ static int node_bootreason (lua_State *L)
...
@@ -421,6 +421,15 @@ static int node_bootreason (lua_State *L)
return
1
;
return
1
;
}
}
// Lua: restore()
static
int
node_restore
(
lua_State
*
L
)
{
flash_init_data_default
();
flash_init_data_blank
();
system_restore
();
return
0
;
}
// Module function map
// Module function map
#define MIN_OPT_LEVEL 2
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
#include "lrodefs.h"
...
@@ -446,6 +455,7 @@ const LUA_REG_TYPE node_map[] =
...
@@ -446,6 +455,7 @@ const LUA_REG_TYPE node_map[] =
{
LSTRKEY
(
"CPU160MHZ"
),
LNUMVAL
(
CPU160MHZ
)
},
{
LSTRKEY
(
"CPU160MHZ"
),
LNUMVAL
(
CPU160MHZ
)
},
{
LSTRKEY
(
"setcpufreq"
),
LFUNCVAL
(
node_setcpufreq
)
},
{
LSTRKEY
(
"setcpufreq"
),
LFUNCVAL
(
node_setcpufreq
)
},
{
LSTRKEY
(
"bootreason"
),
LFUNCVAL
(
node_bootreason
)
},
{
LSTRKEY
(
"bootreason"
),
LFUNCVAL
(
node_bootreason
)
},
{
LSTRKEY
(
"restore"
),
LFUNCVAL
(
node_restore
)
},
// Combined to dsleep(us, option)
// Combined to dsleep(us, option)
// { LSTRKEY( "dsleepsetoption" ), LFUNCVAL( node_deepsleep_setoption) },
// { LSTRKEY( "dsleepsetoption" ), LFUNCVAL( node_deepsleep_setoption) },
#if LUA_OPTIMIZE_MEMORY > 0
#if LUA_OPTIMIZE_MEMORY > 0
...
...
app/modules/rc.c
View file @
e58b7671
...
@@ -9,13 +9,13 @@
...
@@ -9,13 +9,13 @@
#define defProtocol 1
#define defProtocol 1
#define defRepeat 10
#define defRepeat 10
#define defBits 24
#define defBits 24
void
transmit
(
int
pin
,
int
pulseLen
,
int
nHighPulses
,
int
nLowPulses
)
{
static
void
ICACHE_FLASH_ATTR
transmit
(
int
pin
,
int
pulseLen
,
int
nHighPulses
,
int
nLowPulses
)
{
platform_gpio_write
(
pin
,
1
);
platform_gpio_write
(
pin
,
1
);
os_delay_us
(
pulseLen
*
nHighPulses
);
os_delay_us
(
pulseLen
*
nHighPulses
);
platform_gpio_write
(
pin
,
0
);
platform_gpio_write
(
pin
,
0
);
os_delay_us
(
pulseLen
*
nLowPulses
);
os_delay_us
(
pulseLen
*
nLowPulses
);
}
}
//rc.send(
0
,267715,24,185,1) --GPIO, code, bits, pulselen, protocol
//rc.send(
4
,267715,24,185,1
,10
) --GPIO, code, bits, pulselen, protocol
, repeat
static
int
ICACHE_FLASH_ATTR
rc_send
(
lua_State
*
L
)
{
static
int
ICACHE_FLASH_ATTR
rc_send
(
lua_State
*
L
)
{
const
uint8_t
pin
=
luaL_checkinteger
(
L
,
1
);
const
uint8_t
pin
=
luaL_checkinteger
(
L
,
1
);
platform_gpio_mode
(
pin
,
PLATFORM_GPIO_OUTPUT
,
PLATFORM_GPIO_FLOAT
);
platform_gpio_mode
(
pin
,
PLATFORM_GPIO_OUTPUT
,
PLATFORM_GPIO_FLOAT
);
...
...
app/modules/wifi.c
View file @
e58b7671
...
@@ -17,23 +17,48 @@
...
@@ -17,23 +17,48 @@
static
int
wifi_smart_succeed
=
LUA_NOREF
;
static
int
wifi_smart_succeed
=
LUA_NOREF
;
static
uint8
getap_output_format
=
0
;
static
uint8
getap_output_format
=
0
;
#if defined( NODE_SMART_OLDSTYLE )
#else
static
lua_State
*
smart_L
=
NULL
;
#endif
static
void
wifi_smart_succeed_cb
(
void
*
arg
){
static
void
wifi_smart_succeed_cb
(
void
*
arg
){
NODE_DBG
(
"wifi_smart_succeed_cb is called.
\n
"
);
NODE_DBG
(
"wifi_smart_succeed_cb is called.
\n
"
);
#if defined( NODE_SMART_OLDSTYLE )
if
(
!
arg
)
if
(
!
arg
)
return
;
return
;
#if 0
struct station_config *sta_conf = arg;
wifi_station_set_config(sta_conf);
wifi_station_disconnect();
wifi_station_connect();
smartconfig_stop();
#endif
if
(
wifi_smart_succeed
==
LUA_NOREF
)
if
(
wifi_smart_succeed
==
LUA_NOREF
)
return
;
return
;
lua_State
*
L
=
(
lua_State
*
)
arg
;
lua_State
*
L
=
(
lua_State
*
)
arg
;
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
wifi_smart_succeed
);
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
wifi_smart_succeed
);
lua_call
(
L
,
0
,
0
);
lua_call
(
L
,
0
,
0
);
#else
if
(
!
arg
)
return
;
struct
station_config
*
sta_conf
=
arg
;
wifi_station_set_config
(
sta_conf
);
wifi_station_disconnect
();
wifi_station_connect
();
if
(
wifi_smart_succeed
!=
LUA_NOREF
)
{
lua_rawgeti
(
smart_L
,
LUA_REGISTRYINDEX
,
wifi_smart_succeed
);
lua_pushstring
(
smart_L
,
sta_conf
->
ssid
);
lua_pushstring
(
smart_L
,
sta_conf
->
password
);
lua_call
(
smart_L
,
2
,
0
);
luaL_unref
(
smart_L
,
LUA_REGISTRYINDEX
,
wifi_smart_succeed
);
wifi_smart_succeed
=
LUA_NOREF
;
}
smartconfig_stop
();
#endif // defined( NODE_SMART_OLDSTYLE )
}
}
static
int
wifi_scan_succeed
=
LUA_NOREF
;
static
int
wifi_scan_succeed
=
LUA_NOREF
;
...
@@ -107,6 +132,9 @@ static void wifi_scan_done(void *arg, STATUS status)
...
@@ -107,6 +132,9 @@ static void wifi_scan_done(void *arg, STATUS status)
// Lua: smart(type, function succeed_cb)
// Lua: smart(type, function succeed_cb)
static
int
wifi_start_smart
(
lua_State
*
L
)
static
int
wifi_start_smart
(
lua_State
*
L
)
{
{
#if defined( NODE_SMART_OLDSTYLE )
unsigned
channel
;
unsigned
channel
;
int
stack
=
1
;
int
stack
=
1
;
...
@@ -133,15 +161,49 @@ static int wifi_start_smart( lua_State* L )
...
@@ -133,15 +161,49 @@ static int wifi_start_smart( lua_State* L )
}
else
{
}
else
{
smart_begin
(
channel
,
(
smart_succeed
)
wifi_smart_succeed_cb
,
L
);
smart_begin
(
channel
,
(
smart_succeed
)
wifi_smart_succeed_cb
,
L
);
}
}
// smartconfig_start(0, wifi_smart_succeed_cb);
#else
if
(
wifi_get_opmode
()
!=
STATION_MODE
)
{
return
luaL_error
(
L
,
"Smart link only in STATION mode"
);
}
uint8_t
smart_type
=
0
;
int
stack
=
1
;
smart_L
=
L
;
if
(
lua_isnumber
(
L
,
stack
)
)
{
smart_type
=
lua_tointeger
(
L
,
stack
);
stack
++
;
}
if
(
lua_type
(
L
,
stack
)
==
LUA_TFUNCTION
||
lua_type
(
L
,
stack
)
==
LUA_TLIGHTFUNCTION
)
{
lua_pushvalue
(
L
,
stack
);
// copy argument (func) to the top of stack
if
(
wifi_smart_succeed
!=
LUA_NOREF
)
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
wifi_smart_succeed
);
wifi_smart_succeed
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
}
if
(
smart_type
>
1
)
return
luaL_error
(
L
,
"wrong arg range"
);
smartconfig_start
(
smart_type
,
wifi_smart_succeed_cb
);
#endif // defined( NODE_SMART_OLDSTYLE )
return
0
;
return
0
;
}
}
// Lua: exit_smart()
// Lua: exit_smart()
static
int
wifi_exit_smart
(
lua_State
*
L
)
static
int
wifi_exit_smart
(
lua_State
*
L
)
{
{
#if defined( NODE_SMART_OLDSTYLE )
smart_end
();
smart_end
();
// smartconfig_stop();
#else
smartconfig_stop
();
#endif // defined( NODE_SMART_OLDSTYLE )
if
(
wifi_smart_succeed
!=
LUA_NOREF
)
if
(
wifi_smart_succeed
!=
LUA_NOREF
)
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
wifi_smart_succeed
);
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
wifi_smart_succeed
);
wifi_smart_succeed
=
LUA_NOREF
;
wifi_smart_succeed
=
LUA_NOREF
;
...
...
ld/eagle.app.v6.ld
View file @
e58b7671
...
@@ -5,7 +5,7 @@ MEMORY
...
@@ -5,7 +5,7 @@ MEMORY
dport0_0_seg : org = 0x3FF00000, len = 0x10
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40210000, len = 0x
6
0000
irom0_0_seg : org = 0x40210000, len = 0x
8
0000
}
}
PHDRS
PHDRS
...
...
lib/libsmartconfig.a
View file @
e58b7671
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment