Skip to content

Commit 75518ff

Browse files
Release 2.3.0 (#6)
# Release 2.3.0 ## New features - Feature to bridge ETH ports ## Improvements - Better handling of persistent data ## Bugfix - Configured DNS server were not loaded
1 parent ca8f49a commit 75518ff

12 files changed

Lines changed: 1705 additions & 327 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## Release 2.3.0
5+
6+
### New features
7+
- Feature to bridge ETH ports
8+
9+
### Improvements
10+
- Better handling of persistent data
11+
12+
### Bugfix
13+
- Configured DNS server were not loaded
14+
415
## Release 2.2.2
516

617
### Improvements

CSK_Module_DeviceNetworkConfig/pages/pages/CSK_Module_DeviceNetworkConfig/CSK_Module_DeviceNetworkConfig.html

Lines changed: 254 additions & 35 deletions
Large diffs are not rendered by default.

CSK_Module_DeviceNetworkConfig/pages/src/converter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
export function convertToList(value) {
2+
return JSON.parse(value)
3+
}
4+
15
export function InvalidUpstreamIPv4Display(inState) {
26
const status = document.getElementById('UpstreamIPv4Error')
37
if ( status ) {

CSK_Module_DeviceNetworkConfig/project.mf.xml

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,42 @@ See following descriptions of events/functions regarding further information.
136136
<desc>Notify if module can not be used to set configuration (some devices only show current config).</desc>
137137
<param desc="Status" multiplicity="1" name="status" type="bool"/>
138138
</event>
139+
<event name="OnNewStatusShowBridgeFeature">
140+
<desc>Notify status to show bridge feature.</desc>
141+
<param desc="Status" multiplicity="1" name="status" type="bool"/>
142+
</event>
143+
<event name="OnNewStatusBridgeIP">
144+
<desc>Notify IP to use for bridge.</desc>
145+
<param desc="IP" multiplicity="1" name="ip" type="string"/>
146+
</event>
147+
<event name="OnNewStatusBridgeSubnetMask">
148+
<desc>Notify subnet mask to use for bridge.</desc>
149+
<param desc="Subnet mask." multiplicity="1" name="mask" type="string"/>
150+
</event>
151+
<event name="OnNewStatusBridgeGateway">
152+
<desc>Notify gateway to use for bridge.</desc>
153+
<param desc="Gateway" multiplicity="1" name="gateway" type="string"/>
154+
</event>
155+
<event name="OnNewStatusBridgeDelay">
156+
<desc>Notify delay in seconds to wait before activating bridge after restart.</desc>
157+
<param desc="Delay in seconds." multiplicity="1" name="delay" type="int"/>
158+
</event>
159+
<event name="OnNewStatusBridgeTestTime">
160+
<desc>Notify time in minutes to reset bridge. Useful to test bridge setup without losing the access to the device.</desc>
161+
<param desc="Time in minutes to wait before clearing the bridge." multiplicity="1" name="time" type="int"/>
162+
</event>
163+
<event name="OnNewStatusBridgeActive">
164+
<desc>Notify status if bridge is active.</desc>
165+
<param desc="Status" multiplicity="1" name="status" type="bool"/>
166+
</event>
167+
<event name="OnNewStatusBridgeInterfaces">
168+
<desc>Notify list of ethernet interfaces to use for bridge.</desc>
169+
<param desc="List of interfaces." multiplicity="1" name="list" type="string"/>
170+
</event>
171+
<event name="OnNewStatusListOfEthernetInterfaces">
172+
<desc>Notify list of available ethernet interfaces.</desc>
173+
<param desc="List of interfaces." multiplicity="1" name="list" type="string"/>
174+
</event>
139175
<function name="pageCalled">
140176
<desc>Function to register "OnResume" of the module UI (only as helper function).</desc>
141177
<return desc="Empty string (only needed to simplify binding)." multiplicity="1" name="empty" type="string"/>
@@ -228,10 +264,42 @@ See following descriptions of events/functions regarding further information.
228264
<desc>Function to get status if module is active.</desc>
229265
<return desc="Status" multiplicity="1" name="status" type="bool"/>
230266
</function>
267+
<function name="setShowBridgeFeature">
268+
<desc>Function so set status to show bridge feature.</desc>
269+
<param desc="Status" multiplicity="1" name="status" type="bool"/>
270+
</function>
271+
<function name="setBridgeIP">
272+
<desc>Function to set IP of bridge.</desc>
273+
<param desc="IP" multiplicity="1" name="ip" type="string"/>
274+
</function>
275+
<function name="setBridgeSubnetMask">
276+
<desc>Function to set subnet mask of bridge.</desc>
277+
<param desc="Subnet mask" multiplicity="1" name="mask" type="string"/>
278+
</function>
279+
<function name="setBridgeGateway">
280+
<desc>Function to set gateway of bridge.</desc>
281+
<param desc="Gateway" multiplicity="1" name="gateway" type="string"/>
282+
</function>
283+
<function name="setBridgeActive">
284+
<desc>Function to set status of bridge,</desc>
285+
<param desc="Status" multiplicity="1" name="status" type="bool"/>
286+
</function>
287+
<function name="setBridgeInterfaces">
288+
<desc>Function to set interfaces to use for bridge.</desc>
289+
<param desc="Interfaces" multiplicity="+" name="interfaces" type="string"/>
290+
</function>
291+
<function name="setBridgeDelay">
292+
<desc>Function to set delay to wait before activating bridge after restart.</desc>
293+
<param desc="Delay in seconds." multiplicity="1" name="delay" type="int"/>
294+
</function>
295+
<function name="setBridgeTestTime">
296+
<desc>Function to set time to reset bridge. This helps to test the bridge setup.</desc>
297+
<param desc="Time in minutes to wait before deleting the bridge. Set to 0 to keep bridge." multiplicity="1" name="time" type="int"/>
298+
</function>
231299
</serves>
232300
</crown>
233301
<meta key="author">SICK AG</meta>
234-
<meta key="version">2.2.2</meta>
302+
<meta key="version">2.3.0</meta>
235303
<meta key="priority">low</meta>
236304
<meta key="copy-protected">false</meta>
237305
<meta key="read-protected">false</meta>

CSK_Module_DeviceNetworkConfig/scripts/Configuration/DeviceNetworkConfig/DeviceNetworkConfig_Controller.lua

Lines changed: 99 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ Script.serveEvent("CSK_DeviceNetworkConfig.OnNewInterfaceChoice", "DeviceNetwork
6060
Script.serveEvent("CSK_DeviceNetworkConfig.OnNewDNS", "DeviceNetworkConfig_OnNewDNS")
6161
Script.serveEvent("CSK_DeviceNetworkConfig.OnDNSIPError", "DeviceNetworkConfig_OnDNSIPError")
6262

63+
Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusShowBridgeFeature', 'DeviceNetworkConfig_OnNewStatusShowBridgeFeature')
64+
65+
Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusBridgeIP', 'DeviceNetworkConfig_OnNewStatusBridgeIP')
66+
Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusBridgeSubnetMask', 'DeviceNetworkConfig_OnNewStatusBridgeSubnetMask')
67+
Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusBridgeGateway', 'DeviceNetworkConfig_OnNewStatusBridgeGateway')
68+
Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusBridgeActive', 'DeviceNetworkConfig_OnNewStatusBridgeActive')
69+
Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusListOfEthernetInterfaces', 'DeviceNetworkConfig_OnNewStatusListOfEthernetInterfaces')
70+
Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusBridgeInterfaces', 'DeviceNetworkConfig_OnNewStatusBridgeInterfaces')
71+
72+
Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusBridgeDelay', 'DeviceNetworkConfig_OnNewStatusBridgeDelay')
73+
Script.serveEvent('CSK_DeviceNetworkConfig.OnNewStatusBridgeTestTime', 'DeviceNetworkConfig_OnNewStatusBridgeTestTime')
74+
6375
Script.serveEvent("CSK_DeviceNetworkConfig.OnUserLevelOperatorActive", "DeviceNetworkConfig_OnUserLevelOperatorActive")
6476
Script.serveEvent("CSK_DeviceNetworkConfig.OnUserLevelMaintenanceActive", "DeviceNetworkConfig_OnUserLevelMaintenanceActive")
6577
Script.serveEvent("CSK_DeviceNetworkConfig.OnUserLevelServiceActive", "DeviceNetworkConfig_OnUserLevelServiceActive")
@@ -153,7 +165,7 @@ end
153165

154166
local function refresh()
155167
interfacesTable = deviceNetworkConfig_Model.refreshInterfaces()
156-
jsonInterfaceListContent = deviceNetworkConfig_Model.helperFuncs.createJsonList(interfacesTable, selectedInterfaceName)
168+
jsonInterfaceListContent = deviceNetworkConfig_Model.helperFuncs.createSpecificJsonList(interfacesTable, selectedInterfaceName)
157169
Script.notifyEvent("DeviceNetworkConfig_OnNewInterfaceTable", jsonInterfaceListContent)
158170
checkWhatToDisable()
159171
end
@@ -352,7 +364,20 @@ local function handleOnExpiredTmrDeviceNetworkConfig()
352364
Script.notifyEvent("DeviceNetworkConfig_OnNewDefaultGateway", '-')
353365
Script.notifyEvent("DeviceNetworkConfig_OnNewInterfaceChoice",'-')
354366
Script.notifyEvent("DeviceNetworkConfig_OnNewEthernetConfigStatus", 'empty')
355-
367+
368+
Script.notifyEvent("DeviceNetworkConfig_OnNewStatusShowBridgeFeature", deviceNetworkConfig_Model.showBridgeFeature)
369+
370+
Script.notifyEvent("DeviceNetworkConfig_OnNewStatusBridgeIP", deviceNetworkConfig_Model.parameters.bridgeIP)
371+
Script.notifyEvent("DeviceNetworkConfig_OnNewStatusBridgeSubnetMask", deviceNetworkConfig_Model.parameters.bridgeSubnetMask)
372+
Script.notifyEvent("DeviceNetworkConfig_OnNewStatusBridgeGateway", deviceNetworkConfig_Model.parameters.bridgeGateway)
373+
Script.notifyEvent("DeviceNetworkConfig_OnNewStatusBridgeActive", deviceNetworkConfig_Model.parameters.bridgeActive)
374+
375+
Script.notifyEvent("DeviceNetworkConfig_OnNewStatusListOfEthernetInterfaces", deviceNetworkConfig_Model.helperFuncs.createJsonList(deviceNetworkConfig_Model.listOfInterfaces))
376+
Script.notifyEvent("DeviceNetworkConfig_OnNewStatusBridgeInterfaces", deviceNetworkConfig_Model.helperFuncs.createJsonList(deviceNetworkConfig_Model.parameters.bridgeInterfaces))
377+
378+
Script.notifyEvent("DeviceNetworkConfig_OnNewStatusBridgeDelay", deviceNetworkConfig_Model.parameters.bridgeDelay)
379+
Script.notifyEvent("DeviceNetworkConfig_OnNewStatusBridgeTestTime", deviceNetworkConfig_Model.parameters.bridgeTestTime)
380+
356381
local dnsList = deviceNetworkConfig_Model.helperFuncs.json.encode(getNameserverList())
357382
if dnsList == '[]' or dnsList == '' then
358383
dnsList = '[{"dns":"-"}]'
@@ -449,7 +474,7 @@ local function selectInterface(row_selected)
449474
Script.notifyEvent("DeviceNetworkConfig_OnGatewayDisabled", true)
450475
end
451476
Script.sleep(100)
452-
jsonInterfaceListContent = deviceNetworkConfig_Model.helperFuncs.createJsonList(interfacesTable, selectedInterfaceName)
477+
jsonInterfaceListContent = deviceNetworkConfig_Model.helperFuncs.createSpecificJsonList(interfacesTable, selectedInterfaceName)
453478
Script.notifyEvent("DeviceNetworkConfig_OnNewInterfaceTable", jsonInterfaceListContent)
454479
checkWhatToDisable()
455480
end
@@ -502,6 +527,65 @@ local function setDHCPState(newDHCPState)
502527
end
503528
Script.serveFunction("CSK_DeviceNetworkConfig.setDHCPState", setDHCPState)
504529

530+
local function setShowBridgeFeature(status)
531+
if _G.availableAPIs.bridge then
532+
deviceNetworkConfig_Model.showBridgeFeature = status
533+
Script.notifyEvent("DeviceNetworkConfig_OnNewStatusShowBridgeFeature", status)
534+
else
535+
_G.logger:info(nameOfModule .. ": Bridge feature not supported on device.")
536+
Script.notifyEvent("DeviceNetworkConfig_OnNewStatusShowBridgeFeature", false)
537+
end
538+
end
539+
Script.serveFunction('CSK_DeviceNetworkConfig.setShowBridgeFeature', setShowBridgeFeature)
540+
541+
local function setBridgeIP(ip)
542+
deviceNetworkConfig_Model.parameters.bridgeIP = ip
543+
end
544+
Script.serveFunction('CSK_DeviceNetworkConfig.setBridgeIP', setBridgeIP)
545+
546+
local function setBridgeSubnetMask(mask)
547+
deviceNetworkConfig_Model.parameters.bridgeSubnetMask = mask
548+
end
549+
Script.serveFunction('CSK_DeviceNetworkConfig.setBridgeSubnetMask', setBridgeSubnetMask)
550+
551+
local function setBridgeGateway(gateway)
552+
deviceNetworkConfig_Model.parameters.bridgeGateway = gateway
553+
end
554+
Script.serveFunction('CSK_DeviceNetworkConfig.setBridgeGateway', setBridgeGateway)
555+
556+
local function setBridgeActive(status)
557+
if _G.availableAPIs.bridge then
558+
deviceNetworkConfig_Model.parameters.bridgeActive = status
559+
560+
if status then
561+
deviceNetworkConfig_Model.createBridge()
562+
else
563+
deviceNetworkConfig_Model.deleteBridge()
564+
end
565+
else
566+
_G.logger:info(nameOfModule .. ": Bridge feature not supported on device.")
567+
end
568+
end
569+
Script.serveFunction('CSK_DeviceNetworkConfig.setBridgeActive', setBridgeActive)
570+
571+
local function setBridgeInterfaces(interfaces)
572+
deviceNetworkConfig_Model.parameters.bridgeInterfaces = {}
573+
for _, value in pairs(interfaces) do
574+
table.insert(deviceNetworkConfig_Model.parameters.bridgeInterfaces, value)
575+
end
576+
end
577+
Script.serveFunction('CSK_DeviceNetworkConfig.setBridgeInterfaces', setBridgeInterfaces)
578+
579+
local function setBridgeDelay(delay)
580+
deviceNetworkConfig_Model.parameters.bridgeDelay = delay
581+
end
582+
Script.serveFunction('CSK_DeviceNetworkConfig.setBridgeDelay', setBridgeDelay)
583+
584+
local function setBridgeTestTime(time)
585+
deviceNetworkConfig_Model.parameters.bridgeTestTime = time
586+
end
587+
Script.serveFunction('CSK_DeviceNetworkConfig.setBridgeTestTime', setBridgeTestTime)
588+
505589
local function setPingIPAddress(ping_ip)
506590
deviceNetworkConfig_Model.ping_ip_adress = ping_ip
507591
end
@@ -589,12 +673,24 @@ local function loadParameters()
589673
if data then
590674
_G.logger:info(nameOfModule .. ": Loaded parameters from CSK_PersistentData module.")
591675
deviceNetworkConfig_Model.parameters = deviceNetworkConfig_Model.helperFuncs.convertContainer2Table(data)
676+
deviceNetworkConfig_Model.parameters = deviceNetworkConfig_Model.helperFuncs.checkParameters(deviceNetworkConfig_Model.parameters, deviceNetworkConfig_Model.helperFuncs.defaultParameters.getParameters())
592677

593678
-- Load nameservers
594679
if deviceNetworkConfig_Model.deviceType ~= 'AppEngine' then
595680
updateNameservers(deviceNetworkConfig_Model.parameters.nameservers)
596681
end
597682

683+
if _G.availableAPIs.bridge and deviceNetworkConfig_Model.parameters.bridgeActive then
684+
deviceNetworkConfig_Model.showBridgeFeature = true
685+
if deviceNetworkConfig_Model.parameters.bridgeDelay ~= 0 then
686+
deviceNetworkConfig_Model.bridgeDelayTimer:setExpirationTime(deviceNetworkConfig_Model.parameters.bridgeDelay*1000)
687+
deviceNetworkConfig_Model.bridgeDelayTimer:start()
688+
_G.logger:info(nameOfModule .. ": Start timer for bridge delay")
689+
else
690+
deviceNetworkConfig_Model.createBridge()
691+
end
692+
end
693+
598694
CSK_DeviceNetworkConfig.pageCalled()
599695
return true
600696
else
@@ -630,10 +726,6 @@ local function handleOnInitialDataLoaded()
630726

631727
if parameterName then
632728
deviceNetworkConfig_Model.parametersName = parameterName
633-
deviceNetworkConfig_Model.parameterLoadOnReboot = loadOnReboot
634-
end
635-
636-
if deviceNetworkConfig_Model.parameterLoadOnReboot then
637729
loadParameters()
638730
end
639731
Script.notifyEvent('DeviceNetworkConfig_OnDataLoadedOnReboot')

0 commit comments

Comments
 (0)