So far we used wifi on Toradex iMX6 via the “connmanctrl” by manually set:
- enable wifi
- agent on
- scan wifi
However we need to predefine SSID and password to automatic wifi connection into the Linux Image build, so don’t have to do that manually after flash the Image to the board.
We tried by setting file of the “connamnctrl” to add new connection into the “/var/lib/connman” used previously from manual set.
Unfortunately “connmanctrl> enable wifi” and “connmanctrl> agent on” and rest of the manual setup is still needed.
How to add to Yocto Build configuration for “connmanctrl” with all predefined setup wifi enabled, agent on, wifi ssid and wifi password so after reflashing to automatically connect to desired wifi network?
I expect that adding a service file to the rootfs can do what you want.
Please check the following man page.
You probably have to inject additionally a /var/lib/connman/settings file which has wifi enabled. Otherwise on first invocation connman will create one for you with wifi disabled.
Unfortunately even done like that still need manually to execute from connmanctrl console following:
connmanctrl> enable wifi
connmanctrl> agent on
connmanctrl> connect “service name”
Without these manually executed commands after reflash even with service file it won’t connect to the wifi network.
It works here. If I add the attached two files to /var/lib/connman/ a Wi-Fi connection gets established using SSID/password from the my_wifi.config file.
- What is in your files?
- How did you inject them into the rootfs?
- What looks differently in your files?
- I assume your HW works, i.e. Can you connect to Wi-Fi if you enable Wi-Fi manually with connmanctl?
Yes it is working when manually connect.
However what I see as difference is that in our version there is one more folder level named with the
connection name like:
and inside there are couple of files “data” and “settings”
Actually it is not as in your example with “my_wifi.config” at the “/var/lib/connman/” folder.
Is the “my_wifi” name in your example the long generated name similar to “wifi_5cf3703febf1_64642d777274_managed_psk”?
So to become someting like: “wifi_5cf3703febf1_64642d777274_managed_psk.config” finally?
As I understood you want to flash your image so that afterwards no manual steps to configure Wi-Fi for your SSID/Password use case are needed.
The folder /var/lib/connman/wifi_5cf3703febf1_64642d777274_managed_psk/ is created by connman once it sees your Wi-Fi NIC, not at image creation time. So no, my_wifi.config is not one of those files, it would rather be used by connman when those files are created.
So the idea is to put the two files into the rootfs (in …/var/lib/connman/) before you flash them onto the modul. To add the files you could either:
- Use a recipe which adds the files when bitbaking the image
- Add them to an unpacked legacy image in rootfs/…
- Add the files to a Toradex Easy Installer Image by untaring the rootfs.tar.xz, adding and taring again. Make sure that you do that under root to preserve file permissions / owners …
If the settings file is present on first boot then WiFi will be enabled, otherwise connman will create its default settings file with Wi-Fi disabled.
If (with Wi-Fi enabled) connman detects a Wi-Fi NIC it will take your credentials from the *.config file present and then create for said NIC the “wifi_5cf3703febf1_64642d777274_managed_psk” folder with whatever other information it wants to preserve for said NIC.