Merge pull request #53 from tjboldt/wifi-region

Add wifi region
This commit is contained in:
Terence Boldt 2021-12-31 08:56:04 -05:00 committed by GitHub
commit 91fa35bf0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 14 deletions

View File

@ -65,14 +65,10 @@ So far, this is a project and not a finished product. The current prototype is o
1. Put in any slot (slot 7 preferred as it is the first to boot) 1. Put in any slot (slot 7 preferred as it is the first to boot)
2. Turn on your Apple II 2. Turn on your Apple II
3. Wait for the RPi to start up (will show ... until it connects) 3. Wait for the RPi to start up (will show ... until it connects)
4. After ProDOS boots, type `-SHELL` 4. After ProDOS boots, type `-RPI.COMMAND`
5. Type `sudo vim /etc/wpa_supplicant/wpa_supplicant.conf` 5. Type `RPI a2wifi list`
6. Use `h j k l` keys to navigate, `i` to insert text and `ESC` to go back to navigation more 6. Type `RPI a2wifi select YOUR_SSID YOUR_WIFI_PASSWORD YOUR_TWO_LETTER_COUNTRY_CODE`
7. Enter your wifi information 7. Star and Watch this repo on GitHub for the latest updates
8. Press `ESC:wq` to save and quit
9. Type `sudo reboot`
10. Restart Apple II
11. Star and Watch this repo on GitHub for the latest updates
## Update ## Update
1. Restart Apple II 1. Restart Apple II

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,14 +210,16 @@ 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]
ssid + " " + 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 + " " +
psk + " " + psk + " " +
" > /tmp/wpa_supplicant.conf; " + " > /tmp/wpa_supplicant.conf; " +
"sudo mv /tmp/wpa_supplicant.conf /etc/wpa_supplicant/; " + "sudo mv /tmp/wpa_supplicant.conf /etc/wpa_supplicant/; " +