Network and Yun

Backup and Recover Plan:

Backup and restore system wide setting.

http://forum.arduino.cc/index.php?topic=320168.0

Recover Yun OS by mount Micro SD on Linux box

http://forum.arduino.cc/index.php?topic=319716.0

Clone Yun OS at Linux Box by dd Command

http://forum.arduino.cc/index.php?topic=319452.0

Recover bricked expanded Yun

http://forum.arduino.cc/index.php?topic=321502.msg2230839#msg2230839

An other recover plan:

Bridge Library for Arduino Yún/Examples

at Arduino IDE console type:

reset-to-factory-anyway
reboot

AR9331+ openwrt supported WIFI mode:

  • ap for Access Point
  • sta for managed (client) mode
  • adhoc for Ad-Hoc
  • wds for static WDS
  • monitor for monitor mode
  • mesh for IEEE 802.11s mesh mode

mesh mode only supported by mac80211 (in trunk)

When Yun reflash or reset factory default or brand new:

reset factory default by:

reset-to-factory-anyway
reboot

Yun network setting:

wlan (WIFI)
mode:Access Point
static ip:192.168.240.1

eth1 (ethernet)
dhcp client get ip from router ip pool
(192.168.0.X)

backup system wide setting:

uci export > /root/ap.conf

whenever you need restore it:

uci import </root/ap.conf
reboot

Login web control panel after setup wifi

Yun network setting:

wlan (WIFI)
mode:sta for managed (client) mode
dhcp client get ip from router ip pool
(192.168.0.X)

eth1 (ethernet)
dhcp client get ip from router ip pool
(192.168.0.X)

backup system wide setting:

uci export > /root/sta.conf

whenever you need restore it:

uci import </root/sta.conf
reboot

Yun as an AP to a Router:

http://forum.arduino.cc/index.php?topic=322588.msg2230864#msg2230864

Set bridge mode between 2 AP(Router,Yun):

wlan0 (WIFI) and eth1 (ethernet) bridge together as br-lan
br-lan (wlan0,eth1 )
static ip:192.168.0.2

backup system wide setting:

uci export > /root/bridge.conf

whenever you need restore it:

uci import </root/bridge.conf
reboot

Peter_n:
I think I want to switch between different configurations.

configuration 1 : wifi connected to my home wifi as client, ethernet cable sometimes connected.
configuration 2 : wifi as (bridged or not) AP using the ethernet cable.
configuration 3 : wifi as AP, without ethernet cable.

I want to use a webcam anywhere in my house, and use my home wifi to view the webcam. This is working.
But I also want to be able to use it as a (bridged) AP with the ethernet cable connected, as a substitute for a home wifi.
And and I want to carry it with me, and use any tablet to connect and view the webcam, like a wireless borescope.

configuration 1 : sta for managed (client) mode

uci import </root/sta.conf
reboot

configuration 2 : bridge mode

uci import </root/bridge.conf
reboot

configuration 3 : ap mode Access Point

uci import </root/ap.conf
reboot

Setup monitor mode:

First revert Yun back to factory default (AP mode)

nano /root/setmonitor.sh
#!/bin/ash
uci set wireless.@wifi-iface[0].mode=monitor
uci set wireless.@wifi-iface[0].hidden=1
uci delete wireless.@wifi-iface[0].encryption
uci delete wireless.@wifi-iface[0].ssid
/sbin/uci commit wireless
wifi down; wifi up
chmod 755 /root/setmonitor.sh
/root/setmonitor.sh
iwconfig
lo        no wireless extensions.

eth1      no wireless extensions.

wlan0     IEEE 802.11bgn  Mode:Monitor  Frequency:2.462 GHz  Tx-Power=17 dBm
          RTS thr:off   Fragment thr:off
          Power Management:off

eth0      no wireless extensions.

Mode:Monitor

backup system wide setting:

uci export > /root/monitor.conf

whenever you need restore it:

uci import </root/monitor.conf
reboot

Setup adhoc mode:

First revert Yun back to factory default (AP mode)

nano /root/setadhoc.sh
#!/bin/ash
uci set wireless.@wifi-iface[0].mode=adhoc
/sbin/uci commit wireless
wifi down; wifi up
chmod 755 /root/setadhoc.sh
/root/setadhoc.sh

