Browse Source

fixed if error

master
jkpete 7 months ago
parent
commit
168505c067
  1. 38
      Src/UDPService.lua

38
Src/UDPService.lua

@ -19,20 +19,6 @@ function UDPService(s, data, port, ip) @@ -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) @@ -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

Loading…
Cancel
Save