Programming the AR9331

I'm trying to use the Arduino Yun for a project which involves configuring the wifi, however I am unsure of how to program the AR9331.

Basically I'm trying to write code to do something like this:

if(digitalRead(5)){
//connect to network SSID = network_A
}
else if(digitalRead(6)){
//connect to network SSID = network_B
}
else{
//make arduino yun a network hotspot
}

I'm quite lost with the whole linino, openWRT and makefile stuff, so any help would be appreciated

Since you need to reconfigure wireless, search this forum and also look at Wireless configuration [Old OpenWrt Wiki]
You should write as many scripts as you like and run them at the appointed time

Once you identify the scripts / command lines you need to run - simply use the Process object defined in Bridge.h to execute your command on the Linino environment:

Process proc;
proc.begin("/usr/bin/xxx");
proc.addParaneter("abc");
proc.run();

Plenty of examples are available, once you know what commands you need to execute you should be all good! If you are interested in compiling your own code and running native code of your own:

http://www.ardiri.com/blog/arduino_yun_so_many_possibilities

May be an interesting starting point - only if you are hard core :slight_smile:

thanks, will look into it. Looks like there's a lot of learning to do for using gcc

sonnyyu:

nano setupwifi.sh
#!/bin/sh

/sbin/uci set  network.lan=interface
/sbin/uci set  network.lan.proto=dhcp
/sbin/uci delete  network.lan.ipaddr
/sbin/uci delete  network.lan.netmask
/sbin/uci set wireless.@wifi-iface[0].mode=sta
/sbin/uci set wireless.@wifi-iface[0].ssid=wifi_ssid
/sbin/uci set wireless.@wifi-iface[0].encryption=psk
/sbin/uci set wireless.@wifi-iface[0].key=wifi_password
/sbin/uci commit wireless; /sbin/wifi
/etc/init.d/network  restart




if you know ssid, encryption type, password.



chmod 755 setupwifi.sh






./setupwifi.sh

wrote both network_A and network_B script.

/usr/bin/wifi-reset-and-reboot

for //make arduino yun a network hotspot

then use ardiri method to call each script.

Switch network at code has major problem which is speed.

Plan B: add an other usb wifi adaptor which make connect both network_A and network_B same time.

thanks! will definitely give it a try. Speed isn't too much of an issue for me, as long as it's only slow when it first connects.