Skip to content

Instantly share code, notes, and snippets.

@maoueh
Last active March 31, 2022 12:30
Show Gist options
  • Star 40 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save maoueh/8260199 to your computer and use it in GitHub Desktop.
Save maoueh/8260199 to your computer and use it in GitHub Desktop.
OpenELEC (4.0.1) WIFI connection details using `connman`

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!

  1. Ensures connman daemon is running:

    ps faux | grep connmand

    If 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 connmand
    

    If 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`
  1. Ensures there is a network adapter for your WIFI card (or USB dongle or whatever):

    ifconfig

    You should see an adapter starting with wlan in 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)
    
  2. Enable connman wifi technology:

    connmanctl enable wifi

    Maybe connman will complain that wifi is already enabled, if it's the case, no problem, just move to next step.

    If connman cannot enable wifi, it probably means there is something fishy with your adapter (wrong linux driver maybe).

  3. Scan for WIFI network nearby:

    connmanctl scan wifi

    This will scan nearby network available.

  4. List found WIFI network:

    connmanctl services

    This will list all known services. A services for connman is 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_psk
    

    As you can see, there is a bunch of them. All the one starting with wifi_ are WIFI network available to connect to. The suffix _psk means it's a protected network.

    If my case, the network I want to connect to is Moth, so its service id assigned by connman is wifi_0013ef20018a_4d6f7468_managed_psk.

  5. Create the configuration file to access the network.

    The connman configuration files on OpenELEC are not at the usual location of /var/lib/connman. In the OpenELEC distribution, 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 chose moth as 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 (nano is the default one in OpenELEC):

    [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 the Name field and a description of the network in the Description field.

    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 pattern wifi_<ssid_name>.

    Then, in this section, the Type if the type of technology for the service which is wifi in our case. The Name represents the SSID network name with is Moth in my case. And finally, Passphrase is 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 Name line and put a line SSID = <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 network Moth, the configuration file would look like this when using the SSID field:

    [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).

  6. Check that connman correctly sees your new settings.

    For this, simply run:

    connmanctl scan wifi
    connmanctl services
    

    In the refreshed services list, there now should be a A* just before the network you configured, this indicates that connman knows 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_psk
    

    If the network does not have the *A before it, try restarting the connman daemon to force it to reload configuration files. First, obtain the connmand pid by running:

    ps faux | grep connmand

    And 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 -nr

    When it have restarted, run another wifi scan and check if the services has the *A flag.

  7. Connect to the network

    connmanctl connect wifi_0013ef20018a_4d6f7468_managed_psk

    Where wifi_0013ef20018a_4d6f7468_managed_psk is the servie id reported by connman for your network.

    If everything went well, should then be connected to your protected WIFI network.

Voilà and enjoy Matt

@balouken
Copy link

balouken commented May 1, 2020

Thanks @maoueh for this guide. Helped me a lot with setting up a WiFi connection via Proximus Smart WiFi on my rPi2 running LibreElec.

My config file:
`[global]
Name = proximus_smart_wifi
Description = Proximus Smart Wifi service config file

[service_wifi_proximus_smart]
Type = wifi
IPv4 = dhcp
IPv6 = auto
Name = Proximus Smart Wi-Fi
EAP = ttls
Identity = @proximuswifi.be
Phase2 = MSCHAPV2
Passphrase = `

Do this still work? Because it does not work for me...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment