diff --git a/Src/UDPService.lua b/Src/UDPService.lua index 09c6397..a33b8d0 100644 --- a/Src/UDPService.lua +++ b/Src/UDPService.lua @@ -19,20 +19,6 @@ function UDPService(s, data, port, ip) table.insert(commandSet,word); end print("get data count" .. #commandSet); - -- if string.match(data,"^Light") then - -- if #commandSet==3 then - -- print(tonumber(commandSet[2]).."-"..commandSet[3]) - -- if commandSet[3]=="On" and tonumber(commandSet[2])~=nil then - -- GPIOOn(tonumber(commandSet[2])); - -- s:send(port, ip, "Light "..commandSet[2].." "..commandSet[3]); - -- elseif commandSet[3]=="Off" and tonumber(commandSet[2])~=nil then - -- GPIOOff(tonumber(commandSet[2])); - -- s:send(port, ip, "Light "..commandSet[2].." "..commandSet[3]); - -- else - -- s:send(port, ip, "CommandFaild"); - -- end - -- end - -- end if string.match(data,"^Go") then if #commandSet==2 then print(tonumber(commandSet[2])) @@ -63,31 +49,31 @@ function UDPService(s, data, port, ip) if string.match(data,"^Ready") then Is_AutoClose = false; GPIOOff(0); - GPIOOn(1); - GPIOOn(2); + GPIOOff(1); + GPIOOff(2); s:send(port, ip, "0-1-1"); end if string.match(data,"^Status") then local result = ""; - if(LightArr[0] == true){ + if LightArr[0] == true then result = "1-" - }else{ + else result = "0-" - } - if(LightArr[1] == true){ + end + if LightArr[1] == true then result = result .. "1-" - }else{ + else result = result .. "0-" - } - if(LightArr[2] == true){ + end + if LightArr[2] == true then result = result .. "1" - }else{ + else result = result .. "0" - } + end s:send(port, ip, result); end if string.match(data,"^Addr") then - s:send(port, ip, "Addr-"IpCfg.ip); + s:send(port, ip, "Addr-"..IpCfg.ip); end end