Even though there is a nice XBMC add-on to configure your WIFI settings, sometimes, you may still want to setup the WIFI connection for many reasons or just for fur.
OpenELEC use connman for managing connection to the various available network.
Setuping connman to connect to your protected WIFI network is an easy requiring you only to create a config file and enter some commands in a shell.
This guide was run using OpenELEC 4.0.1 which use internally connman 1.21. It will
guide through all necessary steps to configure a connection to your WIFI
network. Once setup, OpenELEC will automatically re-connect on boot as long
as you keep the configuration in your storage.
Here we go!
-
Ensures
connmandaemon is running:ps faux | grep connmandIf you see something like below, then you are good to go:
OpenELEC:~ # ps faux | grep connmand 862 root 0:00 /usr/sbin/connmand -nr 1033 root 0:00 grep connmandIf you only see:
OpenELEC:~ # ps faux | grep connmand 1033 root 0:00 grep connmand
Then you will probably need to startup connmand manually. Note that this
will not be persistent, i.e. it will not autostart next time you boot
your machine.
To start connmand manually, do:
`/usr/bin/connmand -nr`
-
Ensures there is a network adapter for your WIFI card (or USB dongle or whatever):
ifconfigYou should see an adapter starting with
wlanin the list. Here the result of the command in my hardware:eth0 Link encap:Ethernet HWaddr B8:27:EB:0F:01:A0 inet addr:192.168.0.115 Bcast:192.168.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2307 errors:0 dropped:0 overruns:0 frame:0 TX packets:1268 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:320940 (313.4 KiB) TX bytes:159217 (155.4 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) wlan0 Link encap:Ethernet HWaddr 00:13:EF:20:01:8A UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) -
Enable
connmanwifi technology:connmanctl enable wifiMaybe
connmanwill complain that wifi is already enabled, if it's the case, no problem, just move to next step.If
connmancannot enable wifi, it probably means there is something fishy with your adapter (wrong linux driver maybe). -
Scan for WIFI network nearby:
connmanctl scan wifiThis will scan nearby network available.
-
List found WIFI network:
connmanctl servicesThis will list all known services. A services for
connmanis an available device for which is possible to connect to. This is not limited to WIFI and includes ehternet, bluetooth (if enabled) and more. Here the list I received when doing this command on my hardware:*AR Wired ethernet_b827eb0f01a0_cable BELL825 wifi_0013ef20018a_42454c4c383235_managed_psk VIDEOTRON2188 wifi_0013ef20018a_564944454f54524f4e32313838_managed_psk bungie wifi_0013ef20018a_62756e676965_managed_psk Moth wifi_0013ef20018a_4d6f7468_managed_psk Maison wifi_0013ef20018a_4d6169736f6e_managed_psk GOAHEAD wifi_0013ef20018a_474f4148454144_managed_psk VIDEOTRON6117 wifi_0013ef20018a_564944454f54524f4e36313137_managed_psk VIDEOTRON4100 wifi_0013ef20018a_564944454f54524f4e34313030_managed_psk Nicolas wifi_0013ef20018a_4e69636f6c6173_managed_pskAs you can see, there is a bunch of them. All the one starting with
wifi_are WIFI network available to connect to. The suffix_pskmeans it's a protected network.If my case, the network I want to connect to is
Moth, so its service id assigned byconnmaniswifi_0013ef20018a_4d6f7468_managed_psk. -
Create the configuration file to access the network.
The
connmanconfiguration files onOpenELECare not at the usual location of/var/lib/connman. In theOpenELECdistribution, you must put your configuration file in/storage/.cache/connman.So, navigate to this directory and create a file with the pattern
<name>.config. The<name>should be replaced with any name you think is useful to remember the network. In my case, I chosemothas the<name>since it relates closely to the WIFI SSID name.When the file is created, enter the following content in it using your favorite editor (
nanois the default one inOpenELEC):[global] Name = Moth Description = Moth Wifi service config file [service_wifi_moth] Type = wifi Name = Moth Passphrase = <passphrase>This is the minimal configuration required (in fact, the
[global]section is not really necessary but useful to have).For the
[global]section, enter an identifier for the file in theNamefield and a description of the network in theDescriptionfield.Other section must always start with a
service_. What follows after is simply again another identifier which identity the network. In my case, I used the patternwifi_<ssid_name>.Then, in this section, the
Typeif the type of technology for the service which iswifiin our case. TheNamerepresents the SSID network name with isMothin my case. And finally,Passphraseis the password for the network, replace<passphrase>with your own secret passphrase.If you have an SSID name with special characters (like spaces or anything else), removed the
Nameline and put a lineSSID = <SSID_name_in_hex>instead. The value<SSID_name_in_hex>should be replaced by the hex value of your SSID name which can obtained online with a service like . For example, for the networkMoth, the configuration file would look like this when using theSSIDfield:[global] Name = Moth Description = Moth Wifi service config file [service_wifi_moth] Type = wifi SSID = 4d6f7468 Passphrase = <passphrase>There is more more configuration available but only those will suffice for you guide. Refer to the config file format for more information on the configuration file format (links to version 1.21 of
connman). -
Check that
connmancorrectly sees your new settings.For this, simply run:
connmanctl scan wifi connmanctl servicesIn the refreshed services list, there now should be a
A*just before the network you configured, this indicates thatconnmanknows how to connect to this service:*AR Wired ethernet_b827eb0f01a0_cable *A Moth wifi_0013ef20018a_4d6f7468_managed_psk BELL825 wifi_0013ef20018a_42454c4c383235_managed_psk bungie wifi_0013ef20018a_62756e676965_managed_psk Nicolas wifi_0013ef20018a_4e69636f6c6173_managed_psk Maison wifi_0013ef20018a_4d6169736f6e_managed_psk GOAHEAD wifi_0013ef20018a_474f4148454144_managed_psk VIDEOTRON2188 wifi_0013ef20018a_564944454f54524f4e32313838_managed_psk VIDEOTRON6117 wifi_0013ef20018a_564944454f54524f4e36313137_managed_psk VIDEOTRON4100 wifi_0013ef20018a_564944454f54524f4e34313030_managed_pskIf the network does not have the
*Abefore it, try restarting theconnmandaemon to force it to reload configuration files. First, obtain theconnmandpid by running:ps faux | grep connmandAnd then checking the first number if the result line.
kill <connmand_pid>It should restart automatically but if it's not the case:
/usr/bin/connmand -nrWhen it have restarted, run another wifi scan and check if the services has the
*Aflag. -
Connect to the network
connmanctl connect wifi_0013ef20018a_4d6f7468_managed_pskWhere
wifi_0013ef20018a_4d6f7468_managed_pskis the servie id reported byconnmanfor your network.If everything went well, should then be connected to your protected WIFI network.
Voilà and enjoy Matt
Hey Guys, I could not get connman to connect via wifi using the above method. The wifi just failed to register no matter what I did (No * next to the wifi name when executing the connmanctl services command - after completing all the steps beforehand of course).
The fix for me can be found here https://discourse.osmc.tv/t/could-not-connect-to-wi-fi/5654/16
It's just a matter of running connmanctl by itself, finding the wifi you want to connect to and then connecting.
Connmanctl takes care of everything, It creates a few config files similar to above (if you dig deeper they reside in a folder named after your connection in /storage/.cache/connman).