backup system wide setting:

uci export > /root/adhoc.conf

whenever you need restore it:

uci import </root/adhoc.conf
reboot

sonnyyu:
Login web control panel after setup wifi

Yun network setting:

wlan (WIFI)
mode:sta for managed (client) mode
dhcp client get ip from router ip pool
(192.168.0.X)

eth1 (ethernet)
dhcp client get ip from router ip pool
(192.168.0.X)
...

Change wifi dhcp client get ip from router ip pool to static ip:

nano  /root/sta2.sh
#!/bin/ash
uci set network.lan._orig_ifname=wlan0
uci set network.lan._orig_bridge=false
uci set network.lan.proto=static
uci set network.lan.ipaddr=192.168.0.3
uci set network.lan.netmask=255.255.255.0
uci set network.lan.gateway=192.168.0.1
uci set network.lan.dns=192.168.0.1
/sbin/uci commit network
/etc/init.d/network restart
chmod 755 /root/sta2.sh
/root/sta2.sh

can one just copy one's desired config into /etc/config/wireless and then do
/sbin/uci commit wireless
wifi down; wifi up

?

It would be nice to be able to name configs and switch cleanly, quickly from the web interface.
Another problem is preventing the automatic reset to AP mode that happens if no wireless router is found.
That is not very good for unattended deployment - think your mains go down, your mains come up, your router reboots, but the Yun is now orphaned.

Edmund

edmundronald:
can one just copy one's desired config into /etc/config/wireless and then do
/sbin/uci commit wireless
wifi down; wifi up

?
...

Yes, it will work and might work without

/sbin/uci commit wireless

some thing like

cp /etc/config/wireless.back /etc/config/wireless
wifi down; wifi up

Further more use an other Linux Box mount Micro SD do same thing

Recover Yun OS by mount Micro SD on Linux box

http://forum.arduino.cc/index.php?topic=319716.0

edmundronald:
can one just copy one's desired config into /etc/config/wireless and then do
/sbin/uci commit wireless
wifi down; wifi up

I have done this successfully, it works well to switch between several pre-defined configurations. I give the details here: Use sketch to create temporary wireless access point ? - #6 by ShapeShifter - Arduino Yún - Arduino Forum

Another problem is preventing the automatic reset to AP mode that happens if no wireless router is found.

That "feature" can help during initial configuration if you get your network settings wrong, but I agree that it gets in the way in just about all other cases. To disable it, edit /etc/rc.local and comment out the line that says wifi-live-or-reset (put a '#' character in front.)

I previously tried it without

/sbin/uci commit wireless

