#580 supervisor wired/wireless dual networking
This commit is contained in:
@@ -17,7 +17,7 @@ local max_distance = nil
|
||||
local comms = {}
|
||||
|
||||
-- protocol/data versions (protocol/data independent changes tracked by util.lua version)
|
||||
comms.version = "3.0.8"
|
||||
comms.version = "3.0.9"
|
||||
comms.api_version = "0.0.10"
|
||||
|
||||
---@enum PROTOCOL
|
||||
@@ -49,13 +49,14 @@ local MGMT_TYPE = {
|
||||
ESTABLISH = 0, -- establish new connection
|
||||
KEEP_ALIVE = 1, -- keep alive packet w/ RTT
|
||||
CLOSE = 2, -- close a connection
|
||||
RTU_ADVERT = 3, -- RTU capability advertisement
|
||||
RTU_DEV_REMOUNT = 4, -- RTU multiblock possbily changed (formed, unformed) due to PPM remount
|
||||
RTU_TONE_ALARM = 5, -- instruct RTUs to play specified alarm tones
|
||||
DIAG_TONE_GET = 6, -- (API) diagnostic: get alarm tones
|
||||
DIAG_TONE_SET = 7, -- (API) diagnostic: set alarm tones
|
||||
DIAG_ALARM_SET = 8, -- (API) diagnostic: set alarm to simulate audio for
|
||||
INFO_LIST_CMP = 9 -- (API) info: list all computers on the network
|
||||
PROBE = 3,
|
||||
RTU_ADVERT = 4, -- RTU capability advertisement
|
||||
RTU_DEV_REMOUNT = 5, -- RTU multiblock possbily changed (formed, unformed) due to PPM remount
|
||||
RTU_TONE_ALARM = 6, -- instruct RTUs to play specified alarm tones
|
||||
DIAG_TONE_GET = 7, -- (API) diagnostic: get alarm tones
|
||||
DIAG_TONE_SET = 8, -- (API) diagnostic: set alarm tones
|
||||
DIAG_ALARM_SET = 9, -- (API) diagnostic: set alarm to simulate audio for
|
||||
INFO_LIST_CMP = 10 -- (API) info: list all computers on the network
|
||||
}
|
||||
|
||||
---@enum CRDN_TYPE
|
||||
@@ -89,6 +90,12 @@ local ESTABLISH_ACK = {
|
||||
---@enum DEVICE_TYPE device types for establish messages
|
||||
local DEVICE_TYPE = { PLC = 0, RTU = 1, SVR = 2, CRD = 3, PKT = 4 }
|
||||
|
||||
---@enum PROBE_ACK
|
||||
local PROBE_ACK = {
|
||||
OPEN = 0,
|
||||
CONFLICT = 1
|
||||
}
|
||||
|
||||
---@enum PLC_AUTO_ACK
|
||||
local PLC_AUTO_ACK = {
|
||||
FAIL = 0, -- failed to set burn rate/burn rate invalid
|
||||
@@ -130,6 +137,8 @@ comms.CRDN_TYPE = CRDN_TYPE
|
||||
comms.ESTABLISH_ACK = ESTABLISH_ACK
|
||||
comms.DEVICE_TYPE = DEVICE_TYPE
|
||||
|
||||
comms.PROBE_ACK = PROBE_ACK
|
||||
|
||||
comms.PLC_AUTO_ACK = PLC_AUTO_ACK
|
||||
|
||||
comms.UNIT_COMMAND = UNIT_COMMAND
|
||||
|
||||
@@ -82,7 +82,9 @@ end
|
||||
function network.nic(modem)
|
||||
local self = {
|
||||
-- modem interface name
|
||||
iface = ppm.get_iface(modem),
|
||||
iface = "?",
|
||||
-- phy name
|
||||
name = "?",
|
||||
-- used to quickly return out of tx/rx functions if there is nothing to do
|
||||
connected = true,
|
||||
-- used to avoid costly MAC calculations if not required
|
||||
@@ -94,6 +96,10 @@ function network.nic(modem)
|
||||
---@class nic:Modem
|
||||
local public = {}
|
||||
|
||||
-- get the phy name
|
||||
---@nodiscard
|
||||
function public.phy_name() return self.name end
|
||||
|
||||
-- check if this NIC has a connected modem
|
||||
---@nodiscard
|
||||
function public.is_connected() return self.connected end
|
||||
@@ -102,11 +108,14 @@ function network.nic(modem)
|
||||
---@param reconnected_modem Modem
|
||||
function public.connect(reconnected_modem)
|
||||
modem = reconnected_modem
|
||||
|
||||
self.iface = ppm.get_iface(modem)
|
||||
self.name = util.c(util.trinary(modem.isWireless(), "WLAN_PHY", "ETH_PHY"), "{", self.iface, "}")
|
||||
self.connected = true
|
||||
self.use_hash = c_eng.hmac and modem.isWireless()
|
||||
|
||||
-- open only previously opened channels
|
||||
modem.closeAll()
|
||||
|
||||
-- open previously opened channels
|
||||
for _, channel in ipairs(self.channels) do
|
||||
modem.open(channel)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user