Workaround for meshtastic API incommunicado issue

This commit is contained in:
nagumii 2025-01-19 18:20:58 +02:00
parent 11e5a7b055
commit e4a237abb9
3 changed files with 24 additions and 16 deletions

View file

@ -10,6 +10,8 @@ fi
luckfox-config load
systemctl restart meshtasticd #TEMPORARY bugfix
# try enable RTC
echo 'ds1307 0x68' | sudo tee /sys/class/i2c-adapter/i2c-3/new_device > /dev/null 2>&1

View file

@ -206,27 +206,26 @@ logging() {
# at some point this will be moved to a different script, and have many functions instead of one giant dump
system_info() {
local cpu_architecture="$(uname -m) ($(dpkg --print-architecture) $(python3 -c "import platform; print(platform.architecture()[0])"))"
local cpu_model="$(dmesg | grep "soc_id" | sed -n 's/.*soc_id: //p')"
local cpu_architecture="$(uname -m) ($(dpkg --print-architecture) $(python3 -c "import platform; print(platform.architecture()[0])"))"
local cpu_temp="$(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp) / 1000" | bc)°C"
local cpu_serial="$(awk '/Serial/ {print $3}' /proc/cpuinfo)"
local cpu_speed="$(lscpu | grep "CPU min MHz" | awk '{print int($4)}')-$(lscpu | grep "CPU max MHz" | awk '{print int($4)}')mhz"
local cpu_serial="$(awk '/Serial/ {print $3}' /proc/cpuinfo)"
local microsd_size="$(df --block-size=1 / | awk 'NR==2 {total=$2; avail=$4; total_human=sprintf("%.2f", total/1024/1024/1024); avail_human=sprintf("%.2f", avail/1024/1024/1024); printf "%.2f GB (%.2f%% free)", total_human, (avail/total)*100}')"
local memory="$(free -m | awk 'NR==2{printf "%d MB (%.2f%% free)\n", $2, 100 - (($3/$2)*100)}')"
local swap="$(free -m | awk 'NR==3 {if ($2 > 1000) {printf "%.2f GB (%.2f%% free)", $2/1024, ($4/$2)*100} else {printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}}')"
local mounted_drives="$([ "$(for dir in /mnt/*/; do echo -n "/mnt${dir#"/mnt"} "; done)" ] && echo "Mounted drives: $(for dir in /mnt/*; do echo -n "/mnt${dir#"/mnt"} "; done | sed 's/\/$//')")"
local os_version="Foxbuntu v$(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release)$(output=$(grep -o 'patch=[1-9][0-9]*' /etc/foxbuntu-release | cut -d= -f2) && [ -n "$output" ] && echo ".$output")$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release) ($(lsb_release -d | awk -F'\t' '{print $2}') $(lsb_release -c | awk -F'\t' '{print $2}'))"
local system_uptime="$(uptime -p | awk '{$1=""; print $0}' | sed -e 's/ day\b/d/g' -e 's/ hour\b/h/g' -e 's/ hours\b/h/g' -e 's/ minute\b/m/g' -e 's/ minutes\b/m/g' | sed 's/,//g')"
local logging_enabled="$(logging "check" | sed 's/\x1b\[[0-9;]*m//g')"
local boot_modules="$(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")"
local i2c_addresses="$(i2cdetect -y 3 | awk 'NR>1 {for(i=2;i<=17;i++) if ($i == "ff" || $i == "UU") { printf "0x%02x ", (i-2) + (NR-2)*16} }' | tr -d '\n' )"
local kernel_active_modules="$(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ' && echo)"
local kernel_boot_modules="$(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")"
local wifi_status="$(replace_colors "$(femto-network-config.sh -w | grep -v '^$' | grep -v '^Hostname')")" #remove hostname line, as it's identical to the one in ethernet settings
local eth_status="$(replace_colors "$(femto-network-config.sh -e)")"
local usb_devices="$(lsusb | grep -v 'root hub' | awk 'NR>0{printf "USB: "; for(i=7;i<=NF;i++) printf "%s ", $i; print ""} END {if (NR == 0) printf "USB: None detected"}')"
local kernel_modules_active="$(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ' && echo)"
local lora_radio="$(replace_colors "$(femto-meshtasticd-config.sh -k)")"
local meshtasticd_service_status="$(replace_colors "$(femto-meshtasticd-config.sh -S)")"
local meshtasticd_info="$(replace_colors "$(femto-meshtasticd-config.sh -i)")"
local usb_mode="$(cat /sys/devices/platform/ff3e0000.usb2-phy/otg_mode)"
local spi0_state="$([ "$(awk -F= '/^SPI0_M0_STATUS/ {print $2}' /etc/luckfox.cfg)" -eq 1 ] && echo "enabled" || echo "disabled")"
local spi0_speed="$((0x$(xxd -p /sys/firmware/devicetree/base/spi@ff500000/spidev@0/spi-max-frequency | tr -d '\n')))"
@ -234,7 +233,13 @@ system_info() {
local i2c3_speed="$(awk -F= '/^I2C3_M1_SPEED/ {print $2}' /etc/luckfox.cfg)"
local uart3_state="$([ "$(awk -F= '/^UART3_M1_STATUS/ {print $2}' /etc/luckfox.cfg)" -eq 1 ] && echo "enabled" || echo "disabled")"
local uart4_state="$([ "$(awk -F= '/^UART4_M1_STATUS/ {print $2}' /etc/luckfox.cfg)" -eq 1 ] && echo "enabled" || echo "disabled")"
local lora_radio="$(replace_colors "$(femto-meshtasticd-config.sh -k)")"
local usb_devices="$(lsusb | grep -v 'root hub' | awk 'NR>0{printf "USB: "; for(i=7;i<=NF;i++) printf "%s ", $i; print ""} END {if (NR == 0) printf "USB: None detected"}')"
local i2c_addresses="$(i2cdetect -y 3 | awk 'NR>1 {for(i=2;i<=17;i++) if ($i == "ff" || $i == "UU") { printf "0x%02x ", (i-2) + (NR-2)*16} }' | tr -d '\n' )"
local meshtasticd_service_status="$(replace_colors "$(femto-meshtasticd-config.sh -S)")"
local meshtasticd_info="$(replace_colors "$(femto-meshtasticd-config.sh -i)")"
echo -e "\
Femtofox\n\
Core: $(cat /sys/firmware/devicetree/base/model)\n\
@ -243,15 +248,15 @@ Kernel version: $(uname -r)\n\
Uptime: $system_uptime\n\
Logging: $logging_enabled\n\
System time: $(date)\n\
K modules active: $kernel_modules_active\n\
K boot modules: $boot_modules\n\
K modules active: $kernel_active_modules\n\
K boot modules: $kernel_boot_modules\n\
\n\
CPU:\n\
Architecture: $cpu_architecture\n\
Model: $cpu_model\n\
Serial # $cpu_serial\n\
Architecture: $cpu_architecture\n\
Speed: $cpu_speed x $(nproc) cores\n\
Temperature: $cpu_temp
Temperature: $cpu_temp\n\
Serial # $cpu_serial\n\
\n\
Storage:\n\
microSD size: $microsd_size\n\

View file

@ -20,13 +20,14 @@ log_message() {
if [ $arg_count -eq 0 ]; then
dialog --msgbox "$1" 12 50
else
echo $1
echo -e $1
fi
}
set_timezone() {
if timedatectl set-timezone "$1"; then
log_message "\nTime zone set to $1 (UTC$(date +%z)) successfully."
exit 0
else
log_message "\nFailed to set the time zone to $1."
exit 1