(didn't know about commit) and it didn't work; I guessed something was missing but didn't know what.

When I tried I didn't know about uci.

Let's keep this thread live for discussing this topic, decide which way to do this, and then maybe we could bake this operation into the GUI.

I think OpenWRT was originally for routers and routers don't get moved around a lot so having multiple configurations is not a priority, which is why this feature was left out; Arduinos travel much more than routers, and for us it's useful.

Edmund

sonnyyu:
Yes, it will work and might work without

/sbin/uci commit wireless

some thing like

mv /etc/config/wireless.back /etc/config/wireless

wifi down; wifi up




Further more use an other Linux Box mount Micro SD do same thing

Recover Yun OS by mount Micro SD on Linux box

http://forum.arduino.cc/index.php?topic=319716.0

edmundronald:
I previously tried it without

/sbin/uci commit wireless

(didn't know about commit) and it didn't work; I guessed something was missing but didn't know what.

When I tried I didn't know about uci.

Let's keep this thread live for discussing this topic, decide which way to do this, and then maybe we could bake this operation into the GUI.

I think OpenWRT was originally for routers and routers don't get moved around a lot so having multiple configurations is not a priority, which is why this feature was left out; Arduinos travel much more than routers, and for us it's useful.

Edmund

@edmundronald,

I should clear up some assumptions for you.

First as you can see, both SonnyYu and ShapeShifter have experience in doing this, so I might blunder or mis-type something. (I might fix it the next day.)

Next, the UCI system is fairly well documented with a cousin that handled the web-interface. It is know as LuCI(technical reference). The LuCI is a Lua implementation. UCI has several libraries you can utilize, that include c++ and python. The technical reference for LuCI has a list of kernel mods and web mods that will make life easier. However, they are written for Lua.

In addition, you should know that while UCI is the best tool, some parts are poorly documented, namely the shell scripts implementation - which are scheduled to be deprecated. I know this because I am documenting this issue (with the shell scripts) this week.

Lastly, for exchanging different types of wireless scenarios, OpenWrt has a list of recipes, which do everything from dumpAP to VoIP.

Given all that I don't want to discourage you from working on anything. I'm just giving you a head start. :wink:

Jesse

Jesse, thank you for those pointers.

Yun is neat as a prototyping tool, it allows one to do a quick prototype with lots of capabilities eg. I now have a small Twisted chat server running, which I'm going to demo today. I really like the way things just work on the Yun, there's just enough Unix and not too much :slight_smile:

On the other hand, looking at those links one can see that bulletproofing any network-related issue really would take a lot of work, and is a very specialised job, and should certainly go through the openwrt approved way of doing things.

But hacking things fast is part of the attraction here - Yun is a demo tool, not a production router :slight_smile:

Edmund

EpoxyD:
Hi there!

First of all, I'm new to the Arduino world, but loving it so far. :slight_smile:
My current project is a gas sensor that sends its data to an online mySQL database. However, I'd like to use my campus WiFi to connect to said database instead of the standard ethernet cable for portability reasons. Our campus network always uses the same network name, and once logged in you can use it throughout campus while on pc or mobile. However, my Yun only seems willing to connect to 1 single router.

How come?
I have a WiFi network that is secured with WPA2-Enterprise. This isn't compatible with the standard wpad-mini package, but I got it working by switching it out with wpad. When configuring the connection however I needed to connect to a network, and it showed my campus network by router. (Can't give you an image now, I'm currently at home. I'll provide one later if that would help out) The situation is: about 5/6 routers with the same connection name, but with a different BSSID value.

What's my question?
Currently I can manage to connect to one router on my radio0. Would it be possible to configure multiple (or all of these) routers so that the Yun would pick the strongest signal? Otherwise my application would become very limited throughout the building.

Thanks in advance!

Same SSID ( network name) but different BSSID ( AP mac address)

Setup STA mode first:

http://forum.arduino.cc/index.php?topic=319496.msg2231126#msg2231126

Switch to first BSSID:

#!/bin/ash
uci set wireless.@wifi-iface[0].bssid=14:CF:E2:A2:XX:XX
uci commit 
wifi down; wifi up
/etc/init.d/network  restart

Switch to second BSSID:

#!/bin/ash
uci set wireless.@wifi-iface[0].bssid=48:5B:39:E7:XX:XX
uci commit 
wifi down; wifi up
/etc/init.d/network  restart

Would it be possible to configure multiple (or all of these) routers so that the Yun would pick the strongest signal?

If you don't set up "wireless.@wifi-iface[0].bssid", It will pick the strongest signal if you run

wifi down; wifi up
/etc/init.d/network  restart

to trigger?

Set up dhcp server at wan ( ethernet port):

  1. Reset Yun to factory default by:
reset-to-factory-anyway
reboot

( backup your own data)

  1. Setup WIFI STA mode:

http://forum.arduino.cc/index.php?topic=319496.msg2231126#msg2231126

  1. SSH to wifi ip address:
nano /mnt/sda1/setwandhcp.sh
uci set network.wan.proto=static
uci set network.wan.ipaddr=192.168.241.1
uci set network.wan.netmask=255.255.255.0
uci commit network
uci set dhcp.wan.start=100
uci set dhcp.wan.limit=150
uci set dhcp.wan.leasetime=12h
uci set dhcp.wan.ignore=0
uci commit dhcp
/etc/init.d/dnsmasq restart
/etc/init.d/network restart
chmod 755 /mnt/sda1/setwandhcp.sh

/mnt/sda1/setwandhcp.sh
  1. Testing:

Connect ethernet cable between Yun and PC, PC as DHCP client.

Hi!

If I use a 3G USB stick on the USB port and I want to share the net over the Wi-Fi and the Ethernet port what shall I do? Until now I'm only able to share it over Wi-Fi but not on the Ethernet port. Anybody have some solution? :slight_smile:

Regards

Oliver