1
0
mirror of https://github.com/XeonSquared/OC-Copper.git synced 2024-11-23 09:58:06 +11:00

Store hostname of EEPROM light-nodes as the EEPROM label.

This commit is contained in:
20kdc 2017-03-23 17:51:54 +00:00
parent 0767092660
commit 65f896b291
3 changed files with 11 additions and 8 deletions

View File

@ -2,7 +2,7 @@
-- No warranty is provided, implied or otherwise. -- No warranty is provided, implied or otherwise.
%-- EXAMPLE IoT Redstone Top Controller -- %-- EXAMPLE IoT Redstone Top Controller --
UR=C.proxy(C.list("redstone")()) UR=CG("redstone")
function UT(p) function UT(p)
US=p US=p
if#p>0then if#p>0then
@ -19,7 +19,7 @@ N={
[0]=UG, [0]=UG,
[1]=function(f)RS(f,4,"\xC1"..US)end, [1]=function(f)RS(f,4,"\xC1"..US)end,
[0x41]=function(_,p)UT(p)end, [0x41]=function(_,p)UT(p)end,
[0x82]=function(_,p)if#p>0then TH=p end end, [0x82]=function(_,p)if#p>0then CG("eeprom").setLabel(p)TH=p end end,
} }
function UI(f,t,p,d) function UI(f,t,p,d)
local m=t==TH local m=t==TH

View File

@ -14,13 +14,15 @@
-- C (short for 'component') -- C (short for 'component')
-- Functions: -- Functions:
-- CG: Get Component
-- TN: Decode Name -- TN: Decode Name
-- TR: Receive Message handling (returns s/d/m rather than using a callback) -- TR: Receive Message handling (returns s/d/m rather than using a callback)
-- TS: Send Message (notably, this has no 'from') -- TS: Send Message (notably, this has no 'from')
-- TB: The TX.broadcast function -- TB: The TX.broadcast function
TH,S,C,TC="hostname",string,component,"copper" S,C,TC=string,component,"copper"
TX=C.proxy(C.list("modem")()) function CG(n)return C.proxy(C.list(n)())end
TH,TX=CG("eeprom").getLabel(),CG("modem")
TX.open(4957) TX.open(4957)
TB=TX.broadcast TB=TX.broadcast
function TN(m) function TN(m)

View File

@ -1,5 +1,6 @@
TH,S,C,TC="hostname",string,component,"copper" S,C,TC=string,component,"copper"
TX=C.proxy(C.list("modem")())TX.open(4957)TB=TX.broadcast function CG(n)return C.proxy(C.list(n)())end
TH,TX=CG("eeprom").getLabel(),CG("modem")TX.open(4957)TB=TX.broadcast
function TN(m)if#m<2then return end function TN(m)if#m<2then return end
local n=m:byte(1)+2return m:sub(2,n),m:sub(n+1)end local n=m:byte(1)+2return m:sub(2,n),m:sub(n+1)end
function TR(m)local h,s,m,d=m:byte(),TN(m:sub(2))if s then function TR(m)local h,s,m,d=m:byte(),TN(m:sub(2))if s then
@ -52,7 +53,7 @@ TS(t,g..S.char(a,1)..d)x=RP(j,R4)end
RN[t..g]=x RN[t..g]=x
end j()end end j()end
-- EXAMPLE IoT Redstone Top Controller -- -- EXAMPLE IoT Redstone Top Controller --
UR=C.proxy(C.list("redstone")())function UT(p)US=p UR=CG("redstone")function UT(p)US=p
if#p>0then if#p>0then
UR.setOutput(1,15)else UR.setOutput(1,15)else
UR.setOutput(1,0)end UR.setOutput(1,0)end
@ -61,7 +62,7 @@ UT("")function UG(t)RS(t,4,"\xC0\x42active.\x81setName")end
N={[0]=UG, N={[0]=UG,
[1]=function(f)RS(f,4,"\xC1"..US)end, [1]=function(f)RS(f,4,"\xC1"..US)end,
[0x41]=function(_,p)UT(p)end, [0x41]=function(_,p)UT(p)end,
[0x82]=function(_,p)if#p>0then TH=p end end, [0x82]=function(_,p)if#p>0then CG("eeprom").setLabel(p)TH=p end end,
} }
function UI(f,t,p,d)local m=t==TH function UI(f,t,p,d)local m=t==TH
if p==1 and(t=="*"or m)then if p==1 and(t=="*"or m)then