Hello,
I’m trying to connect to Wi-Fi network via CLI, but I not sure the procedure I am using is the correct one. Sometimes the connection works, but most of the times it fails. Can someone help with this problem?
The procedure I am using is this one:
1st - Create the interface and set the link up:
iw phy phy0 interface add wlan0 type managed
ip link set wlan0 up
2nd - Scan the network to get the information about the network I am about to connect:
iw dev wlan0 scan
3rd - Set the wireless configuration:
uci set wireless.1=wifi-iface
uci set wireless.1.key=key
uci set wireless.1.bssid=bssid
uci set wireless.1.ssid=ssid
uci set wireless.1.encryption=encryption
uci set wireless.1.device=radio0
uci set wireless.1.mode=sta
uci set wireless.1.network=network
uci set wireless.1.skip_inactivity_poll=0
uci set wireless.1._bgscan_enabled=0
uci set wireless.1.ieee80211r=0
uci set wireless.1.wds=0
uci set wireless.1.disassoc_low_ack=0
uci set wireless.1.short_preamble=0
uci set wireless.1.wifi_id=wifi1
4th - Set the network configuration:
uci set network.network=interface
uci set network.network.proto=dhcp
uci set network.network.metric=1
uci set network.network.area_type=wan
uci set network.network.force_link=0
5th - Commit changes:
uci commit
reload_config
6th - Execute the DHCP lease:
udhcp -i wlan0