#200 work on pocket comms for unit data
This commit is contained in:
@@ -470,10 +470,11 @@ function coordinator.comms(version, nic, sv_watchdog)
|
||||
elseif packet.type == MGMT_TYPE.ESTABLISH then
|
||||
-- establish a new session
|
||||
-- validate packet and continue
|
||||
if packet.length == 3 and type(packet.data[1]) == "string" and type(packet.data[2]) == "string" then
|
||||
local comms_v = packet.data[1]
|
||||
local firmware_v = packet.data[2]
|
||||
if packet.length == 4 then
|
||||
local comms_v = util.strval(packet.data[1])
|
||||
local firmware_v = util.strval(packet.data[2])
|
||||
local dev_type = packet.data[3]
|
||||
local api_v = util.strval(packet.data[4])
|
||||
|
||||
if comms_v ~= comms.version then
|
||||
if self.last_api_est_acks[src_addr] ~= ESTABLISH_ACK.BAD_VERSION then
|
||||
@@ -481,6 +482,12 @@ function coordinator.comms(version, nic, sv_watchdog)
|
||||
end
|
||||
|
||||
_send_api_establish_ack(packet.scada_frame, ESTABLISH_ACK.BAD_VERSION)
|
||||
elseif api_v ~= comms.api_version then
|
||||
if self.last_api_est_acks[src_addr] ~= ESTABLISH_ACK.BAD_API_VERSION then
|
||||
log.info(util.c("dropping API establish packet with incorrect api version v", comms_v, " (expected v", comms.version, ")"))
|
||||
end
|
||||
|
||||
_send_api_establish_ack(packet.scada_frame, ESTABLISH_ACK.BAD_API_VERSION)
|
||||
elseif dev_type == DEVICE_TYPE.PKT then
|
||||
-- pocket linking request
|
||||
local id = apisessions.establish_session(src_addr, firmware_v)
|
||||
|
||||
@@ -126,19 +126,15 @@ function pocket.new_session(id, s_addr, in_queue, out_queue, timeout)
|
||||
if pkt.type == CRDN_TYPE.API_GET_FAC then
|
||||
local fac = db.facility
|
||||
|
||||
---@class api_fac
|
||||
local data = {
|
||||
num_units = fac.num_units,
|
||||
num_tanks = util.table_len(fac.tank_data_tbl),
|
||||
tank_mode = fac.tank_mode,
|
||||
tank_defs = fac.tank_defs,
|
||||
sys_ok = fac.all_sys_ok,
|
||||
rtu_count = fac.rtu_count,
|
||||
radiation = fac.radiation,
|
||||
auto = { fac.auto_ready, fac.auto_active, fac.auto_ramping, fac.auto_saturated },
|
||||
waste = { fac.auto_current_waste_product, fac.auto_pu_fallback_active },
|
||||
has_matrix = fac.induction_data_tbl[1] ~= nil,
|
||||
has_sps = fac.sps_data_tbl[1] ~= nil,
|
||||
fac.all_sys_ok,
|
||||
fac.rtu_count,
|
||||
fac.radiation,
|
||||
{ fac.auto_ready, fac.auto_active, fac.auto_ramping, fac.auto_saturated },
|
||||
{ fac.auto_current_waste_product, fac.auto_pu_fallback_active },
|
||||
util.table_len(fac.tank_data_tbl),
|
||||
fac.induction_data_tbl[1] ~= nil,
|
||||
fac.sps_data_tbl[1] ~= nil,
|
||||
}
|
||||
|
||||
_send(CRDN_TYPE.API_GET_FAC, data)
|
||||
|
||||
Reference in New Issue
Block a user