I am having problems accessing my yun in its AP-mode, after either a WLAN_RST or calling /etc/bin/wifi-reset-and-reboot directly. I have also tried powering the yun off/reset after switching to AP-mode.
While I can still see and connect to the interface (eg. Arduino Yun-MACXXX), but the yun won't give me a IP address. I suspect an openwrt dhcp server problem.
This is because I can still manually configure an IP address (eg. IP=192.168.240.2 SUBNET=255.255.255.0 GATEWAY=192.168.240.1) to see the yun at its default IP (eg. 192.168.240.1)
Thanks @sonnyyu. I took your advice and reset-to-factory, and debugged my project from there.
In the case it might help somebody, my problem was a cron script for checking internet connectivity. It would reset the network service if it couldn't ping the yun's default gateway, which of course isn't defined in it's ap-mode
Here's the final correct code
#!/bin/ash
# ping default wifi gateway and direct stdout stderr to null
# check exit status: $?. note whitespace in conditionals important
# IF ap-mode do not check default gateway because
# will always fail and network will endlessly be reset
WIFIMODE=$(uci get wireless.@wifi-iface[0].mode)
if [ $WIFIMODE == 'ap' ]; then
exit 0
fi
# determine and attempt to ping default gateway
DEFAULT_GATEWAY=$(route | awk '/default/ { print $2 }')
ping -c 1 $DEFAULT_GATEWAY &>/dev/null
if [ $? -eq 0 ]; then
# wifi ok
else
# wifi down
# restart
/etc/init.d/network restart
fi