Revision [31547]
This is an old revision of getWpaPSK() made by s243a on 2016-11-07 02:00:59.
Summary
The function getWpaPSK() is used to return the WPA-PSK key variable. It is part of the file wag-profiles.sh which is a function library for the Network Wizard called "Network Wizard". The function retrieves the value from the shell variable, PROFILE_KEY defined in wag-profiles.sh
Calling Sequence
to use getWpaPSK() the key must first be defined. The key is defined in three steps.
Step 1.
Obtain Profile Data via Either A Scan, or an existing profile
Step 1 (a).Scan for available wireless Networks
A scan is not necessary if the profile is already defined. However, scanning is done on the associated start-up script rc.network (Note 1) so that on startup, the script doesn't try to connect to an unavailable network. Network Wizard comes with two different network scan methods defined within wag-profiles.sh which are shown in the following table.Wizard Function | start-up function | network utility | package | Note |
---|---|---|---|---|
buildScanWindow() | run_iw_scan() | iwlist | net-tools | |
buildPrismScanWindow() | runPrismScan | wlanctl-ng | wlanctl-ng |
In the case of buildSandWindow, the result of the scan is stored in a temporary file which is the largest of two scans.
From line 1821 of netsetup-sh
ScanListFile=$(du -b /tmp/net-setup_scan*.tmp |sort -n | tail -n1 |cut -f2)
two scans are taken because iwlist is not guaranteed to return all available wireless networks in a single scan.
Step 1(b)
Loading an existing Profile
When a profile is obtained via a scan the results of the scan are assigned to profile variables via setupSannedProfile(), which calls setupNewProfile(). This function retrieves the profile variables from the ScanListFile (e.g. ) using the function Get_Cell_Parameters.
Alternatively a profile can be loaded from an existing profile file, either by directly by sourcing the file or indirectly by using the function loadProfileData(). In either case the profile info is assigned to temporary variables which must be first assigined to the profile variables by calling the function assignProfileData.
assignProfileData is called automatically in the function loadProfileData() but my be explicitly called if either the profile file is direcly sourced or if instad the profile data is obtained by using the function Get_Cell_Parmaters. For instance on start-up Get_Cell_Parameters is called directly rather then through setupScannedProfile because the profile already exists.
Step 2.
After the profile is loaded and assigned to the profile variables then the WPA-PSK key can be obtained via the function getWpaPSK. However, normally this function is called when trying to connect to a new WPA profile rather than called directly. (see useWPASupplicant()