Commit e86b2ec5 authored by funshine's avatar funshine
Browse files

fix tmr.delay(), add tmr.wdclr(), fix UDP, update doc

parent 6f9c17a2
This diff is collapsed.
# **NodeMcu** # # **NodeMcu** #
###A lua based firmware for wifi-soc esp8266 ###A lua based firmware for wifi-soc esp8266
version 0.9.2 build 2014-11-19 version 0.9.2 build 2014-11-20
# Change log # Change log
[change log](https://github.com/funshine/nodemcu-firmware/wiki/nodemcu_api_en#change_log)<br /> [change log](https://github.com/funshine/nodemcu-firmware/wiki/nodemcu_api_en#change_log)<br />
[变更日志](https://github.com/funshine/nodemcu-firmware/wiki/nodemcu_api_cn#change_log) [变更日志](https://github.com/funshine/nodemcu-firmware/wiki/nodemcu_api_cn#change_log)
...@@ -76,7 +76,7 @@ braudrate:9600 ...@@ -76,7 +76,7 @@ braudrate:9600
```lua ```lua
-- A simple http client -- A simple http client
conn=net.createConnection(net.TCP, false) conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(c) end ) conn:on("receive", function(conn, payload) print(c) end )
conn:connect(80,"115.239.210.27") conn:connect(80,"115.239.210.27")
conn:send("GET / HTTP/1.1\r\nHost: www.baidu.com\r\n" conn:send("GET / HTTP/1.1\r\nHost: www.baidu.com\r\n"
......
This diff is collapsed.
# **nodeMcu API说明** # # **nodeMcu API说明** #
[English Version](https://github.com/funshine/nodemcu-firmware/wiki/nodemcu_api_en) [English Version](https://github.com/funshine/nodemcu-firmware/wiki/nodemcu_api_en)
###版本 0.9.2 build 2014-11-19 ###版本 0.9.2 build 2014-11-20
<a id="change_log"></a> <a id="change_log"></a>
###变更日志: ###变更日志:
2014-11-20<br />
修正tmr.delay,支持2s以上的延时,但是长延时可能会引起beacon timer out,导致与AP之间重新连接。<br />
增加tmr.wdclr(),用来重置看门狗计数器,用在长循环中,以防芯片因看门狗重启。<br />
修正net模块UDP无法连接问题。<br />
createServer(net.TCP, timeout)函数增加连接超时参数设置。
2014-11-19<br /> 2014-11-19<br />
增加adc模块,adc.read(0)读取adc的值。<br /> 增加adc模块,adc.read(0)读取adc的值。<br />
wifi模块增加wifi.sta.getap() 函数,用于获取ap列表。 wifi模块增加wifi.sta.getap() 函数,用于获取ap列表。
...@@ -1032,6 +1038,31 @@ nil ...@@ -1032,6 +1038,31 @@ nil
####参见 ####参见
**-** [tmr.now()](#tm_now) **-** [tmr.now()](#tm_now)
<a id="tm_wdclr"></a>
## tmr.wdclr()
####描述
清除看门狗计数器。<br />
####语法
tmr.wdclr()
####参数
nil.
####返回值
nil
####示例
```lua
for i=1,10000 do
print(i)
tmr.wdclr() -- 一个长时间的循环或者事务,需内部调用tmr.wdclr() 清楚看门狗计数器,防止重启。
end
```
####参见
**-** [tmr.delay()](#tm_delay)
#GPIO 模块 #GPIO 模块
##常量 ##常量
...@@ -1382,11 +1413,11 @@ net.TCP, net.UDP ...@@ -1382,11 +1413,11 @@ net.TCP, net.UDP
创建一个server。 创建一个server。
####语法 ####语法
net.createServer(type, secure) net.createServer(type, timeout)
####参数 ####参数
type: 取值为:net.TCP 或者 net.UDP<br /> type: 取值为:net.TCP 或者 net.UDP<br />
secure: 设置为true或者false, true代表安全连接,false代表普通连接 timeout: 1~28800, 当为tcp服务器时,客户端的超时时间设置
####返回值 ####返回值
net.server子模块 net.server子模块
...@@ -1394,7 +1425,7 @@ net.server子模块 ...@@ -1394,7 +1425,7 @@ net.server子模块
####示例 ####示例
```lua ```lua
net.createServer(net.TCP, true) net.createServer(net.TCP, 30)
``` ```
####参见 ####参见
...@@ -1411,7 +1442,7 @@ net.createConnection(type, secure) ...@@ -1411,7 +1442,7 @@ net.createConnection(type, secure)
####参数 ####参数
type: 取值为:net.TCP 或者 net.UDP<br /> type: 取值为:net.TCP 或者 net.UDP<br />
secure: 设置为true或者false, true代表安全连接,false代表普通连接。 secure: 设置为1或者0, 1代表安全连接,0代表普通连接。
####返回值 ####返回值
net.server子模块 net.server子模块
...@@ -1419,7 +1450,7 @@ net.server子模块 ...@@ -1419,7 +1450,7 @@ net.server子模块
####示例 ####示例
```lua ```lua
net.createConnection(net.UDP, false) net.createConnection(net.UDP, 0)
``` ```
####参见 ####参见
...@@ -1447,7 +1478,7 @@ nil ...@@ -1447,7 +1478,7 @@ nil
```lua ```lua
-- 创建一个server -- 创建一个server
sv=net.createServer(net.TCP, false) sv=net.createServer(net.TCP, 30) -- 30s 超时
-- server侦听端口80,如果收到数据将数据打印至控制台,并向远端发送‘hello world’ -- server侦听端口80,如果收到数据将数据打印至控制台,并向远端发送‘hello world’
sv:listen(80,function(c) sv:listen(80,function(c)
c:on("receive", function(sck, pl) print(pl) end) c:on("receive", function(sck, pl) print(pl) end)
...@@ -1477,7 +1508,7 @@ nil ...@@ -1477,7 +1508,7 @@ nil
```lua ```lua
-- 创建server -- 创建server
sv=net.createServer(net.TCP, false) sv=net.createServer(net.TCP, 5)
-- 关闭server -- 关闭server
sv:close() sv:close()
``` ```
...@@ -1544,7 +1575,7 @@ nil ...@@ -1544,7 +1575,7 @@ nil
####示例 ####示例
```lua ```lua
sk=net.createConnection(net.TCP, false) sk=net.createConnection(net.TCP, 0)
sk:on("receive", function(sck, c) print(c) end ) sk:on("receive", function(sck, c) print(c) end )
sk:connect(80,"192.168.0.66") sk:connect(80,"192.168.0.66")
sk:send("GET / HTTP/1.1\r\nHost: 192.168.0.66\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n") sk:send("GET / HTTP/1.1\r\nHost: 192.168.0.66\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")
...@@ -1750,7 +1781,7 @@ string:接收到的数据。 ...@@ -1750,7 +1781,7 @@ string:接收到的数据。
<a id="adc_read"></a> <a id="adc_read"></a>
## adc.read() ## adc.read()
####描述 ####描述
读取adc的值,esp8266只有一个10bit adc,id为0,最大值1024 读取adc的值,esp8266只有一个10bit adc,id为0,引脚为TOUT,最大值1024
####语法 ####语法
adc.read(id) adc.read(id)
......
This diff is collapsed.
# **nodeMcu API Instruction** # # **nodeMcu API Instruction** #
[中文版本](https://github.com/funshine/nodemcu-firmware/wiki/nodemcu_api_cn) [中文版本](https://github.com/funshine/nodemcu-firmware/wiki/nodemcu_api_cn)
###version 0.9.2 build 2014-11-19 ###version 0.9.2 build 2014-11-20
<a id="change_log"></a> <a id="change_log"></a>
###change log: ###change log:
2014-11-20<br />
fix tmr.delay to support more than 2s delay, may cause bacon time out, lost connection to AP.<br />
add tmr.wdclr to clear watchdog counter in chip, use in long time loop.<br />
fix UDP part of net module.<br />
add a timeout para to createServer(net.TCP, timeout).
2014-11-19<br /> 2014-11-19<br />
add adc module, use adc.read(0) to read adc value, no tests made.<br /> add adc module, use adc.read(0) to read adc value, no tests made.<br />
add wifi.sta.getap() api to wifi.sta module, to get ap list. add wifi.sta.getap() api to wifi.sta module, to get ap list.
...@@ -1051,6 +1057,32 @@ nil ...@@ -1051,6 +1057,32 @@ nil
**-** [tmr.now()](#tm_now) **-** [tmr.now()](#tm_now)
<a id="tm_wdclr"></a>
## tmr.wdclr()
####Description
clear system watchdog counter.<br />
####Syntax
tmr.wdclr()
####Parameters
nil.
####Returns
nil
####Example
```lua
for i=1,10000 do
print(i)
tmr.wdclr() -- should call tmr.wdclr() in a long loop to avoid hardware reset caused by watchdog.
end
```
####See also
**-** [tmr.delay()](#tm_delay)
#GPIO module #GPIO module
##CONSTANT ##CONSTANT
gpio.OUTPUT, gpio.INPUT, gpio.INT, gpio.HIGH, gpio.LOW gpio.OUTPUT, gpio.INPUT, gpio.INT, gpio.HIGH, gpio.LOW
...@@ -1401,11 +1433,11 @@ net.TCP, net.UDP ...@@ -1401,11 +1433,11 @@ net.TCP, net.UDP
create a server. create a server.
####Syntax ####Syntax
net.createServer(type, secure) net.createServer(type, timeout)
####Parameters ####Parameters
type: net.TCP or net.UDP<br /> type: net.TCP or net.UDP<br />
secure: true or false, true for safe link, false for ordinary link timeout: for a TCP server, timeout is 1~28800 seconds, for a inactive client to disconnected.
####Returns ####Returns
net.server sub module net.server sub module
...@@ -1413,7 +1445,7 @@ net.server sub module ...@@ -1413,7 +1445,7 @@ net.server sub module
####Example ####Example
```lua ```lua
net.createServer(net.TCP, true) net.createServer(net.TCP, 30) -- 30s timeout
``` ```
####See also ####See also
...@@ -1430,7 +1462,7 @@ net.createConnection(type, secure) ...@@ -1430,7 +1462,7 @@ net.createConnection(type, secure)
####Parameters ####Parameters
type: net.TCP or net.UDP<br /> type: net.TCP or net.UDP<br />
secure: true or false, true for safe link, false for ordinary link secure: 1 or 0, 1 for ssl link, 0 for normal link
####Returns ####Returns
net.server sub module net.server sub module
...@@ -1438,7 +1470,7 @@ net.server sub module ...@@ -1438,7 +1470,7 @@ net.server sub module
####Example ####Example
```lua ```lua
net.createConnection(net.UDP, false) net.createConnection(net.UDP, 0)
``` ```
####See also ####See also
...@@ -1466,7 +1498,7 @@ nil ...@@ -1466,7 +1498,7 @@ nil
```lua ```lua
-- create a server -- create a server
sv=net.createServer(net.TCP, false) sv=net.createServer(net.TCP, 30) -- 30s time out for a inactive client
-- server listen on 80, if data received, print data to console, and send "hello world" to remote. -- server listen on 80, if data received, print data to console, and send "hello world" to remote.
sv:listen(80,function(c) sv:listen(80,function(c)
c:on("receive", function(sck, pl) print(pl) end) c:on("receive", function(sck, pl) print(pl) end)
...@@ -1496,7 +1528,7 @@ nil ...@@ -1496,7 +1528,7 @@ nil
```lua ```lua
-- create a server -- create a server
sv=net.createServer(net.TCP, false) sv=net.createServer(net.TCP, 30)
-- close server -- close server
sv:close() sv:close()
``` ```
...@@ -1563,7 +1595,7 @@ nil ...@@ -1563,7 +1595,7 @@ nil
####Example ####Example
```lua ```lua
sk=net.createConnection(net.TCP, false) sk=net.createConnection(net.TCP, 0)
sk:on("receive", function(sck, c) print(c) end ) sk:on("receive", function(sck, c) print(c) end )
sk:connect(80,"192.168.0.66") sk:connect(80,"192.168.0.66")
sk:send("GET / HTTP/1.1\r\nHost: 192.168.0.66\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n") sk:send("GET / HTTP/1.1\r\nHost: 192.168.0.66\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")
...@@ -1769,7 +1801,7 @@ none ...@@ -1769,7 +1801,7 @@ none
<a id="adc_read"></a> <a id="adc_read"></a>
## adc.read() ## adc.read()
####Description ####Description
read adc value of id, esp8266 has only one 10bit adc, id=0 read adc value of id, esp8266 has only one 10bit adc, id=0, pin TOUT
####Syntax ####Syntax
adc.read(id) adc.read(id)
......
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