01-03-2024, 09:46 PM
(01-03-2024, 04:03 PM)Tim Curtis Wrote: I verified the code in worker.php that extracts the country code from pi-imager generated wpa_supplicant and then updates cfg_network table works correctly.
What doesn't seem right is the wpa_supplicant file generated by the Pi Imager. It has country = US even though /boot/firstrun.sh shows country = GB which I specified in the imager.
Here's my test
1. Prep image using Pi-Imager 1.8.4
2. Set WiFi country to something other than US
3. Write the image
4. Insert USB-uSD dongle into a moOde Pi
# Save firstrun.sh file and examine it, verify country code
5. sudo cp /media/boot/firstrun.sh ./
# Add debug line to worker.php
6. sudo nano /media/rootfs/var/www/daemon/worker.php and add the bolded line
// Pi Imager: Import SSID/PSK/Country
if (file_exists('/etc/wpa_supplicant/wpa_supplicant.conf')) {
$moodeHeader = sysCmd('cat /etc/wpa_supplicant/wpa_supplicant.conf 2>&1 | grep "This file is automatically generated"');
sysCmd('cp /etc/wpa_supplicant/wpa_supplicant.conf /home/pi/');
7. Boot a Pi with the modified uSD card
8. SSH
# Examine country code
9. sudo cat ./wpa_supplicant.conf
It gets weirder---at least to me.
With vanilla (e.g., no moOde) Bullseye 64-bit Lite flashed with Imager options set for Germany, wpa_supplicant.conf ends up with no country code line at all.
Similarly with vanilla Bookworm 64-bit Lite, where the connection info is stored in /etc/NetworkManager/system-connections, I find no country code associated with the WiFi subsystem.
I suppose in managed (aka infrastructure) mode this perhaps doesn't matter because it's the detectable APs which dictate which frequencies are acceptable for connection. Still, I don't understand the inner workings well enough to make any definitive statement.
And in neither case is the locale properly set. In the bookworm test I'm running ATM I get (because RaspiOS comes configured for the UK)
Code:
pi@bookworm-test:~ $ locale
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=
yet the time zone is Europe/Berlin and the default keyboard settings include XKBLAYOUT="de" due to firstrun.sh.
Regards,
Kent
PS - For what it's worth, I'm running Imager v1.8.4 on a Linux laptop.