Skip to content

Commit 7d24c3c

Browse files
scottfeldmandeadprogram
authored andcommitted
wioterminal: fix check for bad Wifi connect
rpc_wifi_connect() will return 0 on successful connection, so check for that. Also, check that if passphrase is given, that it's the minimum 8 chars per WPA Wifi.
1 parent 5c0f048 commit 7d24c3c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

netlink/netlink.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var (
1313
ErrConnectFailed = errors.New("Connect failed")
1414
ErrConnectTimeout = errors.New("Connect timed out")
1515
ErrMissingSSID = errors.New("Missing WiFi SSID")
16+
ErrShortPassphrase = errors.New("Invalid Wifi Passphrase < 8 chars")
1617
ErrAuthFailure = errors.New("Wifi authentication failure")
1718
ErrAuthTypeNoGood = errors.New("Wifi authorization type not supported")
1819
ErrConnectModeNoGood = errors.New("Connect mode not supported")

rtl8720dn/rtl8720dn.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,18 @@ func (r *rtl8720dn) connectToAP() error {
102102
return netlink.ErrMissingSSID
103103
}
104104

105+
if len(r.params.Passphrase) != 0 && len(r.params.Passphrase) < 8 {
106+
return netlink.ErrShortPassphrase
107+
}
108+
105109
if debugging(debugBasic) {
106110
fmt.Printf("Connecting to Wifi SSID '%s'...", r.params.Ssid)
107111
}
108112

109113
// Start the connection process
110114
securityType := uint32(0x00400004)
111115
result := r.rpc_wifi_connect(r.params.Ssid, r.params.Passphrase, securityType, -1, 0)
112-
if result == -1 {
116+
if result != 0 {
113117
if debugging(debugBasic) {
114118
fmt.Printf("FAILED\r\n")
115119
}

0 commit comments

Comments
 (0)