From e576a324f976b56cd880020cfc71dc99a4416efd Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 5 Aug 2026 17:27:48 -0400 Subject: [PATCH 1/9] Create hotspot.ini --- hotspot.ini | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 hotspot.ini diff --git a/hotspot.ini b/hotspot.ini new file mode 100644 index 00000000..bb8b7d3a --- /dev/null +++ b/hotspot.ini @@ -0,0 +1,11 @@ +[Hotspot] +# WiFi hotspot name +hotspot_ssid=CubeSat +# WiFi hotspot password - note: this password is stored in the clear! +hotspot_password=amsat +# Web Dashboard port number. If 80, no port needs to be entered in browser +dashboard_port=80 +# Web terminal setting during hotspot - note, there is no authentication for this! +web_term_hotspot=yes +# Web terminal setting during WiFi - note: there is no authentication for this! +web_term_wifi=no From 20b8a757b21ee5a1ca80435a4db39a3caa237b03 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 5 Aug 2026 17:34:32 -0400 Subject: [PATCH 2/9] Update pushbutton.py add read_config_ini --- pushbutton.py | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/pushbutton.py b/pushbutton.py index 996ecb0a..1ef7688e 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -7,6 +7,38 @@ import subprocess import time import os from time import sleep +import configparser + +def read_config_ini(): + global hotspot_ssid + global hotspot_password + global web_term_hotspot + global web_term_wifi + global dashboard_port + try: + # Initialize the parser + config = configparser.ConfigParser() + + # Read the file + config.read('/home/pi/CubeSatSim/hotspot.ini') + + # Access the values like a dictionary + hotspot_ssid = config['Hotspot']['hotspot_ssid'] + hotspot_password = config['Hotspot']['hotspot_password'] + web_term_hotspot = config['Hotspot']['web_term_hotspot'] + web_term_wifi = config['Hotspot']['web_term_wifi'] + dashboard_port = config.getint('Hotspot', 'dashboard_port') + + print(f"SSID: {hotspot_ssid} Password: {hotspot_password} Term Hotspot: {web_term_hotspot} Term WiFi {web_term_wifi} Port: {dashboard_port}") + + except Exception as e: + print(f"An error occurred: {e}") + print(" failed, setting defaults") + hotspot_ssid = "CubeSat" + hotspot_password = "amsat" + web_term_hotspot = "yes" + web_term_wifi = "no" + dashboard_port = 80 def blink(times): blink_time = 0.1 @@ -142,15 +174,19 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot success = 1 count = 0 while (success != 0) and (count < 5): - result = subprocess.run(['nmcli', 'device', 'wifi', 'hotspot', 'con-name', 'Hotspot', 'ifname', 'wlan0', 'ssid', 'CubeSat', 'password', 'amsatao7'], capture_output=True, text=True) + read_config_ini() + result = subprocess.run(['nmcli', 'device', 'wifi', 'hotspot', 'con-name', 'Hotspot', 'ifname', 'wlan0', 'ssid', hotspot_ssid, 'password', hotspot_password], capture_output=True, text=True) print(result, flush=True) #.stdout) count = count + 1 success = result.returncode sleep(1) + print(f"Starting Wi-Fi Hotspot with SSID: {hotspot_ssid} and password: {hotspot_password}") result = subprocess.run(['nmcli', 'connection', 'show'], capture_output=True, text=True) print(result, flush=True) sleep(2) - subprocess.Popen(['sudo', '-u', 'pi', 'ttyd', '-p', '8081', 'bash']) + if web_term_hotspot == "yes": + subprocess.Popen(['sudo', '-u', 'pi', 'ttyd', '-p', '8081', 'bash']) + print("Starting web terminal on port 8081") GPIO.setup(powerPin, GPIO.OUT) GPIO.output(powerPin, 1) From 41e69b1bad9ad1c9cee13238bd7f61a76f3d394b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 5 Aug 2026 17:47:29 -0400 Subject: [PATCH 3/9] Update install print setting up journal across boots --- install | 1 + 1 file changed, 1 insertion(+) diff --git a/install b/install index 4ec8dcaa..cee53d6c 100755 --- a/install +++ b/install @@ -266,6 +266,7 @@ 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 + echo "Setting up 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 From 1bd8662cfc6ded0d83650a23c5798e784df48536 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 5 Aug 2026 17:52:01 -0400 Subject: [PATCH 4/9] Update hotspot.ini change to amsatcubesat --- hotspot.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot.ini b/hotspot.ini index bb8b7d3a..87853c70 100644 --- a/hotspot.ini +++ b/hotspot.ini @@ -2,7 +2,7 @@ # WiFi hotspot name hotspot_ssid=CubeSat # WiFi hotspot password - note: this password is stored in the clear! -hotspot_password=amsat +hotspot_password=amsatcubesat # Web Dashboard port number. If 80, no port needs to be entered in browser dashboard_port=80 # Web terminal setting during hotspot - note, there is no authentication for this! From 99fa7b281a1c33533db26ce3879e660da2f63cc2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 5 Aug 2026 22:52:17 -0400 Subject: [PATCH 5/9] Update pushbutton.py add web terminal on wifi --- pushbutton.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pushbutton.py b/pushbutton.py index 1ef7688e..80ae21e4 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -187,7 +187,9 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot if web_term_hotspot == "yes": subprocess.Popen(['sudo', '-u', 'pi', 'ttyd', '-p', '8081', 'bash']) print("Starting web terminal on port 8081") - +elif web_term_wifi == "yes": + subprocess.Popen(['sudo', '-u', 'pi', 'ttyd', '-p', '8081', 'bash']) + print("Starting web terminal on port 8081") GPIO.setup(powerPin, GPIO.OUT) GPIO.output(powerPin, 1) while (True): From eba37f68a5e597c32759bcb76ed5144db0b169d3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 5 Aug 2026 22:55:58 -0400 Subject: [PATCH 6/9] Update pushbutton.py moved ini check --- pushbutton.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pushbutton.py b/pushbutton.py index 80ae21e4..590619d7 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -158,6 +158,7 @@ GPIO.output(powerPin, 0) GPIO.setup(push_button, GPIO.IN, pull_up_down=GPIO.PUD_UP) +read_config_ini() if not GPIO.input(push_button): # if pushbutton is held down during boot print("Activating WiFi access point!", flush=True) GPIO.output(powerPin, 1) @@ -173,8 +174,7 @@ if not GPIO.input(push_button): # if pushbutton is held down during boot GPIO.output(powerPin, 0) success = 1 count = 0 - while (success != 0) and (count < 5): - read_config_ini() + while (success != 0) and (count < 5): result = subprocess.run(['nmcli', 'device', 'wifi', 'hotspot', 'con-name', 'Hotspot', 'ifname', 'wlan0', 'ssid', hotspot_ssid, 'password', hotspot_password], capture_output=True, text=True) print(result, flush=True) #.stdout) count = count + 1 From 05f491483ab9e33e6440f08ac1c86ce17ff13fb3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 5 Aug 2026 23:02:12 -0400 Subject: [PATCH 7/9] Update pushbutton.py remove dashboard port --- pushbutton.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pushbutton.py b/pushbutton.py index 590619d7..f5b1395e 100644 --- a/pushbutton.py +++ b/pushbutton.py @@ -14,7 +14,7 @@ def read_config_ini(): global hotspot_password global web_term_hotspot global web_term_wifi - global dashboard_port +# global dashboard_port try: # Initialize the parser config = configparser.ConfigParser() @@ -27,9 +27,9 @@ def read_config_ini(): hotspot_password = config['Hotspot']['hotspot_password'] web_term_hotspot = config['Hotspot']['web_term_hotspot'] web_term_wifi = config['Hotspot']['web_term_wifi'] - dashboard_port = config.getint('Hotspot', 'dashboard_port') +# dashboard_port = config.getint('Hotspot', 'dashboard_port') - print(f"SSID: {hotspot_ssid} Password: {hotspot_password} Term Hotspot: {web_term_hotspot} Term WiFi {web_term_wifi} Port: {dashboard_port}") + print(f"SSID: {hotspot_ssid} Password: {hotspot_password} Term Hotspot: {web_term_hotspot} Term WiFi {web_term_wifi}") # : {dashboard_}") except Exception as e: print(f"An error occurred: {e}") @@ -38,7 +38,7 @@ def read_config_ini(): hotspot_password = "amsat" web_term_hotspot = "yes" web_term_wifi = "no" - dashboard_port = 80 +# dashboard_port = 80 def blink(times): blink_time = 0.1 From 5e601dffa6502fc7fadbb96458a79f19a1dcedf9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 5 Aug 2026 23:02:45 -0400 Subject: [PATCH 8/9] Update hotspot.ini remove dashboard_port --- hotspot.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot.ini b/hotspot.ini index 87853c70..fdbb8c60 100644 --- a/hotspot.ini +++ b/hotspot.ini @@ -4,7 +4,7 @@ hotspot_ssid=CubeSat # WiFi hotspot password - note: this password is stored in the clear! hotspot_password=amsatcubesat # Web Dashboard port number. If 80, no port needs to be entered in browser -dashboard_port=80 +# dashboard_port=80 # Web terminal setting during hotspot - note, there is no authentication for this! web_term_hotspot=yes # Web terminal setting during WiFi - note: there is no authentication for this! From 7b334866331da40cf749ff4d9a82a4fb39046a16 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 5 Aug 2026 23:12:57 -0400 Subject: [PATCH 9/9] Update install always setup log across boots --- install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install b/install index cee53d6c..79d48772 100755 --- a/install +++ b/install @@ -265,13 +265,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 +# if [ ! -d "/var/log/journal" ]; then # persistant journal logs across boots echo "Setting up journal logs across boots" - sudo mkdir -p /var/log/journal + sudo mkdir -p /var/log/journal &>/dev/null 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 +# fi elif [[ $(grep 'trixie' /etc/os-release) ]]; then