From d7ace14b09f7eefa3ed22ecb71e69483f4518707 Mon Sep 17 00:00:00 2001 From: Mika Joenpera Date: Wed, 11 Oct 2023 11:06:45 +0300 Subject: [PATCH] Add phy/network name handling and more index usage Jira-Id: SCDI-43 Signed-off-by: Mika Joenpera --- common/scripts/mesh-11s-mr.sh | 347 ------------------ common/scripts/mesh-11s_nats.sh | 29 +- common/scripts/mesh-helper.sh | 11 +- .../src/nats/initd/S9011sNatsMesh | 6 +- .../src/nats/initd/S90APoint | 12 +- .../src/nats/scripts/cli_settings_apply.py | 2 +- .../src/nats/scripts/config.py | 4 +- .../src/nats/scripts/identity.py | 1 + .../src/nats/src/comms_common.py | 46 +-- .../src/nats/src/comms_status.py | 105 +++--- 10 files changed, 124 insertions(+), 439 deletions(-) delete mode 100755 common/scripts/mesh-11s-mr.sh create mode 100644 modules/sc-mesh-secure-deployment/src/nats/scripts/identity.py diff --git a/common/scripts/mesh-11s-mr.sh b/common/scripts/mesh-11s-mr.sh deleted file mode 100755 index 8bd1d9f9e..000000000 --- a/common/scripts/mesh-11s-mr.sh +++ /dev/null @@ -1,347 +0,0 @@ -#!/bin/bash - -function help -{ - echo - cat << EOF -Usage: sudo ./mesh_11s-mr.sh [] []" -Parameters: - - - - - - - - - - - optional - - optional - -example: - For One Radio: - sudo ./mesh-11s-mr.sh mesh 192.168.1.2 255.255.255.0 00:11:22:33:44:55 1234567890 mymesh2 5220 30 fi wlan1 phy1 - Automatic detection: - sudo ./mesh-11s-mr.sh mesh 192.168.1.2 255.255.255.0 00:11:22:33:44:55 1234567890 mymesh2 5220 30 fi - Create simple AP for debug purposes: - sudo ./mesh-11s-mr.sh ap - Turn all radios off: - sudo ./mesh-11s-mr.sh off -EOF - exit -} - -find_mesh_wifi_device() -{ - # arguments: - # $1 = bus (usb, pci, sdio..) - # $2 = wifi device vendor - # $3 = wifi device id list - - # return values: device_list - # format example = "phy0,wlp1s0 phy1,wlp2s0 phy2,wlp3s0" - - device_list="" - - echo "## Searching WIFI card: bus=$1 deviceVendor=$2 deviceID=$3" - - case "$1" in - pci) - # tested only with Qualcomm cards - phynames=$(ls /sys/class/ieee80211/) - for device in $3; do - for phy in $phynames; do - device_id="$(cat /sys/bus/pci/devices/*/ieee80211/"$phy"/device/device 2>/dev/null)" - device_vendor="$(cat /sys/bus/pci/devices/*/ieee80211/"$phy"/device/vendor 2>/dev/null)" - if [ "$device_id" = "$device" ] && [ "$device_vendor" = "$2" ]; then - retval_phy=$phy - retval_name=$(ls /sys/class/ieee80211/"$phy"/device/net/) - # add "phy,name" pair to device_list (space as separator for pairs) - device_list="$device_list$retval_phy,$retval_name " - fi - done - done - ;; - usb) - device_list="" - ;; - sdio) - device_list="" - ;; - esac -} - -create_meshpoint() -{ - # parameters: - # 1 2 3 4 5 6 7 8 9 10 11 - # - - echo "create_meshpoint $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}" - if [[ -z "$1" || -z "$2" || -z "$3" || -z "$4" || -z "$5" || -z "$6" ]] - then - echo "check arguments..." - help - fi - -cat </var/run/wpa_supplicant-11s_"${10}".conf -ctrl_interface=DIR=/var/run/wpa_supplicant -# use 'ap_scan=2' on all devices connected to the network -# this is unnecessary if you only want the network to be created when no other networks.. -ap_scan=1 -country=$9 -p2p_disabled=1 -#autoscan=periodic:10 -#bgscan="simple:30:-45:300" -network={ - ssid="$6" - bssid=$4 - mode=5 - frequency=$7 - psk="$5" - key_mgmt=SAE - mesh_fwding=0 - ieee80211w=2 -} -EOF - - echo "Killing wpa_supplicant for ${10}..." - pkill -f "/var/run/wpa_supplicant-11s_${10}" 2>/dev/null - rm -fr /var/run/wpa_supplicant/"${10}" - - - killall alfred 2>/dev/null - killall batadv-vis 2>/dev/null - rm -f /var/run/alfred.sock - - modprobe batman-adv - - echo "$wifidev down.." - iw dev "${10}" del - iw phy "${11}" interface add "${10}" type mp - - echo "${10} create 11s.." - ifconfig "${10}" mtu 1560 - - echo "${10} up.." - ip link set "${10}" up - batctl if add "${10}" - - echo "bat0 up.." - ifconfig bat0 up - echo "bat0 ip address.." - ifconfig bat0 "$2" netmask "$3" - echo - ifconfig bat0 - - sleep 3 - - # for visualisation - (alfred -i bat0 -m)& - echo "started alfred" - (batadv-vis -i bat0 -s)& - echo "started batadv-vis" - - wpa_supplicant -i "${10}" -c /var/run/wpa_supplicant-11s_"${10}".conf -D nl80211 -C /var/run/wpa_supplicant/ -B -} - -create_ap() -{ - # parameters: - # 1 2 3 4 5 6 7 8 9 10 11 - # - - if [[ -z "$1" ]] - then - echo "check arguments..." - help - fi - - # find ap parameters from enclave - if [ -z "$DRONE_DEVICE_ID" ] - then - echo "DRONE_DEVICE_ID not available" - -cat </var/run/wpa_supplicant-ap_"${10}".conf -ctrl_interface=DIR=/var/run/wpa_supplicant -ap_scan=1 -p2p_disabled=1 -network={ - ssid="debug-hotspot" - mode=2 - frequency=5220 - key_mgmt=WPA-PSK - psk="1234567890" - pairwise=CCMP - group=CCMP - proto=RSN -} -EOF - else - echo "DRONE_DEVICE_ID available" - -cat </var/run/wpa_supplicant-ap_"${10}".conf -ctrl_interface=DIR=/var/run/wpa_supplicant -ap_scan=1 -p2p_disabled=1 -network={ - ssid="$DRONE_DEVICE_ID" - mode=2 - frequency=5220 - key_mgmt=WPA-PSK - psk="1234567890" - pairwise=CCMP - group=CCMP - proto=RSN -} -EOF - - fi - - echo "Killing wpa_supplicant ${10}..." - pkill -f "/var/run/wpa_supplicant-*_${10}" 2>/dev/null - rm -fr /var/run/wpa_supplicant/"${10}" - - echo "create $wifidev" - iw dev "${10}" del - iw phy "${11}" interface add "${10}" type managed - - echo "$wifidev up.." - ip link set "${10}" up - batctl if add "${10}" - - echo "set ip address.." - # set AP ipaddr - ifconfig "${10}" 192.168.1.1 netmask 255.255.255.0 - - # set bat0 ipaddr - if [ -z "$DRONE_DEVICE_ID" ] - then - # DRONE_DEVICE_ID not available set default - ifconfig bat0 192.168.1.1 netmask 255.255.255.0 - else - declare -i ip - ip=10#$(echo "$DRONE_DEVICE_ID" | tr -d -c 0-9) - ifconfig bat0 192.168.1."$ip" netmask 255.255.255.0 - fi - - echo "bat0 up.." - ifconfig bat0 up - echo - ifconfig bat0 - - route del -net 192.168.1.0 netmask 255.255.255.0 dev bat0 - route add -net 192.168.1.0 netmask 255.255.255.0 dev bat0 metric 1 - - # TODO DHCP server? - # dhserver - - wpa_supplicant -B -i "${10}" -c /var/run/wpa_supplicant-ap_"${10}".conf -D nl80211 -C /var/run/wpa_supplicant/ -} - -off() -{ - # parameters: - # 1 2 3 4 5 6 7 8 9 10 11 - # - - # kills all mesh script started wpa_supplicant processes (ap/mesh) - pkill -f "/var/run/wpa_supplicant-" 2>/dev/null - rm -fr /var/run/wpa_supplicant/"${10}" - killall alfred 2>/dev/null - killall batadv-vis 2>/dev/null - rm -f /var/run/alfred.sock 2>/dev/null -} - -init_device() -{ - # parameters: - # 1 2 3 4 5 6 7 8 9 10 11 - # - - echo "- init_device $1" - echo - - case "$1" in - mesh) - create_meshpoint "$@" - ;; - ap) - create_ap "$@" - ;; - off) - # stop all processes which were started - off "$@" - ;; - *) - help - ;; - esac -} - -### MAIN ### -main () -{ - # parameters - # 1 2 3 4 5 6 7 8 9 10 11 - # - - if [[ -z "$1" ]]; then - help - exit - fi - - echo "Solving wifi device name and phy name.." - echo - #---------------- - - count=0 - - rfkill unblock all - - if [[ -z "${10}" ]]; then - # multiple wifi options --> can be detected as follows: - # manufacturer 0x168c = Qualcomm - # devices = 0x0034 0x003c 9462/988x 11s - # 0x003e 6174 adhoc - list="0x0034 0x003c 0x003e" - for dev in $list; do - find_mesh_wifi_device "pci" 0x168c "$dev" - - if [ "$device_list" != "" ]; then - for pair in $device_list; do - phyname=$(echo "$pair" | cut -f1 -d ',') - wifidev=$(echo "$pair" | cut -f2 -d ',') - - echo " --------------------------------------------------------" - - count=$((count+1)) - echo "- #$count Found: $wifidev $phyname" - - if [ "$count" -gt 1 ]; then - # ACS - Automatic Channel Selection, not yet working for wpa/ap - # TODO Hardcoded frequency used - init_device "$1" "$2" "$3" "$4" "$5" "$6" "2412" "$8" "$9" "$wifidev" "$phyname" - else - init_device "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "$wifidev" "$phyname" - fi - - if [ "$1" = "ap" ]; then - # only one AP is initialised - exit 0 - fi - done - else - echo "- Not Found: 0x168c $dev - (not installed)" - fi - echo - done - else - wifidev=${10} - phyname=${11} - init_device "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "${10}" "${11}" - fi -} - -main "$@" - diff --git a/common/scripts/mesh-11s_nats.sh b/common/scripts/mesh-11s_nats.sh index be78a5c71..c0a8e3bdb 100755 --- a/common/scripts/mesh-11s_nats.sh +++ b/common/scripts/mesh-11s_nats.sh @@ -109,6 +109,26 @@ calculate_wifi_channel() { fi } +find_phy_interface() { + # Argument: + # $1 = Wi-Fi interface name + + # Return value: retval_phy as global + + echo "Find PHY interface for Wi-Fi interface: $1" + echo + phy_names=$(ls /sys/class/ieee80211/) + + for phy in $phy_names; do + if [ -d "/sys/class/ieee80211/$phy/device/net/$1" ]; then + retval_phy=$phy + break + else + retval_phy="" + fi + done +} + mode_execute() { # parameters: # $1 = mode @@ -440,7 +460,7 @@ main () { source /opt/mesh-helper.sh # sources mesh configuration - source_configuration + source_configuration "${2:2}" # Modes: mesh, ap+mesh_scc, ap+mesh_mcc, halow # mesh 1.0 with NATS communication setup @@ -516,8 +536,11 @@ main () { _mesh_vif="${INDEX}_MESH_VIF" wifidev="${!_mesh_vif}" - _phy="${INDEX}_PHY" - phyname="${!_phy}" + #_phy="${INDEX}_PHY" + #phyname="${!_phy}" + + find_phy_interface "$wifidev" + phyname=$retval_phy _priority="${INDEX}_PRIORITY" priority="${!_priority}" diff --git a/common/scripts/mesh-helper.sh b/common/scripts/mesh-helper.sh index 8ff10cecf..53b2aa63b 100644 --- a/common/scripts/mesh-helper.sh +++ b/common/scripts/mesh-helper.sh @@ -64,12 +64,15 @@ EOF } source_configuration() { - if [ -f "/opt/mesh.conf" ]; then + # $1: index of the mesh.conf file to be used + + if [ -f "/opt/${1}_mesh.conf" ]; then # Calculate hash for mesh.conf file - hash=$(sha256sum /opt/mesh.conf | awk '{print $1}') + hash=$(sha256sum /opt/"${1}"_mesh.conf | awk '{print $1}') # Compare calculated hash with the one created when setting has been applied - if diff <(printf %s "$hash") /opt/mesh.conf_hash; then - source /opt/mesh.conf + if diff <(printf %s "$hash") /opt/"${1}"_mesh.conf_hash; then + # shellcheck disable=SC1090 + source /opt/"${1}"_mesh.conf else # Revert to default mesh if [ -f "/opt/mesh_default.conf" ]; then diff --git a/modules/sc-mesh-secure-deployment/src/nats/initd/S9011sNatsMesh b/modules/sc-mesh-secure-deployment/src/nats/initd/S9011sNatsMesh index 0ce2b3f8b..52b08df6d 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/initd/S9011sNatsMesh +++ b/modules/sc-mesh-secure-deployment/src/nats/initd/S9011sNatsMesh @@ -12,9 +12,11 @@ source /opt/mesh-helper.sh # sources mesh configuration -source_configuration -RADIO_INDEX=$2 +RADIO_INDEX=$2 # $1: index of the mesh.conf file to be used e.g. "id0" + +source_configuration "${RADIO_INDEX:2}" + DAEMON="mesh-11s_nats.sh" DIR="/opt/" _WIFI="${RADIO_INDEX}_MESH_VIF" diff --git a/modules/sc-mesh-secure-deployment/src/nats/initd/S90APoint b/modules/sc-mesh-secure-deployment/src/nats/initd/S90APoint index d1bbd5e8b..c33da7783 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/initd/S90APoint +++ b/modules/sc-mesh-secure-deployment/src/nats/initd/S90APoint @@ -10,7 +10,13 @@ # automatically ### END INIT INFO -RADIO_INDEX=$2 +source /opt/mesh-helper.sh +# sources mesh configuration + +RADIO_INDEX=$2 # $1: index of the mesh.conf file to be used e.g. "id0" + +source_configuration "${RADIO_INDEX:2}" + DAEMON="mesh-11s_nats.sh" DIR="/opt/" _WIFI="${RADIO_INDEX}_MESH_VIF" @@ -18,10 +24,6 @@ _MODE="${RADIO_INDEX}_MODE" PIDFILE="/var/run/${DAEMON}_hostapd_${RADIO_INDEX}_${!_WIFI}.pid" LOG_FILE=/opt/mesh-11s_AP_${RADIO_INDEX}_${!_WIFI}.log -source /opt/mesh-helper.sh -# sources mesh configuration -source_configuration - # shellcheck source=/dev/null [ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" diff --git a/modules/sc-mesh-secure-deployment/src/nats/scripts/cli_settings_apply.py b/modules/sc-mesh-secure-deployment/src/nats/scripts/cli_settings_apply.py index 4bad56871..655008c9b 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/scripts/cli_settings_apply.py +++ b/modules/sc-mesh-secure-deployment/src/nats/scripts/cli_settings_apply.py @@ -8,7 +8,7 @@ async def main(): # Connect to NATS! nc = await client.connect_nats() - cmd_dict = {"api_version": 1, "cmd": "APPLY", "radio_index": "1"} + cmd_dict = {"api_version": 1, "cmd": "APPLY", "radio_index": "0"} cmd = json.dumps(cmd_dict) rep = await nc.request( f"comms.command.{config.MODULE_IDENTITY}", cmd.encode(), timeout=10 diff --git a/modules/sc-mesh-secure-deployment/src/nats/scripts/config.py b/modules/sc-mesh-secure-deployment/src/nats/scripts/config.py index db201fd58..5324e92cf 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/scripts/config.py +++ b/modules/sc-mesh-secure-deployment/src/nats/scripts/config.py @@ -8,7 +8,7 @@ print("No identity found!!!!!!!!!!!!!!!!!!!!!!!!") print("Please run _cli_command_get_identity.py to get the identity (creates identity.py)") -MODULE_IP = "10.10.10.2" # or 192.168.1.x - brlan ip address +MODULE_IP = "10.10.20.2" # or 192.168.1.x - brlan ip address MODULE_PORT = "4222" # IPv6 connection example @@ -16,4 +16,4 @@ # MODULE_PORT = "6222" MODULE_ROLE = "drone" # drone, sleeve or gcs -MODULE_IDENTITY = IDENTITY # messages are sent to this device +MODULE_IDENTITY = IDENTITY # messages are sent to this device diff --git a/modules/sc-mesh-secure-deployment/src/nats/scripts/identity.py b/modules/sc-mesh-secure-deployment/src/nats/scripts/identity.py new file mode 100644 index 000000000..2b4bfc7c4 --- /dev/null +++ b/modules/sc-mesh-secure-deployment/src/nats/scripts/identity.py @@ -0,0 +1 @@ +MODULE_IDENTITY="04f0219e6a01100000001e8cac33" diff --git a/modules/sc-mesh-secure-deployment/src/nats/src/comms_common.py b/modules/sc-mesh-secure-deployment/src/nats/src/comms_common.py index 05263727e..298603bdf 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/src/comms_common.py +++ b/modules/sc-mesh-secure-deployment/src/nats/src/comms_common.py @@ -8,33 +8,33 @@ class STATUS: # pylint: disable=too-few-public-methods """ Comms status values """ - no_status = "MESH_NO_STATUS" # no stat available - mesh_default = "MESH_DEFAULT" # mesh default settings - mesh_default_connected = "MESH_DEFAULT_CONNECTED" # mesh default connected - mesh_cfg_not_stored = "MESH_CONFIGURATION_NOT_STORED" # mesh configuration not stored - mesh_cfg_stored = "MESH_CONFIGURATION_PENDING" # new mission onfiguration stored but not active - mesh_cfg_applied = "MESH_CONFIGURATION_APPLIED" # mission mesh configuration has been applied - mesh_cfg_tampered = "MESH_CONFIGURATION_TAMPERED" # mission mesh configuration file doesn't match with hash - mesh_mission_not_connected = "MESH_MISSION_NOT_CONNECTED" # mesh mission not connected - mesh_mission_connected = "MESH_MISSION_CONNECTED" # mesh mission connected - mesh_fail = "MESH_FAIL" # fails + no_status: str = "MESH_NO_STATUS" # no stat available + mesh_default: str = "MESH_DEFAULT" # mesh default settings + mesh_default_connected: str = "MESH_DEFAULT_CONNECTED" # mesh default connected + mesh_cfg_not_stored: str = "MESH_CONFIGURATION_NOT_STORED" # mesh configuration not stored + mesh_cfg_stored: str = "MESH_CONFIGURATION_PENDING" # new mission onfiguration stored but not active + mesh_cfg_applied: str = "MESH_CONFIGURATION_APPLIED" # mission mesh configuration has been applied + mesh_cfg_tampered: str = "MESH_CONFIGURATION_TAMPERED" # mission mesh configuration file doesn't match with hash + mesh_mission_not_connected: str = "MESH_MISSION_NOT_CONNECTED" # mesh mission not connected + mesh_mission_connected: str = "MESH_MISSION_CONNECTED" # mesh mission connected + mesh_fail: str = "MESH_FAIL" # fails - security_provisioned = "SECURITY_PROVISIONED" # security provisioned - security_non_provisioned = "SECURITY_NON_PROVISIONED" # security non provisioned - security_compromised = "SECURITY_COMPROMISED" + security_provisioned: str = "SECURITY_PROVISIONED" # security provisioned + security_non_provisioned: str = "SECURITY_NON_PROVISIONED" # security non provisioned + security_compromised: str = "SECURITY_COMPROMISED" # TBD add more status class COMMAND: # pylint: disable=too-few-public-methods """ Comms control commands """ - revoke = "REVOKE" # Activate default mesh and revoke/delete mission keys - apply = "APPLY" # Take mission config into use - wifi_down = "DOWN" # Deactivate Wi-Fi transmitter - wifi_up = "UP" # Activate Wi-Fi transmitter - reboot = "REBOOT" # Reboot comms module - get_logs = "LOGS" # Command to send basic logs as response - enable_visualisation = "ENABLE_VISUALISATION" - disable_visualisation = "DISABLE_VISUALISATION" - get_config = "GET_CONFIG" - get_identity = "GET_IDENTITY" + revoke: str = "REVOKE" # Activate default mesh and revoke/delete mission keys + apply: str = "APPLY" # Take mission config into use + wifi_down: str = "DOWN" # Deactivate Wi-Fi transmitter + wifi_up: str = "UP" # Activate Wi-Fi transmitter + reboot: str = "REBOOT" # Reboot comms module + get_logs: str = "LOGS" # Command to send basic logs as response + enable_visualisation: str = "ENABLE_VISUALISATION" + disable_visualisation: str = "DISABLE_VISUALISATION" + get_config: str = "GET_CONFIG" + get_identity: str = "GET_IDENTITY" diff --git a/modules/sc-mesh-secure-deployment/src/nats/src/comms_status.py b/modules/sc-mesh-secure-deployment/src/nats/src/comms_status.py index a900f2702..ea4b86680 100644 --- a/modules/sc-mesh-secure-deployment/src/nats/src/comms_status.py +++ b/modules/sc-mesh-secure-deployment/src/nats/src/comms_status.py @@ -18,35 +18,35 @@ class WpaStatus: Maintains wpa_supplicant status """ def __init__(self): - self.interface = "" - self.bssid = "" - self.freq = "" - self.ssid = "" - self.id = "" - self.mode = "" - self.pairwise_cipher = "UNKNOWN" - self.group_cipher = "UNKNOWN" - self.key_mgmt = "UNKNOWN" - self.wpa_state = "UNKNOWN" - self.address = "" - self.uuid = "" + self.interface: str = "" + self.bssid: str = "" + self.freq: str = "" + self.ssid: str = "" + self.id: str = "" + self.mode: str = "" + self.pairwise_cipher: str = "UNKNOWN" + self.group_cipher: str = "UNKNOWN" + self.key_mgmt: str = "UNKNOWN" + self.wpa_state: str = "UNKNOWN" + self.address: str = "" + self.uuid: str = "" def reset(self): """ Reset wpa_supplicant status """ - self.interface = "" - self.bssid = "" - self.freq = "" - self.ssid = "" - self.id = "" - self.mode = "" - self.pairwise_cipher = "UNKNOWN" - self.group_cipher = "UNKNOWN" - self.key_mgmt = "UNKNOWN" - self.wpa_state = "INTERFACE_DISABLED" - self.address = "" - self.uuid = "" + self.interface: str = "" + self.bssid: str = "" + self.freq: str = "" + self.ssid: str = "" + self.id: str = "" + self.mode: str = "" + self.pairwise_cipher: str = "UNKNOWN" + self.group_cipher: str = "UNKNOWN" + self.key_mgmt: str = "UNKNOWN" + self.wpa_state: str = "INTERFACE_DISABLED" + self.address: str = "" + self.uuid: str = "" def __eq__(self, other): if isinstance(other, CommsStatus.WpaStatus): @@ -68,25 +68,25 @@ class HostapdStatus: Maintains hostapd status """ def __init__(self): - self.interface = "" - self.state = "DISABLED" - self.phy = "" - self.freq = "" - self.channel = "" - self.beacon_int = "" - self.ssid = "" + self.interface: str = "" + self.state: str = "DISABLED" + self.phy: str = "" + self.freq: str = "" + self.channel: str = "" + self.beacon_int: str = "" + self.ssid: str = "" def reset(self): """ Reset hostapd status """ - self.interface = "" - self.state = "DISABLED" - self.phy = "" - self.freq = "" - self.channel = "" - self.beacon_int = "" - self.ssid = "" + self.interface: str = "" + self.state: str = "DISABLED" + self.phy: str = "" + self.freq: str = "" + self.channel: str = "" + self.beacon_int: str = "" + self.ssid: str = "" def __eq__(self, other): if isinstance(other, CommsStatus.HostapdStatus): @@ -99,48 +99,49 @@ def __eq__(self, other): self.ssid == other.ssid return False - def __init__(self, logger): + def __init__(self, logger, index): + self.__index = index self.__lock = threading.Lock() - self.__thread_running = False + self.__thread_running: bool = False self.__logger = logger self.__wpa_status = self.WpaStatus() self.__old_wpa_status = copy.copy(self.__wpa_status) self.__hostapd_status = self.HostapdStatus() self.__old_hostapd_status = copy.copy(self.__hostapd_status) - self.__mesh_status = STATUS.no_status - self.__mesh_cfg_status = STATUS.mesh_default - self.__security_status = STATUS.security_non_provisioned - self.__is_mission_cfg = False # True when mission cfg has been applied - self.__is_mesh_radio_on = True # True since mesh is started via initd - self.__is_visualisation_active = False - self.__is_hash_file = False - self.__is_ap_radio_on = False + self.__mesh_status: str = STATUS.no_status + self.__mesh_cfg_status: str = STATUS.mesh_default + self.__security_status: str = STATUS.security_non_provisioned + self.__is_mission_cfg: bool = False # True when mission cfg has been applied + self.__is_mesh_radio_on: bool = True # True since mesh is started via initd + self.__is_visualisation_active: bool = False + self.__is_hash_file: bool = False + self.__is_ap_radio_on: bool = False # Refresh status self.__update_status() @property - def security_status(self): + def security_status(self) -> str: """ Get security status """ return self.__security_status @property - def mesh_status(self): + def mesh_status(self) -> str: """ Get mesh status """ return self.__mesh_status @property - def mesh_cfg_status(self): + def mesh_cfg_status(self) -> str: """ Get mesh configuration status """ return self.__mesh_cfg_status @mesh_cfg_status.setter - def mesh_cfg_status(self, status: STATUS): + def mesh_cfg_status(self, status: str): """ Set mesh configuration status """