how to restart wifi when it fails

hello. I am working with a couple of Yuns exchanging data via wifi. Sometime happens that for any reason (also my "live" intervention on the hw, sensors, etc...) the wifi i/f fails. The white and blue led are off. I cannot connect any more. The i/f is not either in the live nor in the AP mode.

I am looking for a "simple" and linear procedure to restart the wifi i/f.
I suppose that the wifi configuration is still OK, so it should not be necessary to pass through the wifi reset/configure steps. Is it true ?? Just pressing the wifi reset button for a couple of seconds does not work.
Also switching down/up the board does not work.

A problem that may be perhaps connected is that sometimes, after the configuration (OK) from AP mode, the wifi i/f does not come up. How can I start it at this point ???

Thanks in advance for any clarification

I try to explain better :
After many trials I have the following behaviour:

  • system working fine, wifi up, connected.
  • system switched off
  • system switched on
  • the wifi i/f does not come up
  • as I connect the etherned cable (just connect - no operations) also the wifi i/f is started.
    -I disconnect the cable and the system is working fine again

Of course what I would like to have is that as the system is switched on again the wifi i/f is started.
thanks

Mine restarts the WiFi automatic and no issues after a power loss.
What was the last sketch you sent to the YUN and could you post it here please
Use code tags ( </> ) for the sketch or any other error / log messages.

I currently have "Arduino | OpenWRTYun Attitude Adjustment 1 | Load: 0.45 0.29 0.13" on mine btw.
And the following packages (although your config may be slightly different)

 	Package name	Version
