Commit 0b01f28c authored by HuangRui's avatar HuangRui
Browse files

Merge branch 'dev' of https://github.com/nodemcu/nodemcu-firmware

Conflicts:
	app/include/user_modules.h
	app/include/user_version.h
parents e3c31d06 6c6d0d0e
...@@ -355,11 +355,29 @@ cs:listen(5683) ...@@ -355,11 +355,29 @@ cs:listen(5683)
myvar=1 myvar=1
cs:var("myvar") -- get coap://192.168.18.103:5683/v1/v/myvar will return the value of myvar: 1 cs:var("myvar") -- get coap://192.168.18.103:5683/v1/v/myvar will return the value of myvar: 1
function myfun() -- function should tack one string, return one string.
function myfun(payload)
print("myfun called") print("myfun called")
respond = "hello"
return respond
end end
cs:func("myfun") -- post coap://192.168.18.103:5683/v1/f/myfun will call myfun cs:func("myfun") -- post coap://192.168.18.103:5683/v1/f/myfun will call myfun
cc = coap.Client() cc = coap.Client()
cc:get(coap.CON, "coap://192.168.18.100:5683/.well-known/core") cc:get(coap.CON, "coap://192.168.18.100:5683/.well-known/core")
cc:post(coap.NON, "coap://192.168.18.100:5683/", "Hello") cc:post(coap.NON, "coap://192.168.18.100:5683/", "Hello")
file.open("test1.txt", "a+") for i = 1, 100*1000 do file.write("x") end file.close() print("Done.")
for n,s in pairs(file.list()) do print(n.." size: "..s) end
file.remove("test1.txt")
for n,s in pairs(file.list()) do print(n.." size: "..s) end
file.open("test2.txt", "a+") for i = 1, 1*1000 do file.write("x") end file.close() print("Done.")
function TestDNSLeak()
c=net.createConnection(net.TCP, 0)
c:connect(80, "bad-name.tlddfdf")
tmr.alarm(1, 3000, 0, function() print("hack socket close, MEM: "..node.heap()) c:close() end) -- socket timeout hack
print("MEM: "..node.heap())
end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
-- NODEMCU TEAM -- NODEMCU TEAM
-- LICENCE: http://opensource.org/licenses/MIT -- LICENCE: http://opensource.org/licenses/MIT
-- Vowstar <vowstar@nodemcu.com> -- Vowstar <vowstar@nodemcu.com>
-- 2015/02/14 sza2 <sza2trash@gmail.com> Fix for negative values
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Set module name as parameter of require -- Set module name as parameter of require
...@@ -96,12 +97,16 @@ function readNumber(addr, unit) ...@@ -96,12 +97,16 @@ function readNumber(addr, unit)
crc = ow.crc8(string.sub(data,1,8)) crc = ow.crc8(string.sub(data,1,8))
-- print("CRC="..crc) -- print("CRC="..crc)
if (crc == data:byte(9)) then if (crc == data:byte(9)) then
t = (data:byte(1) + data:byte(2) * 256)
if (t > 32767) then
t = t - 65536
end
if(unit == nil or unit == C) then if(unit == nil or unit == C) then
t = (data:byte(1) + data:byte(2) * 256) * 625 t = t * 625
elseif(unit == F) then elseif(unit == F) then
t = (data:byte(1) + data:byte(2) * 256) * 1125 + 320000 t = t * 1125 + 320000
elseif(unit == K) then elseif(unit == K) then
t = (data:byte(1) + data:byte(2) * 256) * 625 + 2731500 t = t * 625 + 2731500
else else
return nil return nil
end end
......
HDC1000 = require("HDC1000")
sda = 1
scl = 2
drdyn = false
HDC1000.init(sda, scl, drdyn)
HDC1000.config() -- default values are used if called with no arguments. prototype is config(address, resolution, heater)
print(string.format("Temperature: %.2f °C\nHumidity: %.2f %%", HDC1000.getTemp(), HDC1000.getHumi()))
HDC1000 = nil
package.loaded["HDC1000"]=nil
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
[Downloads](https://github.com/nodemcu/nodemcu-firmware/releases/latest)
\ No newline at end of file
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