#!/bin/sh ########################################################################### # # Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file wifi_connect.sh # # @author (last) Behrouz NematiPour # @date (last) 15-Jan-2025 # @author (original) Behrouz NematiPour # @date (original) 15-Jan-2025 # ############################################################################ # Description # Connects to the given SSID with the given password. # Parameters # $1: the SSID name # $2: the SSID password # Retruns # No specific response. # Considerations # For security reasons the system is not allowed to connect to a passwordless AP. # Therefore an empty password is an error. # TODO # Add static connection # The static IP enable shall only be a boolean argument for this script. # When set to 1(true), the corretly defined connection will be made static. # sources . ./_errors_ . ./_functions_ # variables PARAM_COUNT=2 SSID_NAME="$(trim "$1")" SSID_PASS="$(trim "$2")" # functions # checks check_param_count "$#" "$PARAM_COUNT" check_empty_string "$SSID_NAME" "$ERR_MTPARAM_WIFI_SSID" check_empty_string "$SSID_PASS" "$ERR_MTPARAM_WIFI_PASS" # main sudo nmcli dev wifi connect "$SSID_NAME" password "$SSID_PASS" check_result "$?" "$ERR_CMDFAIL_WIFI_CONNECT"