From f998c59bc97fdb9743529cb36bb3bab9f62f9ce2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 09:31:52 -0400 Subject: [PATCH 01/29] Create pushbutton.py from pi-power-button --- pushbutton.py | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 pushbutton.py diff --git a/pushbutton.py b/pushbutton.py new file mode 100644 index 00000000..3999dc3b --- /dev/null +++ b/pushbutton.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python + +# originally based on listen-for-shutdown.py from pi-power-button + +import RPi.GPIO as GPIO +import subprocess +import time +import os +from time import sleep + +def blink(times): + blink_time = 0.1 + powerPin = 16 + for i in range(times): # blink times + GPIO.output(powerPin, 0) + sleep(blink_time) + GPIO.output(powerPin, 1) + sleep(blink_time) + sleep(0.65) + +def change_mode(): + push_button = 26 + powerPin = 16 + txPin = 27 + sleep(0.75) + if GPIO.input(push_button): + print("sudo reboot -h now") + os.system("echo 'reboot due to push button!' | wall") + GPIO.setwarnings(False) + GPIO.setup(powerPin, GPIO.OUT) + GPIO.output(powerPin, 0); + subprocess.call(['reboot', '-h', 'now'], shell=False) + return + blink(1) + if GPIO.input(push_button): + print("switch to AFSK") + os.system("echo 'switch to AFSK due to push button!' | wall") + os.system("/home/pi/CubeSatSim/config -a") + return + blink(2) + if GPIO.input(push_button): + print("switch to FSK") + os.system("echo 'switch to FSK due to push button!' | wall") + os.system("/home/pi/CubeSatSim/config -f") + return + blink(3) + if GPIO.input(push_button): + print("switch to BPSK") + os.system("echo 'switch to BPSK due to push button!' | wall") + os.system("/home/pi/CubeSatSim/config -b") + return + blink(4) + if GPIO.input(push_button): + print("switch to SSTV") + os.system("echo 'switch to SSTV due to push button!' | wall") + os.system("/home/pi/CubeSatSim/config -s") + return + blink(5) + if GPIO.input(push_button): + print("switch to CW") + os.system("echo 'switch to CW due to push button!' | wall") + os.system("/home/pi/CubeSatSim/config -m") + return + blink(6) + if GPIO.input(push_button): + print("switch to Repeater") + os.system("echo 'switch to Repeater due to push button!' | wall") + os.system("/home/pi/CubeSatSim/config -e") + return + blink(7) + if GPIO.input(push_button): + print("switch to FunCube") + os.system("echo 'switch to FunCube due to push button!' | wall") + os.system("/home/pi/CubeSatSim/config -j") + return + blink(8) + if GPIO.input(push_button): + print("switch to PacSat") + os.system("echo 'switch to PacSat due to push button!' | wall") + os.system("/home/pi/CubeSatSim/config -G") + return + for i in range(3): # blink 3 times slowly + GPIO.output(powerPin, 0) + sleep(0.35) + GPIO.output(powerPin, 1) + sleep(0.35) + sleep(0.65) + if GPIO.input(push_button): + print("sudo nmcli connection up preconfigured") + os.system("sudo nmcli connection up preconfigured") + print("sudo shutdown -h now") + os.system("echo 'shutdown due to push button!' | wall") + GPIO.setwarnings(False) + GPIO.setup(powerPin, GPIO.OUT) + subprocess.call(['shutdown', '-h', 'now'], shell=False) + return + for i in range(3): # blink two times even more slowly + GPIO.output(powerPin, 0) + sleep(0.7) + GPIO.output(powerPin, 1) + sleep(0.7) + sleep(0.7) + print("toggle command and control mode") + try: + f = open("/home/pi/CubeSatSim/command_control", "r") + f.close() + print("command and control will be deactivated") + os.system('sudo rm /home/pi/CubeSatSim/command_control') + os.system("echo 'command and control deactivated by push button!' | wall") + os.system('sudo systemctl restart command') + except: + print("command and control will be activated") + os.system('touch /home/pi/CubeSatSim/command_control') + os.system("echo 'command and control activated by push button!' | wall") + os.system('sudo systemctl restart command') + sleep(1) + +powerPin = 16 +txPin = 27 +push_button = 26 +GPIO.setmode(GPIO.BCM) +GPIO.setwarnings(False) +GPIO.setup(txPin, GPIO.OUT) +GPIO.output(txPin, 0) +GPIO.setup(powerPin, GPIO.OUT) +GPIO.output(powerPin, 0) +# GPIO.output(powerPin, 1) +# sleep(0.5) +# GPIO.output(powerPin, 0) +# sleep(0.5) + +GPIO.setup(push_button, GPIO.IN, pull_up_down=GPIO.PUD_UP) +# sleep(1) +if not GPIO.input(push_button): # if pushbutton is held down during boot + print("Activating WiFi access point!") + GPIO.output(powerPin, 1) + sleep(0.1) + GPIO.output(powerPin, 0) + sleep(0.1) + GPIO.output(powerPin, 1) + sleep(0.3) + GPIO.output(powerPin, 0) + sleep(0.1) + GPIO.output(powerPin, 1) + sleep(0.3) + GPIO.output(powerPin, 0) + print("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") + os.system("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") + sleep(2) +GPIO.setup(powerPin, GPIO.OUT) +GPIO.output(powerPin, 1) +while (True): + sleep(1) + GPIO.wait_for_edge(push_button, GPIO.FALLING) + change_mode() + sleep(5) From 14439d8d90ce18c49a154abcb4fd7c81b39964b0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 09:37:08 -0400 Subject: [PATCH 02/29] Create pushbutton.system --- systemd/pushbutton.system | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 systemd/pushbutton.system diff --git a/systemd/pushbutton.system b/systemd/pushbutton.system new file mode 100644 index 00000000..fa2edf55 --- /dev/null +++ b/systemd/pushbutton.system @@ -0,0 +1,14 @@ +[Unit] +Description=pushbutton + +[Service] +TimeoutStopSec=5 +ExecStart=python3 -u /home/pi/CubeSatSim/pushbutton.py +WorkingDirectory=/home/pi/CubeSatSim +StandardOutput=inherit +StandardError=inherit +Restart=always +User=pi + +[Install] +WantedBy=default.target From 9ccbcc3a0c3949bca66a76662badab38c82f43ca Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 09:37:36 -0400 Subject: [PATCH 03/29] Rename pushbutton.system to pushbutton.service --- systemd/{pushbutton.system => pushbutton.service} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename systemd/{pushbutton.system => pushbutton.service} (100%) diff --git a/systemd/pushbutton.system b/systemd/pushbutton.service similarity index 100% rename from systemd/pushbutton.system rename to systemd/pushbutton.service From 010cf16db78642597a86b80a9c063341899f9d33 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 09:42:09 -0400 Subject: [PATCH 04/29] Update install --- install | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/install b/install index 4957dc4e..c332569a 100755 --- a/install +++ b/install @@ -741,6 +741,20 @@ else FLAG=1 fi +FILE=/etc/systemd/system/pushbutton.service +if [ -f "$FILE" ]; then + if [[ $(diff /home/pi/CubeSatSim/systemd/pushbutton.service /etc/systemd/system/pushbutton.service) ]]; then + echo "changed pushbutton.service." + sudo cp /home/pi/CubeSatSim/systemd/pushbutton.service /etc/systemd/system/pushbutton.service + FLAG=1 + else + echo "no change to pushbutton.service." + fi +else + echo "creating pushbutton.service." + sudo cp /home/pi/CubeSatSim/systemd/pushbutton.service /etc/systemd/system/pushbutton.service + FLAG=1 +fi FILE=/etc/asound.conf if [ -f "$FILE" ]; then From d9d5ba5a42c3083efcf55e1e546edb650b36dc80 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 09:45:45 -0400 Subject: [PATCH 05/29] Update install remove pi-power-button --- install | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/install b/install index c332569a..f7b565ce 100755 --- a/install +++ b/install @@ -469,28 +469,6 @@ else echo "b" > .mode fi -if [ ! -d "/home/pi/pi-power-button" ]; then - - cd - git clone https://github.com/alanbjohnston/pi-power-button.git - cd pi-power-button - git checkout master - ./script/install - sudo apt-get install -y libraspberrypi-dev - -fi - -cd /home/pi/pi-power-button - -if [ ! $(git branch --show-current | grep master-b) ]; then - - echo "updating branch of pi-power-button to master-b." - git pull - git checkout master-b - script/install - FLAG=1 -fi - git pull --no-rebase > .updated_p #git checkout master grep 'changed' /home/pi/pi-power-button/.updated_p @@ -741,6 +719,11 @@ else FLAG=1 fi +if [ ! -d "/home/pi/pi-pushbutton" ]; then + pkill -f /usr/local/bin/listen-for-shutdown.py > /dev/null + sudo rm /etc/init.d/listen-for-shutdown.sh stop > /dev/null +fi + FILE=/etc/systemd/system/pushbutton.service if [ -f "$FILE" ]; then if [[ $(diff /home/pi/CubeSatSim/systemd/pushbutton.service /etc/systemd/system/pushbutton.service) ]]; then From b9f4ed144c87e0c4cc176472e650efe94315bece Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 09:46:45 -0400 Subject: [PATCH 06/29] Update install remove rest of pi-power-button --- install | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/install b/install index f7b565ce..a0cb5d37 100755 --- a/install +++ b/install @@ -469,16 +469,6 @@ else echo "b" > .mode fi -git pull --no-rebase > .updated_p -#git checkout master -grep 'changed' /home/pi/pi-power-button/.updated_p -if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then - - echo "updating pi-power-button." - script/install - FLAG=1 -fi - if [ ! -d "/home/pi/g0kla_common" ]; then cd git clone https://github.com/alanbjohnston/g0kla_common.git From b0757b4827bd90a703163e792f9dff6670fa9880 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 09:48:20 -0400 Subject: [PATCH 07/29] Update install uninstall pi-power-button --- install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install b/install index a0cb5d37..4de24a86 100755 --- a/install +++ b/install @@ -709,7 +709,8 @@ else FLAG=1 fi -if [ ! -d "/home/pi/pi-pushbutton" ]; then +if [ ! -d "/home/pi/pi-power-button" ]; then + echo "Uninstalling pi-power-button" pkill -f /usr/local/bin/listen-for-shutdown.py > /dev/null sudo rm /etc/init.d/listen-for-shutdown.sh stop > /dev/null fi From 3203f07bf126f8a71aa223156543861745c52483 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 09:49:16 -0400 Subject: [PATCH 08/29] Update install fix uninstall pi-power-button --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index 4de24a86..df4dedde 100755 --- a/install +++ b/install @@ -709,7 +709,7 @@ else FLAG=1 fi -if [ ! -d "/home/pi/pi-power-button" ]; then +if [ -d "/home/pi/pi-power-button" ]; then echo "Uninstalling pi-power-button" pkill -f /usr/local/bin/listen-for-shutdown.py > /dev/null sudo rm /etc/init.d/listen-for-shutdown.sh stop > /dev/null From 09c505ff5ecc1a622cb8daed874dea9d57c3289b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 10:01:24 -0400 Subject: [PATCH 09/29] Update install enable pushbutton --- install | 1 + 1 file changed, 1 insertion(+) diff --git a/install b/install index df4dedde..d8312955 100755 --- a/install +++ b/install @@ -720,6 +720,7 @@ if [ -f "$FILE" ]; then if [[ $(diff /home/pi/CubeSatSim/systemd/pushbutton.service /etc/systemd/system/pushbutton.service) ]]; then echo "changed pushbutton.service." sudo cp /home/pi/CubeSatSim/systemd/pushbutton.service /etc/systemd/system/pushbutton.service + sudo systemctl enable pushbutton FLAG=1 else echo "no change to pushbutton.service." From 86f2faa798f9d08754fd5273aec867951c090762 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 10:03:59 -0400 Subject: [PATCH 10/29] Update log add pushbutton --- log | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/log b/log index c4017153..6ba02f3c 100755 --- a/log +++ b/log @@ -10,6 +10,7 @@ if [ "$1" = "-h" ] ; then echo " -p pacsat" echo " -r frequency control" echo " -f frequency display" + echo " -b pushbutton" echo "Default is the log is dumpted to the screen and written to a file." echo "If an additional r is included, the log is realtime, and exits with a Control-C" echo @@ -48,6 +49,9 @@ if [ "$REALTIME" = "1" ] ; then sleep 1 printf "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" done + elif [ "$1" = "-b" ]; then + sudo journalctl -af -u pushbutton # > /home/pi/CubeSatSim/logb.txt + cat /home/pi/CubeSatSim/logb.txt else sudo journalctl -af -u cubesatsim # > /home/pi/CubeSatSim/log.txt # cat /home/pi/CubeSatSim/log.txt @@ -67,7 +71,7 @@ else elif [ "$1" = "-p" ]; then sudo journalctl -a -u pacsatsim > /home/pi/CubeSatSim/logp.txt cat /home/pi/CubeSatSim/logp.txt - echo -e "\nCommand and Control Log file also saved as /home/pi/CubeSatSim/logp.txt" + echo -e "\nPacSat Log file also saved as /home/pi/CubeSatSim/logp.txt" elif [ "$1" = "-r" ]; then sudo journalctl -a -u frequency > /home/pi/CubeSatSim/logr.txt cat /home/pi/CubeSatSim/logr.txt @@ -75,6 +79,11 @@ else elif [ "$1" = "-f" ] ; then cat /home/pi/CubeSatSim/frequency.txt echo + elif [ "$1" = "-b" ]; then + sudo journalctl -a -u pushbutton > /home/pi/CubeSatSim/logb.txt + cat /home/pi/CubeSatSim/logb.txt + echo -e "\nPushbutton Log file also saved as /home/pi/CubeSatSim/logb.txt" + else sudo journalctl -a -u cubesatsim > /home/pi/CubeSatSim/log.txt cat /home/pi/CubeSatSim/log.txt From 4ce8cdb8b19b042bd8981218869947d4e10acd7b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 10:09:24 -0400 Subject: [PATCH 11/29] Update install remove listen-for-shutdown.sh --- install | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install b/install index d8312955..5dee03cb 100755 --- a/install +++ b/install @@ -711,8 +711,7 @@ fi if [ -d "/home/pi/pi-power-button" ]; then echo "Uninstalling pi-power-button" - pkill -f /usr/local/bin/listen-for-shutdown.py > /dev/null - sudo rm /etc/init.d/listen-for-shutdown.sh stop > /dev/null + sudo rm /etc/init.d/listen-for-shutdown.sh fi FILE=/etc/systemd/system/pushbutton.service From 7693b5b58972f63daff219f37581028e754b3e21 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 10:20:31 -0400 Subject: [PATCH 12/29] Update pushbutton.py shutdown without -h --- pushbutton.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pushbutton.py b/pushbutton.py index 3999dc3b..228323e2 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -28,8 +28,9 @@ def change_mode(): os.system("echo 'reboot due to push button!' | wall") GPIO.setwarnings(False) GPIO.setup(powerPin, GPIO.OUT) - GPIO.output(powerPin, 0); - subprocess.call(['reboot', '-h', 'now'], shell=False) + GPIO.output(powerPin, 0); + os.system("sudo reboot now") +# subprocess.call(['reboot', '-h', 'now'], shell=False) return blink(1) if GPIO.input(push_button): From 8594d29c5dd2b217070e691453cfa8ac6dde53f5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 28 Jul 2026 10:35:45 -0400 Subject: [PATCH 13/29] Update install allow nmcli to manage wifi --- install | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/install b/install index 5dee03cb..2f943ab3 100755 --- a/install +++ b/install @@ -255,6 +255,8 @@ if [[ $(grep 'bookworm' /etc/os-release) ]]; then sudo sh -c 'echo "\n" >> /boot/firmware/config.txt' + sudo sed -i 's/managed=false/managed=true/g' /etc/NetworkManager/NetworkManager.conf # allow nmcli to manage WiFi + elif [[ $(grep 'trixie' /etc/os-release) ]]; then echo "Trixie detected, installation continuing." @@ -709,9 +711,10 @@ else FLAG=1 fi -if [ -d "/home/pi/pi-power-button" ]; then +FILE=/etc/init.d/listen-for-shutdown.sh +if [ -f $FILE ]; then echo "Uninstalling pi-power-button" - sudo rm /etc/init.d/listen-for-shutdown.sh + sudo rm $FILE fi FILE=/etc/systemd/system/pushbutton.service From 7ea790cf80374db82f6dd3138c79527ebd6c6c2d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 10:39:50 -0400 Subject: [PATCH 14/29] Update gpredict.desktop run gpredict.sh --- groundstation/gpredict.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/groundstation/gpredict.desktop b/groundstation/gpredict.desktop index 69d11ecb..c3e0a72b 100644 --- a/groundstation/gpredict.desktop +++ b/groundstation/gpredict.desktop @@ -1,6 +1,6 @@ [Desktop Entry] Type=Application -Exec=/usr/bin/gpredict +Exec=/home/pi/CubeSatSim/groundstation/gpredict.sh Name=Gpredict Comment=ISS and Satellite Tracking for ARISS Radio Pi Icon=/home/pi/Icons/gpredict.png From 0b52f7174911c356cae40e5c70233dc97150701b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 10:46:36 -0400 Subject: [PATCH 15/29] Update pushbutton.service use root --- systemd/pushbutton.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemd/pushbutton.service b/systemd/pushbutton.service index fa2edf55..da0fbdef 100644 --- a/systemd/pushbutton.service +++ b/systemd/pushbutton.service @@ -8,7 +8,7 @@ WorkingDirectory=/home/pi/CubeSatSim StandardOutput=inherit StandardError=inherit Restart=always -User=pi +User=root [Install] WantedBy=default.target From 0f470314f31108e9933f91f99903446849e97408 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 10:54:46 -0400 Subject: [PATCH 16/29] Update pushbutton.py subprocess.run for sudo nmcli commands --- pushbutton.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/pushbutton.py b/pushbutton.py index 228323e2..8686f878 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -88,7 +88,12 @@ def change_mode(): sleep(0.65) if GPIO.input(push_button): print("sudo nmcli connection up preconfigured") - os.system("sudo nmcli connection up preconfigured") +### os.system("sudo nmcli connection down preconfigured") + result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) + print(result) + result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) + print(result) +### os.system("sudo nmcli connection down Hotspot-Manual") print("sudo shutdown -h now") os.system("echo 'shutdown due to push button!' | wall") GPIO.setwarnings(False) @@ -146,8 +151,31 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot sleep(0.3) GPIO.output(powerPin, 0) print("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") - os.system("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") +### os.system("sudo nmcli connection down preconfigured") + result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) + print(result) + result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) + print(result) +### os.system("sudo nmcli connection down Hotspot-Manual") +## os.system("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") +# os.system("sudo nmcli c add type wifi ifname wlan0 con-name Hotspot-Manual ssid MyHotspot") +# os.system("sudo nmcli connection modify Hotspot-Manual 802-11-wireless.mode ap 802-11-wireless.band bg") + # # os.system("sudo nmcli connection modify Hotspot-Manual wifi-sec.key-mgmt wpa-psk wifi-sec.psk 'YourPassword123' ipv4.method shared") +# os.system("sudo nmcli connection down uuid 335c2e13-cab4-40bf-a297-7ff2535ec214") # preconfigured") +# os.system("sudo nmcli device disconnect wlan0") +# os.system("sudo nmcli connection up uuid d437746a-411f-4f02-95ea-7b2f7665d59a") # Hotspot-Manual") + result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) + print(result.stdout) +# os.system("sudo nmcli connection up Hotspot-Manual") + result = subprocess.run(['nmcli', 'connection', 'up', 'Hotspot-Manual'], capture_output=True, text=True) + print(result.stdout) sleep(2) +else: + result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) + print(result.stdout) + result = subprocess.run(['nmcli', 'connection', 'up', 'preconfigured'], capture_output=True, text=True) + print(result.stdout) +# os.system("sudo nmcli connection up preconfigured") GPIO.setup(powerPin, GPIO.OUT) GPIO.output(powerPin, 1) while (True): From 5f5e7e7e53e3b63944653829ae92eb0acc285373 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 10:56:21 -0400 Subject: [PATCH 17/29] Update pushbutton.py cleanup diff --- pushbutton.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pushbutton.py b/pushbutton.py index 8686f878..feb2b0bf 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -24,6 +24,12 @@ def change_mode(): txPin = 27 sleep(0.75) if GPIO.input(push_button): +### os.system("sudo nmcli connection down preconfigured") + result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) + print(result) + result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) + print(result) +### os.system("sudo nmcli connection down Hotspot-Manual") print("sudo reboot -h now") os.system("echo 'reboot due to push button!' | wall") GPIO.setwarnings(False) @@ -151,12 +157,6 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot sleep(0.3) GPIO.output(powerPin, 0) print("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") -### os.system("sudo nmcli connection down preconfigured") - result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) - print(result) - result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) - print(result) -### os.system("sudo nmcli connection down Hotspot-Manual") ## os.system("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") # os.system("sudo nmcli c add type wifi ifname wlan0 con-name Hotspot-Manual ssid MyHotspot") # os.system("sudo nmcli connection modify Hotspot-Manual 802-11-wireless.mode ap 802-11-wireless.band bg") @@ -168,7 +168,7 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot print(result.stdout) # os.system("sudo nmcli connection up Hotspot-Manual") result = subprocess.run(['nmcli', 'connection', 'up', 'Hotspot-Manual'], capture_output=True, text=True) - print(result.stdout) + print(result.stdout) sleep(2) else: result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) From 065cb227dd9f6016b668484881f475b48af2a3b1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 11:13:28 -0400 Subject: [PATCH 18/29] Update pushbutton.py add fflush --- pushbutton.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pushbutton.py b/pushbutton.py index feb2b0bf..6dfb30ef 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -26,9 +26,9 @@ def change_mode(): if GPIO.input(push_button): ### os.system("sudo nmcli connection down preconfigured") result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) - print(result) + print(result, flush=True) result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) - print(result) + print(result, flush=True) ### os.system("sudo nmcli connection down Hotspot-Manual") print("sudo reboot -h now") os.system("echo 'reboot due to push button!' | wall") @@ -96,9 +96,9 @@ def change_mode(): print("sudo nmcli connection up preconfigured") ### os.system("sudo nmcli connection down preconfigured") result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) - print(result) + print(result, flush=True) result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) - print(result) + print(result, flush=True) ### os.system("sudo nmcli connection down Hotspot-Manual") print("sudo shutdown -h now") os.system("echo 'shutdown due to push button!' | wall") @@ -165,16 +165,16 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot # os.system("sudo nmcli device disconnect wlan0") # os.system("sudo nmcli connection up uuid d437746a-411f-4f02-95ea-7b2f7665d59a") # Hotspot-Manual") result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) - print(result.stdout) + print(result, flush=True) #.stdout) # os.system("sudo nmcli connection up Hotspot-Manual") result = subprocess.run(['nmcli', 'connection', 'up', 'Hotspot-Manual'], capture_output=True, text=True) - print(result.stdout) + print(result, flush=True) #.stdout) sleep(2) else: result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) - print(result.stdout) + print(result, flush=True) # .stdout) result = subprocess.run(['nmcli', 'connection', 'up', 'preconfigured'], capture_output=True, text=True) - print(result.stdout) + print(result, flush=True) # .stdout) # os.system("sudo nmcli connection up preconfigured") GPIO.setup(powerPin, GPIO.OUT) GPIO.output(powerPin, 1) From 23454ff97888a724f6897af769d8c7b6747d767f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 12:02:38 -0400 Subject: [PATCH 19/29] Update pushbutton.py add modify to wlan0 --- pushbutton.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pushbutton.py b/pushbutton.py index 6dfb30ef..a37ba4a2 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -164,6 +164,9 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot # os.system("sudo nmcli connection down uuid 335c2e13-cab4-40bf-a297-7ff2535ec214") # preconfigured") # os.system("sudo nmcli device disconnect wlan0") # os.system("sudo nmcli connection up uuid d437746a-411f-4f02-95ea-7b2f7665d59a") # Hotspot-Manual") + result = subprocess.run(['nmcli', 'connection', 'modify', 'Hotspot-Manual', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) + print(result, flush=True) #.stdout) + result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) print(result, flush=True) #.stdout) # os.system("sudo nmcli connection up Hotspot-Manual") From 8674a8d6352846d3cecbb3c0757f5dd72a57149b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 12:18:39 -0400 Subject: [PATCH 20/29] Update pushbutton.py add wlan0 to preconfigured --- pushbutton.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pushbutton.py b/pushbutton.py index a37ba4a2..94c82bb2 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -166,7 +166,6 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot # os.system("sudo nmcli connection up uuid d437746a-411f-4f02-95ea-7b2f7665d59a") # Hotspot-Manual") result = subprocess.run(['nmcli', 'connection', 'modify', 'Hotspot-Manual', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) print(result, flush=True) #.stdout) - result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) print(result, flush=True) #.stdout) # os.system("sudo nmcli connection up Hotspot-Manual") @@ -174,6 +173,8 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot print(result, flush=True) #.stdout) sleep(2) else: + result = subprocess.run(['nmcli', 'connection', 'modify', 'preconfigured', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) + print(result, flush=True) #.stdout) result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) print(result, flush=True) # .stdout) result = subprocess.run(['nmcli', 'connection', 'up', 'preconfigured'], capture_output=True, text=True) From 74a83194d7ded78095122c5fff5cb5dfea780a44 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 12:35:05 -0400 Subject: [PATCH 21/29] Update pushbutton.py remove connection down --- pushbutton.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pushbutton.py b/pushbutton.py index 94c82bb2..ce1635a9 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -25,10 +25,10 @@ def change_mode(): sleep(0.75) if GPIO.input(push_button): ### os.system("sudo nmcli connection down preconfigured") - result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) - print(result, flush=True) - result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) - print(result, flush=True) +# result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) +# print(result, flush=True) +# result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) +# print(result, flush=True) ### os.system("sudo nmcli connection down Hotspot-Manual") print("sudo reboot -h now") os.system("echo 'reboot due to push button!' | wall") @@ -95,10 +95,10 @@ def change_mode(): if GPIO.input(push_button): print("sudo nmcli connection up preconfigured") ### os.system("sudo nmcli connection down preconfigured") - result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) - print(result, flush=True) - result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) - print(result, flush=True) +# result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) +# print(result, flush=True) +# result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) +# print(result, flush=True) ### os.system("sudo nmcli connection down Hotspot-Manual") print("sudo shutdown -h now") os.system("echo 'shutdown due to push button!' | wall") @@ -166,8 +166,8 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot # os.system("sudo nmcli connection up uuid d437746a-411f-4f02-95ea-7b2f7665d59a") # Hotspot-Manual") result = subprocess.run(['nmcli', 'connection', 'modify', 'Hotspot-Manual', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) print(result, flush=True) #.stdout) - result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) - print(result, flush=True) #.stdout) +# result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) +# print(result, flush=True) #.stdout) # os.system("sudo nmcli connection up Hotspot-Manual") result = subprocess.run(['nmcli', 'connection', 'up', 'Hotspot-Manual'], capture_output=True, text=True) print(result, flush=True) #.stdout) @@ -175,8 +175,8 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot else: result = subprocess.run(['nmcli', 'connection', 'modify', 'preconfigured', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) print(result, flush=True) #.stdout) - result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) - print(result, flush=True) # .stdout) +# result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) +# print(result, flush=True) # .stdout) result = subprocess.run(['nmcli', 'connection', 'up', 'preconfigured'], capture_output=True, text=True) print(result, flush=True) # .stdout) # os.system("sudo nmcli connection up preconfigured") From d1b4c30670dc33ee5253ddcc9d0da16ce0504897 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 12:47:56 -0400 Subject: [PATCH 22/29] Update pushbutton.py print connection show --- pushbutton.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pushbutton.py b/pushbutton.py index ce1635a9..4e3160bb 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -165,12 +165,16 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot # os.system("sudo nmcli device disconnect wlan0") # os.system("sudo nmcli connection up uuid d437746a-411f-4f02-95ea-7b2f7665d59a") # Hotspot-Manual") result = subprocess.run(['nmcli', 'connection', 'modify', 'Hotspot-Manual', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) - print(result, flush=True) #.stdout) + print(result, flush=True) #.stdout) # result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) # print(result, flush=True) #.stdout) # os.system("sudo nmcli connection up Hotspot-Manual") result = subprocess.run(['nmcli', 'connection', 'up', 'Hotspot-Manual'], capture_output=True, text=True) print(result, flush=True) #.stdout) +# if (result.returncode != 0): + print(result.returncode) + result = subprocess.run(['nmcli', 'connection', 'show'], capture_output=True, text=True) + print(result, flush=True) sleep(2) else: result = subprocess.run(['nmcli', 'connection', 'modify', 'preconfigured', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) @@ -179,6 +183,10 @@ else: # print(result, flush=True) # .stdout) result = subprocess.run(['nmcli', 'connection', 'up', 'preconfigured'], capture_output=True, text=True) print(result, flush=True) # .stdout) +# if (result.returncode != 0): + print(result.returncode) + result = subprocess.run(['nmcli', 'connection', 'show'], capture_output=True, text=True) + print(result, flush=True) # os.system("sudo nmcli connection up preconfigured") GPIO.setup(powerPin, GPIO.OUT) GPIO.output(powerPin, 1) From 3ee6413d0015a508b74b98ce55bab783f484be6b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 12:52:11 -0400 Subject: [PATCH 23/29] Update pushbutton.py turn wifi on --- pushbutton.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pushbutton.py b/pushbutton.py index 4e3160bb..0d4774cb 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -169,6 +169,8 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot # result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) # print(result, flush=True) #.stdout) # os.system("sudo nmcli connection up Hotspot-Manual") + result = subprocess.run(['nmcli', 'radio', 'wifi', 'on'], capture_output=True, text=True) + print(result, flush=True) result = subprocess.run(['nmcli', 'connection', 'up', 'Hotspot-Manual'], capture_output=True, text=True) print(result, flush=True) #.stdout) # if (result.returncode != 0): @@ -181,6 +183,8 @@ else: print(result, flush=True) #.stdout) # result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) # print(result, flush=True) # .stdout) + result = subprocess.run(['nmcli', 'radio', 'wifi', 'on'], capture_output=True, text=True) + print(result, flush=True) result = subprocess.run(['nmcli', 'connection', 'up', 'preconfigured'], capture_output=True, text=True) print(result, flush=True) # .stdout) # if (result.returncode != 0): From 3a96325e2334285561129e81fccc205982da2a03 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 16:52:37 -0400 Subject: [PATCH 24/29] Update pushbutton.py nmcli one line --- pushbutton.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pushbutton.py b/pushbutton.py index 0d4774cb..6b0a7732 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -158,23 +158,25 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot GPIO.output(powerPin, 0) print("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") ## os.system("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") + result = subprocess.run(['nmcli', 'device', 'wifi', 'hotspot', 'con-name', 'MyHotspot', 'ifname', 'wlan0', 'ssid', 'CubeSat', 'password', 'amsatao7'], capture_output=True, text=True) + print(result, flush=True) #.stdout) # os.system("sudo nmcli c add type wifi ifname wlan0 con-name Hotspot-Manual ssid MyHotspot") # os.system("sudo nmcli connection modify Hotspot-Manual 802-11-wireless.mode ap 802-11-wireless.band bg") # # os.system("sudo nmcli connection modify Hotspot-Manual wifi-sec.key-mgmt wpa-psk wifi-sec.psk 'YourPassword123' ipv4.method shared") # os.system("sudo nmcli connection down uuid 335c2e13-cab4-40bf-a297-7ff2535ec214") # preconfigured") # os.system("sudo nmcli device disconnect wlan0") # os.system("sudo nmcli connection up uuid d437746a-411f-4f02-95ea-7b2f7665d59a") # Hotspot-Manual") - result = subprocess.run(['nmcli', 'connection', 'modify', 'Hotspot-Manual', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) - print(result, flush=True) #.stdout) +## result = subprocess.run(['nmcli', 'connection', 'modify', 'Hotspot-Manual', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) +## print(result, flush=True) #.stdout) # result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) # print(result, flush=True) #.stdout) # os.system("sudo nmcli connection up Hotspot-Manual") - result = subprocess.run(['nmcli', 'radio', 'wifi', 'on'], capture_output=True, text=True) - print(result, flush=True) - result = subprocess.run(['nmcli', 'connection', 'up', 'Hotspot-Manual'], capture_output=True, text=True) - print(result, flush=True) #.stdout) +## result = subprocess.run(['nmcli', 'radio', 'wifi', 'on'], capture_output=True, text=True) +## print(result, flush=True) +## result = subprocess.run(['nmcli', 'connection', 'up', 'Hotspot-Manual'], capture_output=True, text=True) +## print(result, flush=True) #.stdout) # if (result.returncode != 0): - print(result.returncode) +# print(result.returncode) result = subprocess.run(['nmcli', 'connection', 'show'], capture_output=True, text=True) print(result, flush=True) sleep(2) From 3af021d674fec56c28a720c4c1c28c5bb53e9cc3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 17:30:04 -0400 Subject: [PATCH 25/29] Update pushbutton.py nmcli up to 5 times --- pushbutton.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/pushbutton.py b/pushbutton.py index 6b0a7732..4bff85c1 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -156,10 +156,16 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot GPIO.output(powerPin, 1) sleep(0.3) GPIO.output(powerPin, 0) - print("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") + success = 1 + count = 0 + while (success != 0) and (count < 5): +# print("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") ## os.system("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") - result = subprocess.run(['nmcli', 'device', 'wifi', 'hotspot', 'con-name', 'MyHotspot', 'ifname', 'wlan0', 'ssid', 'CubeSat', 'password', 'amsatao7'], capture_output=True, text=True) - print(result, flush=True) #.stdout) + result = subprocess.run(['nmcli', 'device', 'wifi', 'hotspot', 'con-name', 'Hotspot', 'ifname', 'wlan0', 'ssid', 'CubeSat', 'password', 'amsatao7'], capture_output=True, text=True) + print(result, flush=True) #.stdout) + count = count +1 + success = result.returncode + sleep(1) # os.system("sudo nmcli c add type wifi ifname wlan0 con-name Hotspot-Manual ssid MyHotspot") # os.system("sudo nmcli connection modify Hotspot-Manual 802-11-wireless.mode ap 802-11-wireless.band bg") # # os.system("sudo nmcli connection modify Hotspot-Manual wifi-sec.key-mgmt wpa-psk wifi-sec.psk 'YourPassword123' ipv4.method shared") @@ -180,17 +186,17 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot result = subprocess.run(['nmcli', 'connection', 'show'], capture_output=True, text=True) print(result, flush=True) sleep(2) -else: - result = subprocess.run(['nmcli', 'connection', 'modify', 'preconfigured', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) - print(result, flush=True) #.stdout) +###else: +### result = subprocess.run(['nmcli', 'connection', 'modify', 'preconfigured', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) +### print(result, flush=True) #.stdout) # result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) # print(result, flush=True) # .stdout) - result = subprocess.run(['nmcli', 'radio', 'wifi', 'on'], capture_output=True, text=True) - print(result, flush=True) - result = subprocess.run(['nmcli', 'connection', 'up', 'preconfigured'], capture_output=True, text=True) - print(result, flush=True) # .stdout) +### result = subprocess.run(['nmcli', 'radio', 'wifi', 'on'], capture_output=True, text=True) +### print(result, flush=True) +### result = subprocess.run(['nmcli', 'connection', 'up', 'preconfigured'], capture_output=True, text=True) +### print(result, flush=True) # .stdout) # if (result.returncode != 0): - print(result.returncode) +### print(result.returncode) result = subprocess.run(['nmcli', 'connection', 'show'], capture_output=True, text=True) print(result, flush=True) # os.system("sudo nmcli connection up preconfigured") From a49c773fbf7f26422df4f007374ae0c7a9a26947 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 17:35:23 -0400 Subject: [PATCH 26/29] Update pushbutton.py cleanup --- pushbutton.py | 84 +++++++++++---------------------------------------- 1 file changed, 17 insertions(+), 67 deletions(-) diff --git a/pushbutton.py b/pushbutton.py index 4bff85c1..dcf58e4e 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -24,13 +24,7 @@ def change_mode(): txPin = 27 sleep(0.75) if GPIO.input(push_button): -### os.system("sudo nmcli connection down preconfigured") -# result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) -# print(result, flush=True) -# result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) -# print(result, flush=True) -### os.system("sudo nmcli connection down Hotspot-Manual") - print("sudo reboot -h now") + print("sudo reboot -h now", flush=True) os.system("echo 'reboot due to push button!' | wall") GPIO.setwarnings(False) GPIO.setup(powerPin, GPIO.OUT) @@ -40,49 +34,49 @@ def change_mode(): return blink(1) if GPIO.input(push_button): - print("switch to AFSK") + print("switch to AFSK", flush=True) os.system("echo 'switch to AFSK due to push button!' | wall") os.system("/home/pi/CubeSatSim/config -a") return blink(2) if GPIO.input(push_button): - print("switch to FSK") + print("switch to FSK", flush=True) os.system("echo 'switch to FSK due to push button!' | wall") os.system("/home/pi/CubeSatSim/config -f") return blink(3) if GPIO.input(push_button): - print("switch to BPSK") + print("switch to BPSK", flush=True) os.system("echo 'switch to BPSK due to push button!' | wall") os.system("/home/pi/CubeSatSim/config -b") return blink(4) if GPIO.input(push_button): - print("switch to SSTV") + print("switch to SSTV", flush=True) os.system("echo 'switch to SSTV due to push button!' | wall") os.system("/home/pi/CubeSatSim/config -s") return blink(5) if GPIO.input(push_button): - print("switch to CW") + print("switch to CW", flush=True) os.system("echo 'switch to CW due to push button!' | wall") os.system("/home/pi/CubeSatSim/config -m") return blink(6) if GPIO.input(push_button): - print("switch to Repeater") + print("switch to Repeater", flush=True) os.system("echo 'switch to Repeater due to push button!' | wall") os.system("/home/pi/CubeSatSim/config -e") return blink(7) if GPIO.input(push_button): - print("switch to FunCube") + print("switch to FunCube", flush=True) os.system("echo 'switch to FunCube due to push button!' | wall") os.system("/home/pi/CubeSatSim/config -j") return blink(8) if GPIO.input(push_button): - print("switch to PacSat") + print("switch to PacSat", flush=True) os.system("echo 'switch to PacSat due to push button!' | wall") os.system("/home/pi/CubeSatSim/config -G") return @@ -93,14 +87,7 @@ def change_mode(): sleep(0.35) sleep(0.65) if GPIO.input(push_button): - print("sudo nmcli connection up preconfigured") -### os.system("sudo nmcli connection down preconfigured") -# result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) -# print(result, flush=True) -# result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) -# print(result, flush=True) -### os.system("sudo nmcli connection down Hotspot-Manual") - print("sudo shutdown -h now") + print("sudo shutdown -h now", flush=True) os.system("echo 'shutdown due to push button!' | wall") GPIO.setwarnings(False) GPIO.setup(powerPin, GPIO.OUT) @@ -112,16 +99,16 @@ def change_mode(): GPIO.output(powerPin, 1) sleep(0.7) sleep(0.7) - print("toggle command and control mode") + print("toggle command and control mode", flush=True) try: f = open("/home/pi/CubeSatSim/command_control", "r") f.close() - print("command and control will be deactivated") + print("command and control will be deactivated", flush=True) os.system('sudo rm /home/pi/CubeSatSim/command_control') os.system("echo 'command and control deactivated by push button!' | wall") os.system('sudo systemctl restart command') except: - print("command and control will be activated") + print("command and control will be activated", flush=True) os.system('touch /home/pi/CubeSatSim/command_control') os.system("echo 'command and control activated by push button!' | wall") os.system('sudo systemctl restart command') @@ -136,15 +123,11 @@ GPIO.setup(txPin, GPIO.OUT) GPIO.output(txPin, 0) GPIO.setup(powerPin, GPIO.OUT) GPIO.output(powerPin, 0) -# GPIO.output(powerPin, 1) -# sleep(0.5) -# GPIO.output(powerPin, 0) -# sleep(0.5) GPIO.setup(push_button, GPIO.IN, pull_up_down=GPIO.PUD_UP) -# sleep(1) + if not GPIO.input(push_button): # if pushbutton is held down during boot - print("Activating WiFi access point!") + print("Activating WiFi access point!", flush=True) GPIO.output(powerPin, 1) sleep(0.1) GPIO.output(powerPin, 0) @@ -159,47 +142,14 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot success = 1 count = 0 while (success != 0) and (count < 5): -# print("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") -## os.system("sudo nmcli device wifi hotspot con-name HotSpot ifname wlan0 ssid CubeSat password amsatao7") result = subprocess.run(['nmcli', 'device', 'wifi', 'hotspot', 'con-name', 'Hotspot', 'ifname', 'wlan0', 'ssid', 'CubeSat', 'password', 'amsatao7'], capture_output=True, text=True) print(result, flush=True) #.stdout) - count = count +1 + count = count + 1 success = result.returncode sleep(1) -# os.system("sudo nmcli c add type wifi ifname wlan0 con-name Hotspot-Manual ssid MyHotspot") -# os.system("sudo nmcli connection modify Hotspot-Manual 802-11-wireless.mode ap 802-11-wireless.band bg") - # # os.system("sudo nmcli connection modify Hotspot-Manual wifi-sec.key-mgmt wpa-psk wifi-sec.psk 'YourPassword123' ipv4.method shared") -# os.system("sudo nmcli connection down uuid 335c2e13-cab4-40bf-a297-7ff2535ec214") # preconfigured") -# os.system("sudo nmcli device disconnect wlan0") -# os.system("sudo nmcli connection up uuid d437746a-411f-4f02-95ea-7b2f7665d59a") # Hotspot-Manual") -## result = subprocess.run(['nmcli', 'connection', 'modify', 'Hotspot-Manual', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) -## print(result, flush=True) #.stdout) -# result = subprocess.run(['nmcli', 'connection', 'down', 'preconfigured'], capture_output=True, text=True) -# print(result, flush=True) #.stdout) -# os.system("sudo nmcli connection up Hotspot-Manual") -## result = subprocess.run(['nmcli', 'radio', 'wifi', 'on'], capture_output=True, text=True) -## print(result, flush=True) -## result = subprocess.run(['nmcli', 'connection', 'up', 'Hotspot-Manual'], capture_output=True, text=True) -## print(result, flush=True) #.stdout) -# if (result.returncode != 0): -# print(result.returncode) - result = subprocess.run(['nmcli', 'connection', 'show'], capture_output=True, text=True) - print(result, flush=True) - sleep(2) -###else: -### result = subprocess.run(['nmcli', 'connection', 'modify', 'preconfigured', 'connection.interface-name', 'wlan0'], capture_output=True, text=True) -### print(result, flush=True) #.stdout) -# result = subprocess.run(['nmcli', 'connection', 'down', 'Hotspot-Manual'], capture_output=True, text=True) -# print(result, flush=True) # .stdout) -### result = subprocess.run(['nmcli', 'radio', 'wifi', 'on'], capture_output=True, text=True) -### print(result, flush=True) -### result = subprocess.run(['nmcli', 'connection', 'up', 'preconfigured'], capture_output=True, text=True) -### print(result, flush=True) # .stdout) -# if (result.returncode != 0): -### print(result.returncode) result = subprocess.run(['nmcli', 'connection', 'show'], capture_output=True, text=True) print(result, flush=True) -# os.system("sudo nmcli connection up preconfigured") + sleep(2) GPIO.setup(powerPin, GPIO.OUT) GPIO.output(powerPin, 1) while (True): From 92b0e8b854256bc2315a2d785b8bcdf60152ca49 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 18:38:31 -0400 Subject: [PATCH 27/29] Update install add enable pushbutton --- install | 1 + 1 file changed, 1 insertion(+) diff --git a/install b/install index 2f943ab3..7dbf9c09 100755 --- a/install +++ b/install @@ -730,6 +730,7 @@ if [ -f "$FILE" ]; then else echo "creating pushbutton.service." sudo cp /home/pi/CubeSatSim/systemd/pushbutton.service /etc/systemd/system/pushbutton.service + sudo systemctl enable pushbutton FLAG=1 fi From 5b28a52346a0c9da61a8502e1c96378c77282496 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 19:15:27 -0400 Subject: [PATCH 28/29] Update log add -b all --- log | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/log b/log index 6ba02f3c..8963b64f 100755 --- a/log +++ b/log @@ -29,19 +29,19 @@ if [ "$REALTIME" = "1" ] ; then sleep 2 if [ "$1" = "-t" ] ; then - sudo journalctl -af -u transmit # > /home/pi/CubeSatSim/logt.txt + sudo journalctl -b all -af -u transmit # > /home/pi/CubeSatSim/logt.txt # cat /home/pi/CubeSatSim/logt.txt # echo -e "\nTransmit Log file also saved as /home/pi/CubeSatSim/logt.txt" elif [ "$1" = "-c" ]; then - sudo journalctl -af -u command # > /home/pi/CubeSatSim/logc.txt + sudo journaclt -b all -af -u command # > /home/pi/CubeSatSim/logc.txt cat /home/pi/CubeSatSim/logc.txt # echo -e "\nCommand and Control Log file also saved as /home/pi/CubeSatSim/logc.txt" elif [ "$1" = "-p" ]; then - sudo journalctl -af -u pacsatsim # > /home/pi/CubeSatSim/logp.txt + sudo journalctl -b all -af -u pacsatsim # > /home/pi/CubeSatSim/logp.txt cat /home/pi/CubeSatSim/logp.txt # echo -e "\nCommand and Control Log file also saved as /home/pi/CubeSatSim/logp.txt" elif [ "$1" = "-r" ]; then - sudo journalctl -af -u frequency # > /home/pi/CubeSatSim/logr.txt + sudo journalctl -b all -af -u frequency # > /home/pi/CubeSatSim/logr.txt elif [ "$1" = "-f" ] ; then while true; do cat /home/pi/CubeSatSim/frequency.txt | tr -d '\n' @@ -50,10 +50,10 @@ if [ "$REALTIME" = "1" ] ; then printf "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" done elif [ "$1" = "-b" ]; then - sudo journalctl -af -u pushbutton # > /home/pi/CubeSatSim/logb.txt + sudo journalctl -b all -af -u pushbutton # > /home/pi/CubeSatSim/logb.txt cat /home/pi/CubeSatSim/logb.txt else - sudo journalctl -af -u cubesatsim # > /home/pi/CubeSatSim/log.txt + sudo journalctl -b all -af -u cubesatsim # > /home/pi/CubeSatSim/log.txt # cat /home/pi/CubeSatSim/log.txt # echo -e "\nLog file also saved as /home/pi/CubeSatSim/log.txt" fi @@ -61,31 +61,31 @@ if [ "$REALTIME" = "1" ] ; then else if [ "$1" = "-t" ] ; then - sudo journalctl -a -u transmit > /home/pi/CubeSatSim/logt.txt + sudo journalctl -b all -a -u transmit > /home/pi/CubeSatSim/logt.txt cat /home/pi/CubeSatSim/logt.txt echo -e "\nTransmit Log file also saved as /home/pi/CubeSatSim/logt.txt" elif [ "$1" = "-c" ]; then - sudo journalctl -a -u command > /home/pi/CubeSatSim/logc.txt + sudo journalctl -b all -a -u command > /home/pi/CubeSatSim/logc.txt cat /home/pi/CubeSatSim/logc.txt echo -e "\nCommand and Control Log file also saved as /home/pi/CubeSatSim/logc.txt" elif [ "$1" = "-p" ]; then - sudo journalctl -a -u pacsatsim > /home/pi/CubeSatSim/logp.txt + sudo journalctl -b all -a -u pacsatsim > /home/pi/CubeSatSim/logp.txt cat /home/pi/CubeSatSim/logp.txt echo -e "\nPacSat Log file also saved as /home/pi/CubeSatSim/logp.txt" elif [ "$1" = "-r" ]; then - sudo journalctl -a -u frequency > /home/pi/CubeSatSim/logr.txt + sudo journalctl -b all -a -u frequency > /home/pi/CubeSatSim/logr.txt cat /home/pi/CubeSatSim/logr.txt echo -e "\nFrequency Log file also saved as /home/pi/CubeSatSim/logf.txt" elif [ "$1" = "-f" ] ; then cat /home/pi/CubeSatSim/frequency.txt echo elif [ "$1" = "-b" ]; then - sudo journalctl -a -u pushbutton > /home/pi/CubeSatSim/logb.txt + sudo journalctl -b all -a -u pushbutton > /home/pi/CubeSatSim/logb.txt cat /home/pi/CubeSatSim/logb.txt echo -e "\nPushbutton Log file also saved as /home/pi/CubeSatSim/logb.txt" else - sudo journalctl -a -u cubesatsim > /home/pi/CubeSatSim/log.txt + sudo journalctl -b all -a -u cubesatsim > /home/pi/CubeSatSim/log.txt cat /home/pi/CubeSatSim/log.txt echo -e "\nLog file also saved as /home/pi/CubeSatSim/log.txt" fi From ea4ccf94f14c290b6d8d3481e47647a685fb5395 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Jul 2026 19:17:59 -0400 Subject: [PATCH 29/29] Update install add persistent journal logs --- install | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install b/install index 7dbf9c09..9dd12e3d 100755 --- a/install +++ b/install @@ -257,6 +257,13 @@ if [[ $(grep 'bookworm' /etc/os-release) ]]; then sudo sed -i 's/managed=false/managed=true/g' /etc/NetworkManager/NetworkManager.conf # allow nmcli to manage WiFi + if [ ! -d "/var/log/journal" ]; then # persistant journal logs across boots + sudo mkdir -p /var/log/journal + sudo systemd-tmpfiles --create --prefix /var/log/journal + sudo systemctl restart systemd-journal-flush.service + sudo sed -i 's/Storage=volatile/Storage=persistent/g' /etc/systemd/journald.conf + fi + elif [[ $(grep 'trixie' /etc/os-release) ]]; then echo "Trixie detected, installation continuing."