# source code that sets up wifi connection

**URL:** <https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946>\
**Category:** Yún\
**Created:** [January 8, 2015, 9:44pm UTC](https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946 "2015-01-08T21:44:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rret](https://avatars.discourse-cdn.com/v4/letter/r/7ab992/32.png) [@rret](https://forum.arduino.cc/u/rret)\
**Post date:** [January 8, 2015, 9:44pm UTC](https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946/1 "2015-01-08T21:44:47Z")

</div>

When you go to [http://192.168.240.1](http://192.168.240.1) (the Yun IP) one is presented with a page where you can join a network.  
The source code behind that is where in github? is it lua? or ??? does anyone have a link?  
thanks. sorry about the emoticon - don't know how that got in there

---

<div class="post-metadata">

**Author:** ![jessemonroy650](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jessemonroy650/32/1149818_2.png) [@jessemonroy650](https://forum.arduino.cc/u/jessemonroy650)\
**Post date:** [January 8, 2015, 10:28pm UTC](https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946/2 "2015-01-08T22:28:47Z")

</div>

> rret:  
> When you go to [http://192.168.240.1](http://192.168.240.1) (the Yun IP) one is presented with a page where you can join a network.  
> The source code behind that is where in github? is it lua? or ??? does anyone have a link?  
> thanks. sorry about the emoticon - don't know how that got in there

rret,  
The source code is on your Yun. It's all open source. The server is called _uhttpd_. The CGI that runs the page you see is run by [LuCI](http://wiki.openwrt.org/doc/techref/luci). There is code on github, which code do you want that is not on your Yun? The webserver, the CGI, Lua?

Jesse

---

<div class="post-metadata">

**Author:** ![ShapeShifter](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@ShapeShifter](https://forum.arduino.cc/u/ShapeShifter)\
**Post date:** [January 9, 2015, 12:33pm UTC](https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946/3 "2015-01-09T12:33:40Z")

</div>

> rret:  
> one is presented with a page where you can join a network.

Just a bit of pedantic semantics: the code _configures_ the wireless network connection parameters, it does not actually _join_ the wireless network. Joining happens after a restart, as part of the normal boot process, using those configuration parameters

You may already know this, and you may just be wanting to look at the code out of programming curiosity. But if you are trying to write code to actively change the connection at run time, the difference becomes important and looking at that code may or may not be helpful.

What are you actually trying do? Maybe there's a better way.

> sorry about the emoticon - don't know how that got in there

It appears there because you used three question marks in a row. The forum software sees that and substitutes a confused face emoticon. There are a lot of different shorthand sequences for triggering a smiley. When in the posting editor, try clicking on a few of the emoticons and see what text gets entered into the edit box.

---

<div class="post-metadata">

**Author:** ![rret](https://avatars.discourse-cdn.com/v4/letter/r/7ab992/32.png) [@rret](https://forum.arduino.cc/u/rret)\
**Post date:** [January 9, 2015, 2:45pm UTC](https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946/4 "2015-01-09T14:45:53Z")

</div>

i'm assuming that the code that _configures_ changes some files such as **network** and **wireless**.  
i'm interested in that source code. can you tell me where to find that in github? thanks.

---

<div class="post-metadata">

**Author:** ![Angelo9999](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@Angelo9999](https://forum.arduino.cc/u/Angelo9999)\
**Post date:** [January 9, 2015, 3:07pm UTC](https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946/5 "2015-01-09T15:07:14Z")

</div>

This is the lua code used to set the wireless configuration

> <https://github.com/arduino/YunWebUI/blob/master/usr/lib/lua/luci/controller/arduino/index.lua>

Here is the function

> <https://github.com/arduino/YunWebUI/blob/master/usr/lib/lua/luci/controller/arduino/index.lua#L447>

And here the specific wireless configuration

> <https://github.com/arduino/YunWebUI/blob/master/usr/lib/lua/luci/controller/arduino/index.lua#L490>

---

<div class="post-metadata">

**Author:** ![jessemonroy650](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jessemonroy650/32/1149818_2.png) [@jessemonroy650](https://forum.arduino.cc/u/jessemonroy650)\
**Post date:** [January 10, 2015, 12:25am UTC](https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946/6 "2015-01-10T00:25:11Z")

</div>

> rret:  
> i'm assuming that the code that _configures_ changes some files such as **network** and **wireless**.  
> i'm interested in that source code. can you tell me where to find that in github? thanks.

@Angelo9999, I think this person means the config files, and not the code.

@rret, the files on the Yun that hold the **network** and **wireless** are

- /etc/config/network
- /etc/config/wireless

Note it is easier to change these files via the web panel instead of directly.

Please let us know if this helps.  
Jesse

---

<div class="post-metadata">

**Author:** ![ShapeShifter](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@ShapeShifter](https://forum.arduino.cc/u/ShapeShifter)\
**Post date:** [January 10, 2015, 11:59am UTC](https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946/7 "2015-01-10T11:59:32Z")

</div>

> jessemonroy650:  
> @rret, the files on the Yun that hold the **network** and **wireless** are
> 
> - /etc/config/network
> - /etc/config/wireless

Just an idea, if the goal is to programmatically switch between two or more pre-defined settings, I've had good luck with saving several a versions of these configuration files. When it's time to switch, stop the appropriate network, copy the desired version of the file into place, then start networking again. Much easier than trying to make changes to the files each time (but only works if the different sets of settings are known ahead of time.)

---

<div class="post-metadata">

**Author:** ![jessemonroy650](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jessemonroy650/32/1149818_2.png) [@jessemonroy650](https://forum.arduino.cc/u/jessemonroy650)\
**Post date:** [January 12, 2015, 2:36am UTC](https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946/8 "2015-01-12T02:36:30Z")

</div>

> ShapeShifter:  
> Just an idea, if the goal is to programmatically switch between two or more pre-defined settings, I've had good luck with saving several a versions of these configuration files. When it's time to switch, stop the appropriate network, copy the desired version of the file into place, then start networking again. Much easier than trying to make changes to the files each time (but only works if the different sets of settings are known ahead of time.)

Yes ShapeShifter,  
that's usually a great strategy. However, a little extra caution must be taken.

FWIW: as you know I've been going through the bootup and startup files. In particular, when using the [LuCi](http://wiki.openwrt.org/doc/techref/luci) and [UCI](http://wiki.openwrt.org/doc/uci) the final configuration files will get written and _ **any comments** inside those configuration files will be lost._

To be clear,

- save the original
- save the _live configuration_
- save each intermediate

And be aware that using the UCI or LuCI will wipe out the _live configuration_ file

Jesse

---

<div class="post-metadata">

**Author:** ![ShapeShifter](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@ShapeShifter](https://forum.arduino.cc/u/ShapeShifter)\
**Post date:** [January 12, 2015, 1:13pm UTC](https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946/9 "2015-01-12T13:13:21Z")

</div>

> jessemonroy650:  
> To be clear,
> 
> - save the original
> - save the _live configuration_
> - save each intermediate

Good point. I'm doing basically that, but should've been explicit.

I'm not sure of the benefit of #2 (or what you mean by it.) I assume you mean the current /etc/config/wireless, for example. If you saved the original, and saved each custom version, and the live version is always a copy of one of these, what's the point in saving the live version? It will always be a copy of one of the saved files (or perhaps a stripped down version which is definitely not worth saving.)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 5:54pm UTC](https://forum.arduino.cc/t/source-code-that-sets-up-wifi-connection/280946/10 "2021-05-06T17:54:27Z")

</div>

Closed on May 6, 2021, 5:54pm UTC


