Configure WiFi network from prompt

good morning to all,
I tried to configure the WiFi connection from putty with these commands:

uci set wireless.@wifi-iface[0].mode=sta
uci set wireless.@wifi-iface[0].ssid='nomewifi'
uci set wireless.@wifi-iface[0].encryption='psk2'
uci set wireless.@wifi-iface[0].key='password'
uci commit wireless
wifi

Linino does not return any error. The last command (wifi) disconnects the WiFi and then something does not work. YUN is no longer in AP mode and I can't find it on my WiFi. The "ping arduino.local" loses all packets ...
What is the right syntax to change the configuration of WiFi?
What is wrong?

thanks

running WiFiStatus sketch:

Current WiFi configuration
SSID: nomewifi
Mode: Client
Signal: 82%
Encryption method: WPA2 PSK (NONE)
Interface name: wlan0
Active for: 4 minutes
IP address: 192.168.240.1/255.255.255.0
MAC address: 90:A2:DA:F2:05:5A
RX/TX: 67/22 KBs

The problem is surely the IP address ... why does not receive an IP from my DHCP?

tks 1k

It's not receiving the IP address because the interface already has a fixed one, the one when in AP mode. As you tell the wifi interface to work in "station" (client) mode, you also need to tell the related network interface to look for a dhcp to get an IP address

OK Federico...
how? XD

thanks 1k

Take a look at /etc/config/network
Guys, I can only show you the door, you are the ones that have to walk through it :smiley: ehhe

Thanks Federico ... I solved the problem!
I added these lines:

shell_exec ("uci delete network.lan.ipaddr");
shell_exec ("uci delete network.lan.netmask");
shell_exec ("uci September network.lan.proto = dhcp");
shell_exec ("uci commit network");

Thank you!

PS: your sentence was worthy of Jim Morrison!!! :slight_smile: :slight_smile: :slight_smile: