Error - "address_not_allocated"
Closed this issue · 4 comments
sdima75 commented
Hello.
My code.
package main
import (
"fmt"
"time"
wifi "github.com/mark2b/wpa-connect"
)
func main() {
ssid := "My_name_wifi"
password := "My_password_wifi"
if conn, err := wifi.ConnectManager.Connect(ssid, password, time.Second*60); err == nil {
fmt.Println("Connected", conn.NetInterface, conn.SSID, conn.IP4.String(), conn.IP6.String())
// fmt.Println("Connected", conn)
} else {
fmt.Println("Err connect: ", err)
}
}
An error appears - "address_not_allocated".
Wifi is working properly. The password is correct.
Can you tell me what the problem may be?
I understand that the problem is related to the code -
func (self *connectContext) hasIP() bool {
return self.ip4 != nil && self.ip6 != nil
}
mark2b commented
Hello, It looks like DHCP didn't allocate IP address (v4 & v6) for some reason.
There is a loop that waits for IP allocation during timeout you provided.
sdima75 commented
Hello, It looks like DHCP didn't allocate IP address (v4 & v6) for some reason.
There is a loop that waits for IP allocation during timeout you provided.
I only run "ifconfig" with root privileges. Could this be the reason for the error?
mark2b commented
You should run wpa-connect with root / sudo
sdima75 commented
You should run wpa-connect with root / sudo
Thank you for your help!