Make wifi region configurable

This commit is contained in:
Terence Boldt 2021-12-31 08:43:48 -05:00
parent 4eac3e2791
commit dc52abf640

View File

@ -200,7 +200,7 @@ func a2lower(enable bool) {
func a2wifi() { func a2wifi() {
comm.WriteString("\r" + comm.WriteString("\r" +
"Usage: a2wifi list\r" + "Usage: a2wifi list\r" +
" a2wifi select SSID PASSWORD\r" + " a2wifi select SSID PASSWORD REGION\r" +
"\r") "\r")
} }
@ -210,13 +210,15 @@ func a2wifiList() string {
func a2wifiSelect(linuxCommand string) (string, error) { func a2wifiSelect(linuxCommand string) (string, error) {
params := strings.Fields(linuxCommand) params := strings.Fields(linuxCommand)
if len(params) != 4 { if len(params) != 5 {
comm.WriteString("\rIncorrect number of parameters. Usage: a2wifi select SSID PASSWORD\r\r") comm.WriteString("\rIncorrect number of parameters. Usage: a2wifi select SSID PASSWORD REGION\r\r")
return "", errors.New("Incorrect number of parameters. Usage: a2wifi select SSID PASSWORD") return "", errors.New("Incorrect number of parameters. Usage: a2wifi select SSID PASSWORD REGION")
} }
ssid := params[2] ssid := params[2]
psk := params[3] psk := params[3]
linuxCommand = "printf \"country=ca\\nupdate_config=1\\nctrl_interface=/var/run/wpa_supplicant\\n\\nnetwork={\\n scan_ssid=1\\n ssid=\\\"%s\\\"\n psk=\\\"%s\\\"\\n}\\n\" " + region := params[4]
linuxCommand = "printf \"country=%s\\nupdate_config=1\\nctrl_interface=/var/run/wpa_supplicant\\n\\nnetwork={\\n scan_ssid=1\\n ssid=\\\"%s\\\"\n psk=\\\"%s\\\"\\n}\\n\" " +
region + " " +
ssid + " " + ssid + " " +
psk + " " + psk + " " +
" > /tmp/wpa_supplicant.conf; " + " > /tmp/wpa_supplicant.conf; " +