Remove	avahi-daemon	0.6.31-5
Remove	avahi-dnsconfd	0.6.31-5
Remove	avahi-utils	0.6.31-5
Remove	avrdude	5.11.1-r1138-1
Remove	base-files	118.2-r42647
Remove	blkid	2.21.2-1
Remove	block-mount	0.2.0-9
Remove	busybox	1.19.4-6
Remove	cpu-mcu-bridge	1.5.1-2
Remove	curl	7.29.0-1
Remove	dbus	1.4.14-2
Remove	distribute	0.6.21-1
Remove	dnsmasq	2.66-2
Remove	dropbear	2011.54-2
Remove	firewall	2013-06-29
Remove	gnupg	1.4.12-1
Remove	hotplug2	1.0-beta-4
Remove	iptables	1.4.10-5
Remove	iw	3.14-1
Remove	jshn	2013-10-19-734d28eb1a46358743cf8837c91e5d46695c3b91
Remove	kernel	3.3.8-1-openwrtyun1
Remove	kmod-ath	3.3.8+2014-05-22-1
Remove	kmod-ath9k	3.3.8+2014-05-22-1
Remove	kmod-ath9k-common	3.3.8+2014-05-22-1
Remove	kmod-cfg80211	3.3.8+2014-05-22-1
Remove	kmod-crypto-aes	3.3.8-1
Remove	kmod-crypto-arc4	3.3.8-1
Remove	kmod-crypto-core	3.3.8-1
Remove	kmod-crypto-hash	3.3.8-1
Remove	kmod-crypto-manager	3.3.8-1
Remove	kmod-fs-ext4	3.3.8-1
Remove	kmod-fs-hfs	3.3.8-1
Remove	kmod-fs-hfsplus	3.3.8-1
Remove	kmod-fs-ntfs	3.3.8-1
Remove	kmod-fs-reiserfs	3.3.8-1
Remove	kmod-fs-vfat	3.3.8-1
Remove	kmod-fuse	3.3.8-1
Remove	kmod-gpio-button-hotplug	3.3.8-1
Remove	kmod-i2c-core	3.3.8-1
Remove	kmod-ipt-conntrack	3.3.8-1
Remove	kmod-ipt-core	3.3.8-1
Remove	kmod-ipt-nat	3.3.8-1
Remove	kmod-ipt-nathelper	3.3.8-1
Remove	kmod-leds-gpio	3.3.8-1
Remove	kmod-ledtrig-default-on	3.3.8-1
Remove	kmod-ledtrig-netdev	3.3.8-1
Remove	kmod-ledtrig-timer	3.3.8-1
Remove	kmod-lib-crc-ccitt	3.3.8-1
Remove	kmod-lib-crc16	3.3.8-1
Remove	kmod-loop	3.3.8-1
Remove	kmod-mac80211	3.3.8+2014-05-22-1
Remove	kmod-nls-base	3.3.8-1
Remove	kmod-nls-utf8	3.3.8-1
Remove	kmod-ppp	3.3.8-1
Remove	kmod-pppoe	3.3.8-1
Remove	kmod-pppox	3.3.8-1
Remove	kmod-scsi-core	3.3.8-1
Remove	kmod-usb-core	3.3.8-1
Remove	kmod-usb-storage	3.3.8-1
Remove	kmod-usb2	3.3.8-1
Remove	kmod-video-core	3.3.8-1
Remove	kmod-wdt-ath79	3.3.8-1
Remove	libassuan	2.0.2-1
Remove	libavahi	0.6.31-5
Remove	libavahi-client	0.6.31-5
Remove	libavahi-dbus-support	0.6.31-5
Remove	libblkid	2.21.2-1
Remove	libblobmsg-json	2013-10-19-734d28eb1a46358743cf8837c91e5d46695c3b91
Remove	libbz2	1.0.6-1
Remove	libc	0.9.33.2-1
Remove	libcurl	7.29.0-1
Remove	libcyassl	1.6.5-1
Remove	libdaemon	0.14-2
Remove	libdbus	1.4.14-2
Remove	libelf	0.8.13-1
Remove	libexpat	2.0.1-1
Remove	libffi	3.0.10-1
Remove	libftdi	0.19-1
Remove	libgcc	4.6-linaro-1
Remove	libgcrypt	1.5.0-1
Remove	libgdbm	1.9.1-2
Remove	libgnutls	2.8.6-2
Remove	libgpg-error	1.9-1
Remove	libgpgme	1.3.1-1.dh1
Remove	libip4tc	1.4.10-5
Remove	libip6tc	1.4.10-5
Remove	libiwinfo	44
Remove	libiwinfo-lua	44
Remove	libjson	0.11-2
Remove	libjson-c	0.11-2
Remove	libjson-script	2013-10-19-734d28eb1a46358743cf8837c91e5d46695c3b91
Remove	liblua	5.1.4-8
Remove	libncurses	5.7-5
Remove	libnl-tiny	0.1-3
Remove	libopenssl	1.0.1h-1
Remove	libpcre	8.11-2
Remove	libpthread	0.9.33.2-1
Remove	libreadline	5.2-2
Remove	librt	0.9.33.2-1
Remove	libubox	2013-10-19-734d28eb1a46358743cf8837c91e5d46695c3b91
Remove	libubus	2013-08-08-b20a8a01c7faea5bcc9d34d10dcf7736589021b8
Remove	libubus-lua	2013-08-08-b20a8a01c7faea5bcc9d34d10dcf7736589021b8
Remove	libuci	2013-06-11.1-1
Remove	libuci-lua	2013-06-11.1-1
Remove	libusb	0.1.12-3
Remove	libusb-1.0	1.0.9-1
Remove	libuuid	2.21.2-1
Remove	libxtables	1.4.10-5
Remove	lua	5.1.4-8
Remove	luci	0.11+svn10537-1
Remove	luci-app-arduino-webpanel	1.5.4-1
Remove	luci-app-firewall	0.11+svn10537-1
Remove	luci-i18n-english	0.11+svn10537-1
Remove	luci-lib-core	0.11+svn10537-1
Remove	luci-lib-ipkg	0.11+svn10537-1
Remove	luci-lib-json	0.11+svn10537-1
Remove	luci-lib-nixio	0.11+svn10537-1
Remove	luci-lib-sys	0.11+svn10537-1
Remove	luci-lib-web	0.11+svn10537-1
Remove	luci-mod-admin-core	0.11+svn10537-1
Remove	luci-mod-admin-full	0.11+svn10537-1
Remove	luci-proto-core	0.11+svn10537-1
Remove	luci-proto-ppp	0.11+svn10537-1
Remove	luci-sgi-cgi	0.11+svn10537-1
Remove	luci-theme-base	0.11+svn10537-1
Remove	luci-theme-bootstrap	0.11+svn10537-1
Remove	luci-theme-openwrt	0.11+svn10537-1
Remove	mtd	18.1
Remove	nano	2.2.6-1
Remove	netifd	2013-07-16-2674941b06c1ec67f1aff1bff9212e1372106641
Remove	opkg	618-3.dh1
Remove	ppp	2.4.5-10
Remove	ppp-mod-pppoe	2.4.5-10
Remove	px5g	1
Remove	python	2.7.3-2
Remove	python-bzip2	2.7.3-2
Remove	python-json	3_4-1
Remove	python-mini	2.7.3-2
Remove	python-openssl	2.7.3-2
Remove	rng-tools	3-2
Remove	spacebrew	2.3.0-1
Remove	swap-utils	2.21.2-1
Remove	swconfig	10
Remove	temboo	1.1.0-1
Remove	terminfo	5.7-5
Remove	triggerhappy	0.3.4-1
Remove	uSDaemon	1.0.0-1
Remove	uboot-envtools	2012.04.01-1
Remove	ubus	2013-08-08-b20a8a01c7faea5bcc9d34d10dcf7736589021b8
Remove	ubusd	2013-08-08-b20a8a01c7faea5bcc9d34d10dcf7736589021b8
Remove	uci	2013-06-11.1-1
Remove	uhttpd	2012-10-30-e57bf6d8bfa465a50eea2c30269acdfe751a46fd
Remove	uhttpd-mod-lua	2012-10-30-e57bf6d8bfa465a50eea2c30269acdfe751a46fd
Remove	uhttpd-mod-tls	2012-10-30-e57bf6d8bfa465a50eea2c30269acdfe751a46fd
Remove	uhttpd-mod-ubus	2012-10-30-e57bf6d8bfa465a50eea2c30269acdfe751a46fd
Remove	usbutils	005-1
Remove	wget	1.13.4-1
Remove	wireless-tools	29-5
Remove	wpad-mini	20131120-1
Remove	yun-conf	1.2.0-2
Remove	yun-scripts	1.3-1
Remove	zlib	1.2.7-1

OOPS OK firmware version "OpenWRTYun Attitude Adjustment 1 / LuCI 0.11 Branch (0.11+svn10537)"

hi. To be sure that it was not any arduino fault I emptied the sketch. Only an empty setup and loop. The problems still persists. After a power loss Linux does not restart automatically the wifi.
For the moment I apparently solved the problem following the quick and dirty suggestion of msssltd, topic : WLAN issues August 18 2014 in the Forum.
I put in the crontab
1 * * * * /init.d/network reload

It looks stable enough. But shouldn't the system do this job ??

BTW : I must say that the Yun board is located behind a wifi repeater, with an average signal strength of 65-70 %.