Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
app-hotes:wifi-switcher [2023/10/31 15:02] cakirapp-hotes:wifi-switcher [2023/12/12 12:21] (current) – [Goal] cakir
Line 1: Line 1:
 ====== Wifi Switcher ====== ====== Wifi Switcher ======
  
-===== Goal ===== +===== Goal and benefit for the costumer ===== 
-In this guide we will describe how to setup the WiFi Switcher SDK script on a Netmodule router. This script will take care of automatically connecting to a WiFi Access Point when it is part of a List we defined. The list is in a seperate file and consists of SSIDs and associated Password.+In this guide we will describe how to setup the WiFi Switcher SDK script on a Netmodule router. This script will take care of automatically connecting to a WiFi Access Point when it is part of a list we defined. The list is in a seperate file and consists of SSIDs and associated Password. The benefit is that only these known access points can be connected to. 
  
 ===== Application example ===== ===== Application example =====
-Background for this script is a customer who uses our routers in railway applications. The router in the train is supposed to connect to a WiFi network on each respective train station. Only WiFi access points that can be found in the list of defined networks should be used to connect to. +Background for this script is a customer who uses our routers in railway applications. The router in the train is supposed to connect to a WiFi network on each respective train station. Only WiFi access points that can be found in the list are used to connect to. 
      
 +  
 +<code c application-example>
 +TRAIN        TRAIN        TRAIN          TRAIN
 +STATION A    STATION B    STATION C      STATION X
 ++--------+   +--------+   +--------+     +--------+
 +|WIFI AP1|   |WIFI AP2|   |WIFI AP3|     |WIFI APX|
 +|        |          |          |            |
 ++--------+   +--------+   +--------+ ... +--------+
 +
 +     TRAIN WIFI CLIENT
 +        +--------+
 ++---------------------------------------------->
 +</code>
 +
 ===== Setup ===== ===== Setup =====
-Here we will describe step-by-step how to setup the router with the wifi switcher funktionality.+Here we will describe step-by-step how to setup the router with the wifi switcher functionality.
  
 ==== WAN in Link Manager ==== ==== WAN in Link Manager ====
-First we need to pay attention that, after setting up our WiFi client, the WLAN1 is supposed to be in position 2 in the link manager. This is neccessary so that the script queries the correct interface for it's status. The order of WAN interfaces can be changed under INTERFACES -> WAN -> Link Management. WLAN1 should be set to permanent.+First we need to make sure that, after setting up our WiFi client, WLAN1 is supposed to be in position 2 in link manager. This is neccessary so that the script queries the correct interface for it's status. The order of WAN interfaces can be changed under "INTERFACES -> WAN -> Link Management"Also we set WLAN1 to permanent.
  
 {{:app-notes:setup-wan.png}} {{:app-notes:setup-wan.png}}
  
-=== Setup Trigger === +==== Setup Trigger ==== 
-Here we setup a trigger that will start our SDK script later on. Since the script is supposed to run at all times we will set our trigger to event-based -> sdk-startup. As soon as SDK is enabled our wifi switcher script will be running. +Here we setup a trigger that will start our SDK script later on. Since the script is supposed to run at all times we will set our trigger to "event-based -> sdk-startup". As soon as SDK is enabled our wifi switcher script will be running. 
  
 {{:app-notes:triggers.png}} {{:app-notes:triggers.png}}
Line 30: Line 45:
 {{:app-notes:jobs.png}} {{:app-notes:jobs.png}}
  
-==== Setup Wifi Networks List ==== +==== Setup WiFi Networks List ==== 
-Unlike the wifi-switcher script the list of allowed wifi networks does not need to be connected with a job or trigger. It just needts to be available on the device. The reason why we use the GUI to insert this list is update security and also having this file be part of the router config. This wold not be the case when we simply just copy it by hand.+Unlike the wifi-switcher script the list of allowed wifi access points does not need to be connected with a job or trigger. It just needts to be available on the device. The reason why we use the GUI to insert this list is update security and also having this file be part of the router config. This would not be the case when we simply just copy it by hand.
  
-It is important to use the correct name "wifi-networks.cfg" for this file, otherwise the wifi switcher script will not be able to find it. So just get the list example (can be found at the end of this guide) and adjust SSIDs and passwords to your scenario. The list is not limited to 7 entrys, it is possible to put a arbitary number of SSIDs to the file.+It is important to use the correct name "wifi-networks.cfg" for this file, otherwise the WiFi Switcher script will not be able to find it. So just get the list example (can be found at the end of this guide) and adjust SSIDs and passwords to your scenario. The list is not limited to 7 entrys, it is possible to insert an arbitary number of SSIDs to the file.
  
 {{:app-notes:networks.png}} {{:app-notes:networks.png}}
Line 44: Line 59:
  
 ==== wifi-switcher.are ==== ==== wifi-switcher.are ====
-Hier eine kurze Erklärung wie das Script funktioniert.+Here is a short description of the funtionality of the script.
  
-DEBUG kann optional auf gesetzt werden um Output im tail-log zu erhalten.+You have the option to set DEBUG=1, this will give you some debug output visible in tail-log.
  
-Das Script fragt in der while Schleife immer wieder den status vom WLAN Uplink (WANLINK2) ab. +First the scirpt will import the list of access points it is supposed to connect to. Then the scirpt will keep on looking up the state of the WiFi (WLAN1 which is setup as WANLINK2).
-Wenn hier "dialing" oder "up" zurück gegeben wird machen wir nichts, warten 5 Sekunden und fragen nochmal.+
  
-Falls das WLAN down sein sollte und bereits mehr als 30 Sekunden seit dem letzten Scan vergangen sind machen wir jetzt einen neuen Scan der uns die aktuell sichtbaren WLAN NEtzwerke liefern wird.+In case of the state being "dialing" or "up" we do nothing and wait for 5 seconds before we check this status again. In caste the state is "down" and the last scan is at least 30 seconds in the past we trigger a new scan of the currently available Wifi networkss
  
-Nachdem der Scan abgeschlossen holen wir und die Daten der Access Points und schauen in der Liste nach ob dort dieser AP vorhanden istFalls ja wird das WLAN umkonfiguriert jedoch nur wenn mehr als 120 Sekunden seit der letzten konfiguration vergangen sind.+After the scan is finished we take the data and compare it to the list we imported earlierWhen a known access point is found and the last WiFi config update is at least 120 seconds in the past, we update the wifi config so we can connect to the now available WiFi AP.
  
 <code c wifi-switcher.are> <code c wifi-switcher.are>