|
|
@ -19,20 +19,6 @@ function UDPService(s, data, port, ip) |
|
|
|
table.insert(commandSet,word); |
|
|
|
table.insert(commandSet,word); |
|
|
|
end |
|
|
|
end |
|
|
|
print("get data count" .. #commandSet); |
|
|
|
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 string.match(data,"^Go") then |
|
|
|
if #commandSet==2 then |
|
|
|
if #commandSet==2 then |
|
|
|
print(tonumber(commandSet[2])) |
|
|
|
print(tonumber(commandSet[2])) |
|
|
@ -63,31 +49,31 @@ function UDPService(s, data, port, ip) |
|
|
|
if string.match(data,"^Ready") then |
|
|
|
if string.match(data,"^Ready") then |
|
|
|
Is_AutoClose = false; |
|
|
|
Is_AutoClose = false; |
|
|
|
GPIOOff(0); |
|
|
|
GPIOOff(0); |
|
|
|
GPIOOn(1); |
|
|
|
GPIOOff(1); |
|
|
|
GPIOOn(2); |
|
|
|
GPIOOff(2); |
|
|
|
s:send(port, ip, "0-1-1"); |
|
|
|
s:send(port, ip, "0-1-1"); |
|
|
|
end |
|
|
|
end |
|
|
|
if string.match(data,"^Status") then |
|
|
|
if string.match(data,"^Status") then |
|
|
|
local result = ""; |
|
|
|
local result = ""; |
|
|
|
if(LightArr[0] == true){ |
|
|
|
if LightArr[0] == true then |
|
|
|
result = "1-" |
|
|
|
result = "1-" |
|
|
|
}else{ |
|
|
|
else |
|
|
|
result = "0-" |
|
|
|
result = "0-" |
|
|
|
} |
|
|
|
end |
|
|
|
if(LightArr[1] == true){ |
|
|
|
if LightArr[1] == true then |
|
|
|
result = result .. "1-" |
|
|
|
result = result .. "1-" |
|
|
|
}else{ |
|
|
|
else |
|
|
|
result = result .. "0-" |
|
|
|
result = result .. "0-" |
|
|
|
} |
|
|
|
end |
|
|
|
if(LightArr[2] == true){ |
|
|
|
if LightArr[2] == true then |
|
|
|
result = result .. "1" |
|
|
|
result = result .. "1" |
|
|
|
}else{ |
|
|
|
else |
|
|
|
result = result .. "0" |
|
|
|
result = result .. "0" |
|
|
|
} |
|
|
|
end |
|
|
|
s:send(port, ip, result); |
|
|
|
s:send(port, ip, result); |
|
|
|
end |
|
|
|
end |
|
|
|
if string.match(data,"^Addr") then |
|
|
|
if string.match(data,"^Addr") then |
|
|
|
s:send(port, ip, "Addr-"IpCfg.ip); |
|
|
|
s:send(port, ip, "Addr-"..IpCfg.ip); |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|