-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
900 additions
and
894 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
116 changes: 58 additions & 58 deletions
116
...MCU用Lua测试用例/OnLineTerminalAndOTG/init.lua → ...e included)/OnLineTerminalAndOTG/init.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
id = 'yourid' --Device ID | ||
ssid = 'yourSSID' --WiFi Name | ||
ssidpwd = 'WiFiPassword' --view on http://www.mcunode.com/proxy/<yourid>/<anystring> like:http://www.mcunode.com/proxy/4567/index.html | ||
ip="yourServerIpOrHostName" --Eg:"192.168.1.105" or“www.mcunode.com” | ||
function ls() | ||
local l = file.list() | ||
for k,v in pairs(l) do | ||
print("name:"..k..", size:"..v) | ||
end | ||
end | ||
function cat(filename) | ||
local line | ||
file.open(filename, "r") | ||
while 1 do | ||
line = file.readline() | ||
if line == nil then | ||
break | ||
end | ||
line = string.gsub(line, "\n", "") | ||
print(line) | ||
end | ||
file.close() | ||
end | ||
function startServer() | ||
print(wifi.sta.getip()) | ||
sk=net.createConnection(net.TCP, 0) | ||
sk:on("receive", function(sck, c) node.input(c) end ) --print(c) | ||
sk:on("connection", function(sck, c) | ||
--print(c) | ||
sk:send(id) | ||
tmr.alarm(2, 30000, 1, function() | ||
sk:send('<h1></h1>') | ||
end) | ||
function s_output(str) | ||
if (sk~=nil and str~='') then | ||
sk:send(str) | ||
end | ||
end | ||
node.output(s_output,1) | ||
end ) | ||
sk:on("disconnection",function(conn,c) | ||
--node.output(nil) | ||
print('reconnect') | ||
sk:connect(8001,ip) | ||
sk:send(id) | ||
end) | ||
sk:connect(8001,ip) | ||
end | ||
wifi.setmode(wifi.STATION) | ||
wifi.sta.config(ssid,ssidpwd) --set your ap info !!!!!! | ||
wifi.sta.autoconnect(1) | ||
tmr.alarm(1, 1000, 1, function() | ||
if wifi.sta.getip()==nil then | ||
print("Connect AP, Waiting...") | ||
else | ||
startServer() | ||
tmr.stop(1) | ||
end | ||
id = 'yourid' --Device ID | ||
ssid = 'yourSSID' --WiFi Name | ||
ssidpwd = 'WiFiPassword' --view on http://www.mcunode.com/proxy/<yourid>/<anystring> like:http://www.mcunode.com/proxy/4567/index.html | ||
ip="yourServerIpOrHostName" --Eg:"192.168.1.105" or“www.mcunode.com” | ||
function ls() | ||
local l = file.list() | ||
for k,v in pairs(l) do | ||
print("name:"..k..", size:"..v) | ||
end | ||
end | ||
function cat(filename) | ||
local line | ||
file.open(filename, "r") | ||
while 1 do | ||
line = file.readline() | ||
if line == nil then | ||
break | ||
end | ||
line = string.gsub(line, "\n", "") | ||
print(line) | ||
end | ||
file.close() | ||
end | ||
function startServer() | ||
print(wifi.sta.getip()) | ||
sk=net.createConnection(net.TCP, 0) | ||
sk:on("receive", function(sck, c) node.input(c) end ) --print(c) | ||
sk:on("connection", function(sck, c) | ||
--print(c) | ||
sk:send(id) | ||
tmr.alarm(2, 30000, 1, function() | ||
sk:send('<h1></h1>') | ||
end) | ||
function s_output(str) | ||
if (sk~=nil and str~='') then | ||
sk:send(str) | ||
end | ||
end | ||
node.output(s_output,1) | ||
end ) | ||
sk:on("disconnection",function(conn,c) | ||
--node.output(nil) | ||
print('reconnect') | ||
sk:connect(8001,ip) | ||
sk:send(id) | ||
end) | ||
sk:connect(8001,ip) | ||
end | ||
wifi.setmode(wifi.STATION) | ||
wifi.sta.config(ssid,ssidpwd) --set your ap info !!!!!! | ||
wifi.sta.autoconnect(1) | ||
tmr.alarm(1, 1000, 1, function() | ||
if wifi.sta.getip()==nil then | ||
print("Connect AP, Waiting...") | ||
else | ||
startServer() | ||
tmr.stop(1) | ||
end | ||
end) |
File renamed without changes.
File renamed without changes.
66 changes: 33 additions & 33 deletions
66
...测试用例/WebProxyDemo/LEDremote/indextpl.html → ...ded)/WebProxyDemo/LEDremote/indextpl.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
<title>互联网控制nodemcuLED</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | ||
<link rel="stylesheet" type="text/css" href="http://cdn.bootcss.com/semantic-ui/2.2.11/semantic.min.css"> | ||
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> | ||
<script src="http://cdn.bootcss.com/semantic-ui/2.2.11/semantic.min.js"></script> | ||
<h3>互联网控制NodeMcu的IO</h3> | ||
<div class="ui left floated compact segment"> | ||
GPIO0:<div class="ui fitted toggle checkbox" id="IO"> | ||
<input type="checkbox" id="led0" onclick="led(0)"> | ||
<label></label> | ||
</div> | ||
</div> | ||
<script> | ||
function led(pin) { | ||
if ($("#led"+pin).get(0).checked) { | ||
console.log('checked'+pin); | ||
$.ajax({url: "?pin=ON"+pin}) | ||
}else { | ||
console.log('unchecked'+pin); | ||
$.ajax({url: "?pin=OFF"+pin}) | ||
} | ||
} | ||
$(document).ready( | ||
function () { | ||
for (i=12;i>0;i--) { | ||
$("#IO").after("<br>GPIO" + i + ":<div class=\"ui fitted toggle checkbox\">\n" + | ||
" <input type=\"checkbox\" id=\"led" + i + "\" onclick=\"led(" + i + ")\">\n" + | ||
" <label></label>\n" + | ||
" </div>"); | ||
} | ||
} | ||
) | ||
</script> | ||
<title>互联网控制nodemcuLED</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | ||
<link rel="stylesheet" type="text/css" href="http://cdn.bootcss.com/semantic-ui/2.2.11/semantic.min.css"> | ||
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> | ||
<script src="http://cdn.bootcss.com/semantic-ui/2.2.11/semantic.min.js"></script> | ||
<h3>互联网控制NodeMcu的IO</h3> | ||
<div class="ui left floated compact segment"> | ||
GPIO0:<div class="ui fitted toggle checkbox" id="IO"> | ||
<input type="checkbox" id="led0" onclick="led(0)"> | ||
<label></label> | ||
</div> | ||
</div> | ||
<script> | ||
function led(pin) { | ||
if ($("#led"+pin).get(0).checked) { | ||
console.log('checked'+pin); | ||
$.ajax({url: "?pin=ON"+pin}) | ||
}else { | ||
console.log('unchecked'+pin); | ||
$.ajax({url: "?pin=OFF"+pin}) | ||
} | ||
} | ||
$(document).ready( | ||
function () { | ||
for (i=12;i>0;i--) { | ||
$("#IO").after("<br>GPIO" + i + ":<div class=\"ui fitted toggle checkbox\">\n" + | ||
" <input type=\"checkbox\" id=\"led" + i + "\" onclick=\"led(" + i + ")\">\n" + | ||
" <label></label>\n" + | ||
" </div>"); | ||
} | ||
} | ||
) | ||
</script> |
108 changes: 54 additions & 54 deletions
108
...U用Lua测试用例/WebProxyDemo/LEDremote/init.lua → ...included)/WebProxyDemo/LEDremote/init.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
local mcunode = require "mcunode" | ||
|
||
--url:http://mcunodeserver-ip/proxy/<your-id>/gpio?pin=1&val=0 | ||
--return:status=success | ||
mcunode.handle("/gpio",function(req,res) | ||
local pin = req.getParam("pin") | ||
local val = req.getParam("val") | ||
if( pin ~= nil) and (val ~= nil) then | ||
print("pin: "..pin .." , val: " ..val) | ||
gpio.mode(pin, gpio.OUTPUT) | ||
gpio.write(pin, val) | ||
res.setAttribute("status","success") | ||
end | ||
return res | ||
end) | ||
mcunode.handle("/test",function(req,res) | ||
local name = req.getParam("name") | ||
res.setAttribute("name",name) | ||
res.body="wodename:{{name}}" | ||
return res | ||
end) | ||
--url:http://mcunodeserver-ip/proxy/<your-id>/index.html?name=farry&work=student | ||
mcunode.handle("/index.html",function(req,res) | ||
local p | ||
local pin = req.getParam("pin") | ||
for i=0 , 12 do | ||
gpio.mode(i, gpio.OUTPUT) | ||
end | ||
if (pin~=nil) then | ||
res.body="ok" | ||
a,b=string.find(pin,'ON') | ||
if (a~=nil) then | ||
c,d=string.find(pin,'%d%d') | ||
if (c~=nil) then | ||
p=string.sub(pin,c,d) | ||
else | ||
p=string.sub(pin,string.find(pin,'%d')) | ||
end | ||
gpio.write(p,1) | ||
else | ||
c,d=string.find(pin,'%d%d') | ||
if (c~=nil) then | ||
p=string.sub(pin,c,d) | ||
else | ||
p=string.sub(pin,string.find(pin,'%d')) | ||
end | ||
gpio.write(p,0) | ||
end | ||
elseif (pin==nil) then | ||
res.file = "indextpl.html" | ||
end | ||
return res | ||
end) | ||
mcunode.connect("4567","eiot.club","wifi","123456abc") | ||
local mcunode = require "mcunode" | ||
|
||
--url:http://mcunodeserver-ip/proxy/<your-id>/gpio?pin=1&val=0 | ||
--return:status=success | ||
mcunode.handle("/gpio",function(req,res) | ||
local pin = req.getParam("pin") | ||
local val = req.getParam("val") | ||
if( pin ~= nil) and (val ~= nil) then | ||
print("pin: "..pin .." , val: " ..val) | ||
gpio.mode(pin, gpio.OUTPUT) | ||
gpio.write(pin, val) | ||
res.setAttribute("status","success") | ||
end | ||
return res | ||
end) | ||
mcunode.handle("/test",function(req,res) | ||
local name = req.getParam("name") | ||
res.setAttribute("name",name) | ||
res.body="wodename:{{name}}" | ||
return res | ||
end) | ||
--url:http://mcunodeserver-ip/proxy/<your-id>/index.html?name=farry&work=student | ||
mcunode.handle("/index.html",function(req,res) | ||
local p | ||
local pin = req.getParam("pin") | ||
for i=0 , 12 do | ||
gpio.mode(i, gpio.OUTPUT) | ||
end | ||
if (pin~=nil) then | ||
res.body="ok" | ||
a,b=string.find(pin,'ON') | ||
if (a~=nil) then | ||
c,d=string.find(pin,'%d%d') | ||
if (c~=nil) then | ||
p=string.sub(pin,c,d) | ||
else | ||
p=string.sub(pin,string.find(pin,'%d')) | ||
end | ||
gpio.write(p,1) | ||
else | ||
c,d=string.find(pin,'%d%d') | ||
if (c~=nil) then | ||
p=string.sub(pin,c,d) | ||
else | ||
p=string.sub(pin,string.find(pin,'%d')) | ||
end | ||
gpio.write(p,0) | ||
end | ||
elseif (pin==nil) then | ||
res.file = "indextpl.html" | ||
end | ||
return res | ||
end) | ||
mcunode.connect("4567","eiot.club","wifi","123456abc") |
Oops, something went wrong.