Added new package

This commit is contained in:
2025-11-05 23:35:45 +01:00
parent 8cea5151b0
commit d518637947
8 changed files with 188 additions and 100 deletions

23
usr/lib/ocnetlib.lua Normal file
View File

@@ -0,0 +1,23 @@
local component = require("component")
local minitel = require("minitel")
local GATEWAY = "home1"
local PORT = 5353
local f = io.open("/etc/hostname", "r")
local hostname = f and f:read("*l") or "unknown"
if f then f:close() end
local modemUUID
for addr, t in component.list("modem") do
modemUUID = addr
break
end
if not modemUUID then
io.stderr:write("[ocnet] Keine Netzwerkkarte gefunden!\n")
return
end
print("[ocnet] registriere " .. hostname .. " (" .. modemUUID .. ") bei " .. GATEWAY)
minitel.usend(GATEWAY, PORT, "REG " .. hostname .. " " .. modemUUID)