diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-pinout.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-pinout.sh index a09654c..65faa52 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-pinout.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-pinout.sh @@ -40,8 +40,8 @@ luckfox=" VBUS 5V ●│● │ USB-C │ ●│● 1V8 OUT \n\ GND ●│● │ │ ●│● GND \n\ 3V3 IN/OUT ●│● ─────── ●│● 145 (1.8V) \n\ -UART-TX2 DEBUG, 42 ●│● ●│● 144 (1.8V) \n\ -UART-RX2 DEBUG, 43 ●│● [BTN] ●│● 4 \n\ +UART2-TX DEBUG, 42 ●│● ●│● 144 (1.8V) \n\ +UART2-RX DEBUG, 43 ●│● [BTN] ●│● 4 \n\ CS0, 48 ●│● ●│● 55, IRQ \n\ CLK, 49 ●│● ●│● 54 BUSY \n\ MOSI, 50 ●│● ●│● 59, I2C SCL \n\ @@ -91,7 +91,39 @@ femtofox="\ S U R N N N N S X X N V V \n\ 0 S Q D D D D T 4 4 D \n\ Y " -femtofox_zero="coming soon" + + +femtofox_zero="\ + _____ _____ \n\ + │() \ / ()│ \n\ + │ \ / │ \n\ + │ ───────── │ \n\ + │ ───────────────── │ \n\ + │ ●│● USB-C ●│● │ \n\ + │ ●│● ●│● │ \n\ + │ ●│● ●│● │ \n\ + │ ●│● LUCKFOX ●│● │ \n\ + │ ●│● PICO MINI ●│● │ \n\ + │ ●│● ●│● │ \n\ + │ ●│● FOXHOLE ●│● │ \n\ + │ ●│● ●│● │ \n\ + │ ●│● ●│● │ \n\ + │ ●│● ●│● │ \n\ + │ ●│● ●│● │ \n\ + │ ────●─●─●─●─●──── │ \n\ + │─── ───────────── ───│ \n\ + GND │ ● │ │ HT-RA62 │ │ ● │ GND \n\ + 3V3 │ ● │ │ _______ │ │ ● │ 3V3 \n\ +UART4-RX │ ● │ │ │ │ │ │ ● │ I2C SDA \n\ +UART4-TX │ ● │ │ │ WIO │ │ │ ● │ I2C SCL \n\ + │─── │ │SX 1262│ │ ───│ \n\ + │ │ │_______│ │ ● │ UNUSED \n\ + │ ───────────── ● │ GND \n\ + │() ETH ()│ \n\ + ────────●─●─●─●─●──────── \n\ + R R G T T \n\ + X X N X X \n\ + - + D - + \n" femtofox_tiny="coming soon" diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femtofox-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femtofox-config new file mode 100644 index 0000000..0b0257f --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femtofox-config @@ -0,0 +1,365 @@ +#!/bin/bash +# prevents weirdness over tty +export NCURSES_NO_UTF8_ACS=1 +export TERM=xterm-256color +export LANG=C.UTF-8 + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root." + echo "Try \`sudo femtofox-config\`." + exit 1 +fi + +# pause +pause() { + echo "Press any key to continue..." + read -n 1 -s -r +} + +# Function to handle Wi-Fi settings +wifi_settings() { + local title="Wifi settings" + wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf" + while true; do + local option="" + option=$(dialog --menu "Wifi settings" 15 40 4 \ + 1 "View wifi settings" \ + 2 "Change wifi settings" \ + 3 "Restart wifi" \ + 4 "Back to Main Menu" 3>&1 1>&2 2>&3) + + exit_status=$? # This line checks the exit status of the dialog command + if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog + break + fi + + case $option in + 1) + wifi_country=$(grep -m 1 "^country=" "$wpa_supplicant_conf" | cut -d '=' -f 2) + wifi_ssid=$(grep -m 1 '^\s*ssid=' "$wpa_supplicant_conf" | cut -d '"' -f 2) + wifi_psk=$(grep -m 1 '^\s*psk=' "$wpa_supplicant_conf" | cut -d '"' -f 2) + if [ "$(cat /root/.portduino/default/prefs/config.proto | protoc --decode_raw | awk '/4 {/, /}/ {if ($1 == "1:") print $2}')" -eq 1 ]; then + mesh_wifi_status="enabled" + else + mesh_wifi_status="disabled" + fi + dialog --title "$title" --msgbox "\ +SSID: $wifi_ssid\n\ +Password: $wifi_psk\n\ +Country: $wifi_country\n\ +Meshtastic wifi: $mesh_wifi_status\n\ +\n\ +Connected to: $(iwconfig 2>/dev/null | grep -i 'ESSID' | awk -F 'ESSID:"' '{print $2}' | awk -F '"' '{print $1}')\n\ +Signal Strength: $(iwconfig 2>/dev/null | grep -i 'Signal level' | awk -F 'Signal level=' '{print $2}' | awk '{print $1}')\n\ +Current IP: $(hostname -I | awk '{print $1}')\n\ +For more details, enter \`iwconfig\`. + " 0 0 + ;; + 2) + local wifi_ssid="" + local wifi_psk="" + local wifi_country="" + wifi_ssid=$(dialog --title "$title" --inputbox "Enter Wi-Fi SSID:" 8 40 3>&1 1>&2 2>&3) + wifi_psk=$(dialog --title "$title" --inputbox "Enter Wi-Fi Password:" 8 40 3>&1 1>&2 2>&3) + wifi_country=$(dialog --title "$title" --inputbox "Enter Country Code (e.g., US, DE) - optional:" 9 40 3>&1 1>&2 2>&3) + cmd="femto-wifi-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\"" + [ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\"" + echo $cmd + if [ -z "$wifi_ssid" ]; then + dialog --title "$title" --msgbox "\nSSID is required." 8 40 + return + fi + eval $cmd + dialog --title "$title" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: $wifi_psk\nCountry: $wifi_country\nMeshtastic wifi setting set to ON" 10 40 + ;; + 3) + dialog --title "Wifi restart" --msgbox "Wifi will be restarted.\nMeshtastic wifi setting will be set to ON." 7 50 + femto-wifi-config.sh -r + ;; + 4) + return + ;; + esac + done +} + +# Function to handle misc settings +misc_settings() { + local title="Misc Settings" + while true; do + local option="" + option=$(dialog --menu "Misc Settings" 15 40 4 \ + 1 "Set system timezone" \ + 2 "Ham radio support" \ + 3 "Re-run first-boot script" \ + 4 "Display pinout" \ + 5 "Run OEM luckfox-config" \ + 6 "Back to Main Menu" 3>&1 1>&2 2>&3) + + exit_status=$? # This line checks the exit status of the dialog command + if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog + break + fi + + case $option in + 1) + femto-set-timezone.sh + ;; + 2) + dialog --title "$title" --msgbox "Amateur radio support can be added in kernel for:\n\n\ +Amateur Radio AX.25 Level 2 protocol\n\ +AX.25 DAMA Slave support\n\ +Amateur Radio NET/ROM protocol\n\ +Amateur Radio X.25 PLP (Rose)\n\ +Serial port KISS driver\n\ +Serial port 6PACK driver\n\ +BPQ Ethernet driver\n\ +BAYCOM ser12 fullduplex driver for AX.25\n\ +BAYCOM ser12 halfduplex driver for AX.25\n\ +YAM driver for AX.25\n\ +AM/FM Radio receivers/transmitters\n\ +Software defined radio (SDR)\n\ +Maxim 2175 RF to Bits tuner\n\ +Silicon Labs Si470x FM Radio Receiver support\n\ +Silicon Labs Si470x FM Radio Receiver support with USB\n\ +Silicon Labs Si470x FM Radio Receiver support with I2C\n\ +Silicon Labs Si4713 FM Radio with RDS Transmitter support\n\ +Silicon Labs Si4713 FM Radio Transmitter support with USB\n\ +Silicon Labs Si4713 FM Radio Transmitter support with I2C\n\ +Silicon Labs Si4713 FM Radio Transmitter support\n\ +AverMedia MR 800 USB FM radio support\n\ +D-Link/GemTek USB FM radio support\n\ +Guillemot MAXI Radio FM 2000 radio\n\ +Griffin radioSHARK USB radio receiver\n\ +Griffin radioSHARK2 USB radio receiver\n\ +Keene FM Transmitter USB support\n\ +Thanko's Raremono AM/FM/SW radio support\n\ +Masterkit MA901 USB FM radio support\n\ +TEA5764 I2C FM radio support\n\ +SAA7706H Car Radio DSP\n\ +TEF6862 Car Radio Enhanced Selectivity Tuner\n\ +Texas Instruments WL1273 I2C FM Radio\n\ +Renesas Digital Radio Interface (DRIF)" 20 65 + dialog --title "$title" --msgbox "To add support, kernel modules for all these will be copied to \`/lib/modules/5.10.160/\`,\ +then \`depmod\` will be run. To remove support, those modules will be deleted.\n\nAfter installation, many redundant network interfaces will appear." 11 50 + #add code to choose add or remove + cp /oem/usr/ko/ham/* /lib/modules/5.10.160/ + depmod -a 5.10.160 + ;; + 3) + dialog --title "$title" --yesno "Rerunning the first-boot script will add support for RTC (real time clock), \ +set the eth0 MAC address and Meshtastic nodeID to a derivative of the CPU serial number and enable wifi in Meshtastic settings. \ +Rerunning the script will not cause any issues if these things are already in place. Femtofox will reboot after execution.\n\nConfirm?" 12 60 + if [ $? -eq 0 ]; then #unless cancel/no + runonce.sh + fi + ;; + 4) + dialog --title "$title" --msgbox "$(femto-pinout.sh -a | sed 's/|n/\\n/g')" 0 0 + ;; + 5) + luckfox-config + ;; + 6) + return + ;; + esac + done +} + +#set lora radio +set_lora_radio() { + while true; do + local option="" + option=$(dialog --menu "Misc" 0 0 10 \ + 1 "ebyte-e22-900m30s" \ + 2 "ebyte-e22-900m22s" \ + 3 "ebyte-e80-900m22s" \ + 4 "heltec-ht-ra62" \ + 5 "seeed-wio-sx1262" \ + 6 "waveshare-sx126x-xxxm" \ + 7 "ai-thinker-ra-01sh" \ + 8 "sx1262_tcxo" \ + 9 "sx1262_xtal" \ + 10 "lr1121_tcxo" \ + 11 "none (simulated radio)" \ + 12 "Back to Main Menu" 3>&1 1>&2 2>&3) + + exit_status=$? # This line checks the exit status of the dialog command + if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog + break + fi + + local radio="" + case $option in + 1) + radio="sx1262_tcxo" + ;; + 2) + radio="sx1262_tcxo" + ;; + 3) + radio="sx1262_xtal" + ;; + 4) + radio="sx1262_tcxo" + ;; + 5) + radio="sx1262_tcxo" + ;; + 6) + radio="sx1262_xtal" + ;; + 7) + radio="sx1262_xtal" + ;; + 8) + radio="sx1262_tcxo" + ;; + 9) + radio="sx1262_xtal" + ;; + 10) + radio="lr1121_tcxo" + ;; + 11) + radio="none" + ;; + 12) + return + ;; + esac + if [ -n "$radio" ]; then #if a radio was selected + femto-meshtasticd-config.sh -l "$radio" + return + fi + done +} + +# Function to handle Meshtasticd settings +meshtasticd_settings() { + local title="Meshtasticd Settings" + while true; do + local option="" + option=$(dialog --menu "$title" 19 50 4 \ + 1 "Get current configuration URL & QR code" \ + 2 "Set new configuration URL" \ + 3 "Get current lora radio selection" \ + 4 "Set LoRa radio" \ + 5 "View current admin keys" \ + 6 "Set admin key" \ + 7 "Clear admin keys" \ + 8 "Enable legacy admin channel" \ + 9 "Disable legacy admin channel" \ + 10 "Upgrade Meshtasticd" \ + 11 "Uninstall Meshtasticd" \ + 12 "Back to Main Menu" 3>&1 1>&2 2>&3) + + exit_status=$? # This line checks the exit status of the dialog command + if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog + break + fi + + case $option in + 1) #Get current configuration URL & QR code) + femto-meshtasticd-config.sh -g + pause + ;; + 2) + newurl=$(dialog --title "Meshtastic URL" --inputbox "New Meshtasticd URL (SHIFT+INS to paste):" 8 50 3>&1 1>&2 2>&3) + if [ -n "$newurl" ]; then #if a URL was entered + dialog --title "$title" --yesno "New Meshtasticd URL:\n$newurl\n\nConfirm?" 15 60 + if [ $? -eq 0 ]; then #unless cancel/no + femto-meshtasticd-config.sh -q "$newurl" + pause + fi + fi + ;; + 3) + dialog --title "LoRa radio" --msgbox "Currently configured LoRa radio: $(femto-meshtasticd-config.sh -k)" 6 40 + ;; + 4) + set_lora_radio + ;; + 5) + echo "Getting admin keys..." + dialog --title "Admin keys" --msgbox "Up to 3 admin keys are permitted, more will be ignored.\n\nKeys:$(femto-meshtasticd-config.sh -v | tail -n 1 | sed 's/|n/\\n/g')" 0 0 + ;; + 6) #set admin key) + key=$(dialog --title "Meshtastic Admin Key" --inputbox "Meshtastic admin key - up to 3, more will be ignored.\n(SHIFT+INS to paste):" 8 50 3>&1 1>&2 2>&3) + if [ -n "$key" ]; then #if a URL was entered + femto-meshtasticd-config.sh -a "$key" + pause + fi + ;; + 7) + dialog --title "$title" --yesno "Meshtasticd can have up to 3 admin keys.\nClear admin key list?" 0 0 + if [ $? -eq 0 ]; then #unless cancel/no + femto-meshtasticd-config.sh -c + pause + fi + ;; + 8) #enable legacy) + dialog --title "$title" --yesno "Enable legacy admin channel?" 0 0 + if [ $? -eq 0 ]; then #unless cancel/no + femto-meshtasticd-config.sh -e + pause + fi + ;; + 9) #disable legacy) + dialog --title "$title" --yesno "Disable legacy admin channel?" 0 0 + if [ $? -eq 0 ]; then #unless cancel/no + femto-meshtasticd-config.sh -d + pause + fi + ;; + 10) #Upgrade meshtasticd) + dialog --title "$title" --yesno "Upgrade Meshtasticd?\nRequires internet connection." 0 0 + if [ $? -eq 0 ]; then #unless cancel/no + femto-meshtasticd-config.sh -u + pause + fi + ;; + 11) + dialog --title "$title" --yesno "Uninstall Meshtasticd?" 0 0 + if [ $? -eq 0 ]; then + femto-meshtasticd-config.sh -r + dialog --msgbox "Meshtasticd uninstalled. To purge all remnants, run \`sudo apt purge\`.\nAfter reinstallation but before first launch, run \`sudo runonce.sh\`." 8 40 + fi + pause + ;; + 12) + return + ;; + esac + done +} + + +# Main menu +while true; do + choice=$(dialog --title "$(date)" --menu "Femtofox Config" 15 40 5 \ + 1 "Wi-Fi" \ + 2 "Meshtasticd" \ + 3 "Misc" \ + 4 "Software" \ + 5 "Help" \ + 6 "Exit" 3>&1 1>&2 2>&3) + + exit_status=$? # This line checks the exit status of the dialog command + + if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog + break + fi + + case $choice in + 1) wifi_settings ;; + 2) meshtasticd_settings ;; + 3) misc_settings ;; + 4) software_settings ;; + 5) femto_help ;; + 6) break ;; + *) dialog --msgbox "Invalid choice, please try again." 8 40 ;; + esac +done +