#!/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_scan.sh # # @author (last) Behrouz NematiPour # @date (last) 15-Jan-2025 # @author (original) Behrouz NematiPour # @date (original) 15-Jan-2025 # ############################################################################ # Description # Lists all the available Access Points using nmcli command of NetworkManager module. # Parameters # No Parameters # Returns # Sorted list of the APs in defined column as specified in the $COLUMNS. # Considerations # For the Application to work with the List of APs # - it has to be sorted by SSID # - it has to use defined columns exactly as has been defined in $COLUMN. # sources . ./_errors_ . ./_functions_ # variables PARAM_COUNT=0 COLUMNS="SSID,BSSID,FREQ,RATE,SIGNAL,SECURITY,WPA-FLAGS,RSN-FLAGS,IN-USE" # functions # checks check_param_count "$#" "$PARAM_COUNT" # main OUTPUT="$(sudo nmcli -t -f $COLUMNS dev wifi list --rescan yes | sed 's/:/,/g;s/\\,/:/g' | sort)" check_result "$?" "$ERR_CMDFAIL_WIFI_SCAN" # exit gracefully sleep 0.1 echo -e "$OUTPUT" exit 0