forked from hootrhino/rulex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add data to screen example(hootrhino#76)
add data to screen example
- Loading branch information
1 parent
1404c95
commit 7027f9f
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
-- | ||
-- App use lua syntax, goto https://rulex.pages.dev for more document | ||
-- APPID: APP12a32a3d45df4555a50e04472a78ab4b | ||
-- | ||
AppNAME = "helloworld" | ||
AppVERSION = "1.0.2" | ||
AppDESCRIPTION = "helloworld" | ||
|
||
function ToScreen(In, Out, Data) | ||
local result, err1 = applib:CtrlDevice(In, "ctrlin30ms", Data) | ||
print("err1=>", err1) | ||
print("result=>", result) | ||
local jsonT, err3 = applib:J2T(result) | ||
if err3 ~= nil then | ||
print(3, err3) | ||
return | ||
end | ||
local udpData = applib:T2J{ | ||
model = 'HX-S20', | ||
sn = string.sub(jsonT['out'], 1, 2), | ||
state = string.sub(jsonT['out'], 14, 14) | ||
} | ||
print("udpData => ", udpData) | ||
local err4 = applib:DataToUdp(Out, udpData) | ||
print('DataToUdp success? =>', err4 == nil) | ||
end | ||
|
||
-- | ||
-- Main | ||
-- | ||
-- DEVICEa3a94f6c1ae84f56a92f0f4cd7f53cc4 | ||
function Main() | ||
local Inid = 'DEVICEa3a94f6c1ae84f56a92f0f4cd7f53cc4' | ||
local Outid = 'OUTfde44d8992ce4fde82a3b096352b10cf' | ||
local cmdlist = { | ||
'010300010003540B', '02030000000305F8', '0303000000030429', | ||
'040300000003059E', '050300000003044F', '060300000003047C', | ||
'07030000000305AD', '0803000000030552', '0903000000030483', | ||
'0A030000000304B0' | ||
} | ||
while true do | ||
|
||
for _, cmd in ipairs(cmdlist) do | ||
ToScreen(Inid,Outid,cmd) | ||
applib:Sleep(500) | ||
end | ||
|
||
end | ||
end | ||
|