From e1355f0afddf7736ea21fa0c68e8477c86575bab Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 31 Dec 2022 01:33:56 -0500 Subject: [PATCH 01/60] detect Pi Zero 3.3V, start payload, then do nothing --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 173ff180..9d31db61 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -116,7 +116,7 @@ void setup() { // if Pi is present, run Payload OK software /// load_files(); -/* +/**/ pinMode(PI_3V3_PIN, INPUT); Serial.print("Pi 3.3V: "); Serial.println(digitalRead(PI_3V3_PIN)); @@ -124,10 +124,10 @@ void setup() { Serial.print("Pi Zero present, so running Payload OK code instead of CubeSatSim code."); start_payload(); while(true) { - payload_OK_only(); +// payload_OK_only(); } } -*/ +/**/ // configure STEM Payload sensors // pinMode(PI_3V3_PIN, OUTPUT); From 4f12636244a78b25875cd8e901c312903b4eb96b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 31 Dec 2022 01:40:49 -0500 Subject: [PATCH 02/60] force Pi Zero detected --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 9d31db61..fe1d9ab9 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -120,7 +120,8 @@ void setup() { pinMode(PI_3V3_PIN, INPUT); Serial.print("Pi 3.3V: "); Serial.println(digitalRead(PI_3V3_PIN)); - if (digitalRead(PI_3V3_PIN) == HIGH) { +// if (digitalRead(PI_3V3_PIN) == HIGH) { + { Serial.print("Pi Zero present, so running Payload OK code instead of CubeSatSim code."); start_payload(); while(true) { From b49fe72090c29fbe934c9d0af76df4c0c61ef155 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 31 Dec 2022 01:44:39 -0500 Subject: [PATCH 03/60] move Pi Zero detect code to config_gpio --- cubesatsim/cubesatsim.ino | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fe1d9ab9..93e73dc7 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -116,19 +116,19 @@ void setup() { // if Pi is present, run Payload OK software /// load_files(); -/**/ +/* pinMode(PI_3V3_PIN, INPUT); Serial.print("Pi 3.3V: "); Serial.println(digitalRead(PI_3V3_PIN)); -// if (digitalRead(PI_3V3_PIN) == HIGH) { - { + if (digitalRead(PI_3V3_PIN) == HIGH) { +// { Serial.print("Pi Zero present, so running Payload OK code instead of CubeSatSim code."); start_payload(); while(true) { // payload_OK_only(); } } -/**/ +*/ // configure STEM Payload sensors // pinMode(PI_3V3_PIN, OUTPUT); @@ -3609,6 +3609,19 @@ void config_gpio() { for (int i = 6; i < 29; i++) { pinMode(i, INPUT); } + + pinMode(PI_3V3_PIN, INPUT); + Serial.print("Pi 3.3V: "); + Serial.println(digitalRead(PI_3V3_PIN)); +// if (digitalRead(PI_3V3_PIN) == HIGH) { + { + Serial.print("Pi Zero present, so running Payload OK code instead of CubeSatSim code."); + start_payload(); + while(true) { +// payload_OK_only(); + } + } + // set audio out to TXC board pinMode(AUDIO_OUT_PIN, OUTPUT); From 7d7a7b38bfb6d717d8de74870b76bfc2c20ba45f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 31 Dec 2022 01:51:39 -0500 Subject: [PATCH 04/60] print waiting after config --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 93e73dc7..7101d540 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3618,6 +3618,8 @@ void config_gpio() { Serial.print("Pi Zero present, so running Payload OK code instead of CubeSatSim code."); start_payload(); while(true) { + Serial.println("waiting"); + sleep(3.0); // payload_OK_only(); } } From 8b7a7b5fb7e7fcc9e7387a8a017d64a43b5018f9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 31 Dec 2022 01:54:54 -0500 Subject: [PATCH 05/60] check for Pi Zero back in --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 7101d540..98531a74 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3613,8 +3613,8 @@ void config_gpio() { pinMode(PI_3V3_PIN, INPUT); Serial.print("Pi 3.3V: "); Serial.println(digitalRead(PI_3V3_PIN)); -// if (digitalRead(PI_3V3_PIN) == HIGH) { - { + if (digitalRead(PI_3V3_PIN) == HIGH) { +// { Serial.print("Pi Zero present, so running Payload OK code instead of CubeSatSim code."); start_payload(); while(true) { From afcdd3d8875617f40fcd6510eb65860b00889d2c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 31 Dec 2022 01:56:03 -0500 Subject: [PATCH 06/60] run payload_OK_only --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 98531a74..9982e415 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3618,9 +3618,9 @@ void config_gpio() { Serial.print("Pi Zero present, so running Payload OK code instead of CubeSatSim code."); start_payload(); while(true) { - Serial.println("waiting"); - sleep(3.0); -// payload_OK_only(); +// Serial.println("waiting"); +// sleep(3.0); + payload_OK_only(); } } From c8570acf2169b374beeb3b66671f2da041ce7f94 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 31 Dec 2022 01:57:36 -0500 Subject: [PATCH 07/60] added def for payload_ok_only --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 9982e415..8bb11e18 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2878,7 +2878,7 @@ void read_payload() // delay(100); } -/* +/**/ void payload_OK_only() { payload_str[0] = '\0'; // clear the payload string @@ -3067,7 +3067,7 @@ void payload_OK_only() delay(100); } -*/ +/**/ /* void eeprom_word_write(int addr, int val) { From a396067a141ac410efdc4bdee14285f433183a0f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 11 Jan 2023 16:46:11 -0500 Subject: [PATCH 08/60] added back wifi.h --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8bb11e18..4a824522 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -36,7 +36,7 @@ #include "hardware/sync.h" // wait for interrupt #include "RPi_Pico_ISR_Timer.h" #include "RPi_Pico_TimerInterrupt.h" -//#include +#include #include "hardware/gpio.h" #include "hardware/adc.h" //#include "SSTV-Arduino-Scottie1-Library.h" From 027ece49bb570d5b3555c18cfada4a76f65cb327 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 11 Jan 2023 16:54:41 -0500 Subject: [PATCH 09/60] add Wifi join --- cubesatsim/cubesatsim.ino | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 4a824522..58030d0c 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -203,6 +203,13 @@ void setup() { Serial.print(" "); Serial.println(millis()); */ + +//SSID of your network +char ssid[] = "CubeSatSim"; +//password of your WPA Network +char pass[] = "amsatao7"; + WiFi.begin(ssid, pass); + } void loop() { From 662be636909ca56e8f4271e943d8d51017eae550 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 11 Jan 2023 19:33:18 -0500 Subject: [PATCH 10/60] changed RSSI --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index d5e6ee9c..763b3825 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -108,7 +108,7 @@ #define XS2 15 #define XS3 16 -#define RSSI 0 +#define RSSI_ 0 #define IHU_TEMP 2 #define SPIN 1 From e2da861e7633dfdbf6cc554b299543811703bc41 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 11 Jan 2023 19:34:11 -0500 Subject: [PATCH 11/60] changed RSSI --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 58030d0c..ce4d4753 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -1135,7 +1135,7 @@ void get_tlm_fox() { encodeA(b_max, 30 + head_offset, (int)(voltage_max[mapping[BUS]] * 100)); encodeB(b_max, 46 + head_offset, (int)(current_max[mapping[BUS]] + 0.5) + 2048); - encodeB(b_max, 37 + head_offset, (int)(other_max[RSSI] + 0.5) + 2048); + encodeB(b_max, 37 + head_offset, (int)(other_max[RSSI_] + 0.5) + 2048); encodeA(b_max, 39 + head_offset, (int)(other_max[IHU_TEMP] * 10 + 0.5)); encodeB(b_max, 31 + head_offset, ((int)(other_max[SPIN] * 10)) + 2048); @@ -1184,7 +1184,7 @@ void get_tlm_fox() { encodeB(b_min, 46 + head_offset, (int)(current_min[mapping[BUS]] + 0.5) + 2048); encodeB(b_min, 31 + head_offset, ((int)(other_min[SPIN] * 10)) + 2048); - encodeB(b_min, 37 + head_offset, (int)(other_min[RSSI] + 0.5) + 2048); + encodeB(b_min, 37 + head_offset, (int)(other_min[RSSI_] + 0.5) + 2048); encodeA(b_min, 39 + head_offset, (int)(other_min[IHU_TEMP] * 10 + 0.5)); if (sensor_min[0] != 1000.0) // make sure values are valid @@ -1220,7 +1220,7 @@ void get_tlm_fox() { encodeA(b, 33 + head_offset, (int)(sensor[PRES] + 0.5)); // Pressure encodeB(b, 34 + head_offset, (int)(sensor[ALT] * 10.0 + 0.5)); // Altitude encodeA(b, 36 + head_offset, Resets); - encodeB(b, 37 + head_offset, (int)(other[RSSI] + 0.5) + 2048); + encodeB(b, 37 + head_offset, (int)(other[RSSI_] + 0.5) + 2048); encodeA(b, 39 + head_offset, (int)(other[IHU_TEMP] * 10 + 0.5)); encodeB(b, 40 + head_offset, (int)(sensor[GYRO_X] + 0.5) + 2048); encodeA(b, 42 + head_offset, (int)(sensor[GYRO_Y] + 0.5) + 2048); From d5c48e0628355478e4cd461621d7514064b7ad91 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 11 Jan 2023 19:36:21 -0500 Subject: [PATCH 12/60] changed A --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 763b3825..28927dd5 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -82,7 +82,7 @@ #define TRUE 1 #define FALSE 0 -#define A 1 +#define A_ 1 #define B 2 #define C 3 #define D 4 From a49cd8be2f6e7f1b7d1f56fc920d4b618e3d6ee7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 11 Jan 2023 19:38:09 -0500 Subject: [PATCH 13/60] changed A --- cubesatsim/cubesatsim.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index ce4d4753..16358d98 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -730,26 +730,26 @@ void get_tlm_ao7() { int tlm[7][5]; memset(tlm, 0, sizeof tlm); - tlm[1][A] = (int)(voltage[mapping[BUS]] / 15.0 + 0.5) % 100; // Current of 5V supply to Pi + tlm[1][A_] = (int)(voltage[mapping[BUS]] / 15.0 + 0.5) % 100; // Current of 5V supply to Pi tlm[1][B] = (int)(99.5 - current[mapping[PLUS_X]] / 10.0) % 100; // +X current [4] tlm[1][C] = (int)(99.5 - current[mapping[MINUS_X]] / 10.0) % 100; // X- current [10] tlm[1][D] = (int)(99.5 - current[mapping[PLUS_Y]] / 10.0) % 100; // +Y current [7] - tlm[2][A] = (int)(99.5 - current[mapping[MINUS_Y]] / 10.0) % 100; // -Y current [10] + tlm[2][A_] = (int)(99.5 - current[mapping[MINUS_Y]] / 10.0) % 100; // -Y current [10] tlm[2][B] = (int)(99.5 - current[mapping[PLUS_Z]] / 10.0) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel tlm[2][C] = (int)(99.5 - current[mapping[MINUS_Z]] / 10.0) % 100; // -Z current (was timestamp) tlm[2][D] = (int)(50.5 + current[mapping[BAT]] / 10.0) % 100; // NiMH Battery current // tlm[3][A] = abs((int)((voltage[mapping[BAT]] * 10.0) - 65.5) % 100); if (voltage[mapping[BAT]] > 4.6) - tlm[3][A] = (int)((voltage[mapping[BAT]] * 10.0) - 65.5) % 100; // 7.0 - 10.0 V for old 9V battery + tlm[3][A_] = (int)((voltage[mapping[BAT]] * 10.0) - 65.5) % 100; // 7.0 - 10.0 V for old 9V battery else - tlm[3][A] = (int)((voltage[mapping[BAT]] * 10.0) + 44.5) % 100; // 0 - 4.5 V for new 3 cell battery + tlm[3][A_] = (int)((voltage[mapping[BAT]] * 10.0) + 44.5) % 100; // 0 - 4.5 V for new 3 cell battery tlm[3][B] = (int)(voltage[mapping[BUS]] * 10.0) % 100; // 5V supply to Pi // tlm[4][A] = (int)((95.8 - other[IHU_TEMP]) / 1.48 + 0.5) % 100; // was [B] but didn't display in online TLM spreadsheet - tlm[4][A] = (int)((95.8 - analogReadTemp()) / 1.48 + 0.5) % 100; // was [B] but didn't display in online TLM spreadsheet + tlm[4][A_] = (int)((95.8 - analogReadTemp()) / 1.48 + 0.5) % 100; // was [B] but didn't display in online TLM spreadsheet tlm[6][B] = 0; tlm[6][D] = 49 + rand() % 3; From fca5c78557824c08d09c93dc74455f0f4a00ab4c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 11 Jan 2023 19:55:47 -0500 Subject: [PATCH 14/60] changed B, C, D --- cubesatsim/cubesatsim.ino | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 16358d98..e87b0443 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -731,14 +731,14 @@ void get_tlm_ao7() { memset(tlm, 0, sizeof tlm); tlm[1][A_] = (int)(voltage[mapping[BUS]] / 15.0 + 0.5) % 100; // Current of 5V supply to Pi - tlm[1][B] = (int)(99.5 - current[mapping[PLUS_X]] / 10.0) % 100; // +X current [4] - tlm[1][C] = (int)(99.5 - current[mapping[MINUS_X]] / 10.0) % 100; // X- current [10] - tlm[1][D] = (int)(99.5 - current[mapping[PLUS_Y]] / 10.0) % 100; // +Y current [7] + tlm[1][B_] = (int)(99.5 - current[mapping[PLUS_X]] / 10.0) % 100; // +X current [4] + tlm[1][C_] = (int)(99.5 - current[mapping[MINUS_X]] / 10.0) % 100; // X- current [10] + tlm[1][D_] = (int)(99.5 - current[mapping[PLUS_Y]] / 10.0) % 100; // +Y current [7] tlm[2][A_] = (int)(99.5 - current[mapping[MINUS_Y]] / 10.0) % 100; // -Y current [10] - tlm[2][B] = (int)(99.5 - current[mapping[PLUS_Z]] / 10.0) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel - tlm[2][C] = (int)(99.5 - current[mapping[MINUS_Z]] / 10.0) % 100; // -Z current (was timestamp) - tlm[2][D] = (int)(50.5 + current[mapping[BAT]] / 10.0) % 100; // NiMH Battery current + tlm[2][B_] = (int)(99.5 - current[mapping[PLUS_Z]] / 10.0) % 100; // +Z current [10] // was 70/2m transponder power, AO-7 didn't have a Z panel + tlm[2][C_] = (int)(99.5 - current[mapping[MINUS_Z]] / 10.0) % 100; // -Z current (was timestamp) + tlm[2][D_] = (int)(50.5 + current[mapping[BAT]] / 10.0) % 100; // NiMH Battery current // tlm[3][A] = abs((int)((voltage[mapping[BAT]] * 10.0) - 65.5) % 100); if (voltage[mapping[BAT]] > 4.6) @@ -746,13 +746,13 @@ void get_tlm_ao7() { else tlm[3][A_] = (int)((voltage[mapping[BAT]] * 10.0) + 44.5) % 100; // 0 - 4.5 V for new 3 cell battery - tlm[3][B] = (int)(voltage[mapping[BUS]] * 10.0) % 100; // 5V supply to Pi + tlm[3][B_] = (int)(voltage[mapping[BUS]] * 10.0) % 100; // 5V supply to Pi // tlm[4][A] = (int)((95.8 - other[IHU_TEMP]) / 1.48 + 0.5) % 100; // was [B] but didn't display in online TLM spreadsheet tlm[4][A_] = (int)((95.8 - analogReadTemp()) / 1.48 + 0.5) % 100; // was [B] but didn't display in online TLM spreadsheet - tlm[6][B] = 0; - tlm[6][D] = 49 + rand() % 3; + tlm[6][B_] = 0; + tlm[6][D_] = 49 + rand() % 3; /* // Display tlm From 1ab904a9d3df4b9eea5096a51f8ff29c4ded1d5d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 11 Jan 2023 19:56:34 -0500 Subject: [PATCH 15/60] changed B, C, D --- cubesatsim/cubesatsim.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 28927dd5..f6719b1f 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -83,9 +83,9 @@ #define FALSE 0 #define A_ 1 -#define B 2 -#define C 3 -#define D 4 +#define B_ 2 +#define C_ 3 +#define D_ 4 #define PLUS_X 0 #define PLUS_Y 1 #define BAT 2 From c95ee19afd638f78f529e67b7708122657ce6410 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 12 Jan 2023 07:08:26 -0500 Subject: [PATCH 16/60] added PROMPT_WIFI --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index f6719b1f..fba8e7f4 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -129,6 +129,7 @@ #define PROMPT_FORMAT 12 #define PROMPT_REBOOT 13 #define PROMPT_I2CSCAN 14 +#define PROMPT_WIFI 15 #define PAYLOAD_QUERY 1 #define PAYLOAD_RESET 2 From 242c02bf43307c049478a941ee32afbe9192eae0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 12 Jan 2023 07:18:46 -0500 Subject: [PATCH 17/60] added PROMPT_WIFI code --- cubesatsim/cubesatsim.ino | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index e87b0443..fc55221b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -203,13 +203,14 @@ void setup() { Serial.print(" "); Serial.println(millis()); */ - + +/* //SSID of your network char ssid[] = "CubeSatSim"; //password of your WPA Network char pass[] = "amsatao7"; WiFi.begin(ssid, pass); - +*/ } void loop() { @@ -4315,6 +4316,11 @@ void serial_input() { prompt = PROMPT_DEBUG; break; + case 'w': + Serial.println("Connect to WiFi"); + prompt = PROMPT_WIFI; + break; + default: Serial.println("Not a command\n"); @@ -4515,7 +4521,31 @@ void prompt_for_input() { else Serial.println("off"); break; + + case PROMPT_WIFI: + char ssid[30], pass[30]; + Serial.println("Enter the credentials for your WiFi network"); + + Serial.print("Enter WiFi SSID: "); + get_serial_string(); + + print_string(serial_string); + + if (strlen(serial_string) > 0) { + strcpy(serial_string, ssid); + Serial.print("Enter WiFi password: "); + get_serial_string(); + if ( strlen(serial_string) > 0) { + strcpy(serial_string, pass); + Serial.println("Connecting to Wifi"); + WiFi.begin(ssid, pass); + } else + Serial.println("No password entered."); + } else + Serial.println("No SSID entered."); + break; + case PROMPT_I2CSCAN: Serial.print("I2C scan"); From dda6518ef5389fd98a981bf0b2b423d2e8fd0ded Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 12 Jan 2023 08:19:25 -0500 Subject: [PATCH 18/60] add mitt --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fc55221b..ed251477 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -45,6 +45,8 @@ #include "picosstvpp.h" #include "pico/bootrom.h" #include "hardware/watchdog.h" +#include + // jpg files to be stored in flash storage on Pico (FS 512kB setting) #include "sstv1.h" From 28dd8392ee192fa3c635babe8e52d173c22e61f0 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 12 Jan 2023 08:22:12 -0500 Subject: [PATCH 19/60] add clients --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index ed251477..33b38da9 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -67,6 +67,8 @@ unsigned long micros3; //WiFiServer server(port); //WiFiClient client; +WiFiClient net; +MQTTClient client; //#define PICO_W // define if Pico W board. Otherwise, compilation fail for Pico or runtime fail if compile as Pico W From 05db2fb5f0c3bf10c794b38b7c3839f8e5702b11 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 13 Jan 2023 08:36:58 -0500 Subject: [PATCH 20/60] read ADC gpio 29 --- cubesatsim/cubesatsim.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 33b38da9..04131ebe 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3690,6 +3690,10 @@ void config_gpio() { pinMode(AUDIO_IN_PIN, INPUT); Serial.print("Audio In: "); Serial.println(analogRead(AUDIO_IN_PIN)); + + pinMode(29); + Serial.print("ADC3: "); + Serial.println(analogRead(29)); pinMode(PTT_PIN, OUTPUT); // PTT active LOW digitalWrite(PTT_PIN, HIGH); From 49a31a0e9012edb8c572bdba87a693b5d4a96bd8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 13 Jan 2023 08:38:15 -0500 Subject: [PATCH 21/60] typo --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 04131ebe..bcda9f72 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3691,7 +3691,7 @@ void config_gpio() { Serial.print("Audio In: "); Serial.println(analogRead(AUDIO_IN_PIN)); - pinMode(29); + pinMode(29, INPUT); Serial.print("ADC3: "); Serial.println(analogRead(29)); From 032903f5e44aa556809bff0b7e7b2c948105c83c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 13 Jan 2023 09:16:24 -0500 Subject: [PATCH 22/60] moved gpio29 read before LED --- cubesatsim/cubesatsim.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index bcda9f72..fdeedbe1 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3638,6 +3638,11 @@ void config_gpio() { // set audio out to TXC board pinMode(AUDIO_OUT_PIN, OUTPUT); + + + pinMode(29, INPUT); + Serial.print("ADC3: "); + Serial.println(analogRead(29)); // set LEDs and blink once // if (!wifi) @@ -3691,9 +3696,6 @@ void config_gpio() { Serial.print("Audio In: "); Serial.println(analogRead(AUDIO_IN_PIN)); - pinMode(29, INPUT); - Serial.print("ADC3: "); - Serial.println(analogRead(29)); pinMode(PTT_PIN, OUTPUT); // PTT active LOW digitalWrite(PTT_PIN, HIGH); From 3cf02e63c9693c6b30f1cdadd5741acf6a51a6d9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 13 Jan 2023 09:26:02 -0500 Subject: [PATCH 23/60] use detect wifi --- cubesatsim/cubesatsim.ino | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index fdeedbe1..74e5aac7 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -157,12 +157,12 @@ void setup() { // if ((i2c_bus3 == false) || (mode == FSK)) // force simulated telemetry mode for FSK config_simulated_telem(); -/* +/**/ if (check_for_wifi()) { wifi = true; - configure_wifi(); +// configure_wifi(); } -*/ +/**/ start_button_isr(); // setup_sstv(); @@ -3639,11 +3639,6 @@ void config_gpio() { // set audio out to TXC board pinMode(AUDIO_OUT_PIN, OUTPUT); - - pinMode(29, INPUT); - Serial.print("ADC3: "); - Serial.println(analogRead(29)); - // set LEDs and blink once // if (!wifi) Serial.println("Blinking pins"); @@ -3695,8 +3690,11 @@ void config_gpio() { pinMode(AUDIO_IN_PIN, INPUT); Serial.print("Audio In: "); Serial.println(analogRead(AUDIO_IN_PIN)); + + pinMode(29, INPUT); + Serial.print("ADC3: "); + Serial.println(analogRead(29)); - pinMode(PTT_PIN, OUTPUT); // PTT active LOW digitalWrite(PTT_PIN, HIGH); @@ -3829,7 +3827,7 @@ void client_print_string(char *string) } client.println(" "); } - +*/ bool check_for_wifi() { #ifndef PICO_W @@ -3840,14 +3838,17 @@ bool check_for_wifi() { // stdio_init_all(); - adc_init(); - adc_gpio_init(29); - adc_select_input(3); +// adc_init(); +// adc_gpio_init(29); + pinMode(29, INPUT); +// adc_select_input(3); const float conversion_factor = 3.3f / (1 << 12); - uint16_t result = adc_read(); +// uint16_t result = adc_read(); + uint16_t result = analogRead(29); // Serial.printf("ADC3 value: 0x%03x, voltage: %f V\n", result, result * conversion_factor); - if (result < 0x100) { +// if (result < 0x100) { + if (result < 0x10) { Serial.println("\nPico W detected!\n"); return(true); } @@ -3857,7 +3858,7 @@ bool check_for_wifi() { } } - +/* void check_for_browser() { if (!wifi) return; @@ -4533,6 +4534,7 @@ void prompt_for_input() { break; case PROMPT_WIFI: + if (wifi) { char ssid[30], pass[30]; Serial.println("Enter the credentials for your WiFi network"); @@ -4553,7 +4555,9 @@ void prompt_for_input() { Serial.println("No password entered."); } else Serial.println("No SSID entered."); - + } else + Serial.println("WiFi not available"); + break; case PROMPT_I2CSCAN: From 12e68a08d531bab83fddd9aae96bd107d6b06e10 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 13 Jan 2023 09:30:28 -0500 Subject: [PATCH 24/60] added print for WiFi disabled in code --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 74e5aac7..4dc43742 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3831,7 +3831,8 @@ void client_print_string(char *string) bool check_for_wifi() { #ifndef PICO_W - + + Serial.println("WiFi disabled in software"); return(false); // skip check if not Pico W board or compilation will fail #endif From 1220eed5b801c58892455b04db3d8e99384c1519 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 13 Jan 2023 09:32:06 -0500 Subject: [PATCH 25/60] enable WiFi --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 4dc43742..2b5cf22c 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -70,7 +70,7 @@ unsigned long micros3; WiFiClient net; MQTTClient client; -//#define PICO_W // define if Pico W board. Otherwise, compilation fail for Pico or runtime fail if compile as Pico W +#define PICO_W // define if Pico W board. Otherwise, compilation fail for Pico or runtime fail if compile as Pico W byte green_led_counter = 0; char call[] = "AMSAT"; // put your callsign here From 65b30451128f789fbf69f273607aec7a3a22025d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 13 Jan 2023 09:37:56 -0500 Subject: [PATCH 26/60] print wifi variable --- cubesatsim/cubesatsim.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 2b5cf22c..c2fced8a 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4535,6 +4535,7 @@ void prompt_for_input() { break; case PROMPT_WIFI: + Serial.println(wifi); if (wifi) { char ssid[30], pass[30]; Serial.println("Enter the credentials for your WiFi network"); From 4389feab794216dbb6bd7595acd7346946374c6f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 13 Jan 2023 09:41:04 -0500 Subject: [PATCH 27/60] don't prompt for wifi --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c2fced8a..0c3dbd40 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4330,7 +4330,7 @@ void serial_input() { case 'w': Serial.println("Connect to WiFi"); - prompt = PROMPT_WIFI; +// prompt = PROMPT_WIFI; break; default: From 203e6df2f48a414c7dab86912f13d968c2c5a4ba Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 13 Jan 2023 09:41:51 -0500 Subject: [PATCH 28/60] print wifi --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 0c3dbd40..a025e491 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4329,7 +4329,8 @@ void serial_input() { break; case 'w': - Serial.println("Connect to WiFi"); + Serial.println(wifi); + Serial.println("Connect to WiFi"); // prompt = PROMPT_WIFI; break; From 1efafc13c32f3923d0a6d927503d5d00e26dbe42 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 14:30:47 -0500 Subject: [PATCH 29/60] prompt for WiFi --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a025e491..bd4f3536 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4331,7 +4331,7 @@ void serial_input() { case 'w': Serial.println(wifi); Serial.println("Connect to WiFi"); -// prompt = PROMPT_WIFI; + prompt = PROMPT_WIFI; break; default: @@ -4377,6 +4377,7 @@ void prompt_for_input() { Serial.println("v Read INA219 voltage and current"); Serial.println("o Read diode temperature"); Serial.println("d Change debug mode\n"); + Serial.println("w Connect to WiFi\n"); Serial.printf("Config file /sim.cfg contains %s %d %f %f %s\n\n", callsign, reset_count, lat_file, long_file, sim_yes); From 49f7722fc892c0a3ed8bd2ad65ca505e296a2398 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 15:17:55 -0500 Subject: [PATCH 30/60] added wifi connect dots ... --- cubesatsim/cubesatsim.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index bd4f3536..551d9008 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4555,6 +4555,12 @@ void prompt_for_input() { strcpy(serial_string, pass); Serial.println("Connecting to Wifi"); WiFi.begin(ssid, pass); + + while (WiFi.status() != WL_CONNECTED) { + Serial.print("."); + delay(500); + } + } else Serial.println("No password entered."); } else From 7d60ce1cdf036ec06306993a5fce60e76e7870b7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 15:23:07 -0500 Subject: [PATCH 31/60] fix password --- cubesatsim/cubesatsim.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 551d9008..5100b4e3 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4553,8 +4553,11 @@ void prompt_for_input() { get_serial_string(); if ( strlen(serial_string) > 0) { strcpy(serial_string, pass); - Serial.println("Connecting to Wifi"); - WiFi.begin(ssid, pass); + Serial.println("Connecting to Wifi"); +const char ssid2[] = "CubeSatSim"; +const char pass2[] = "amsatao7"; + WiFi.begin(ssid2, pass2); +// WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); From f843ff4323ddfbed606d945e02c2ccc84415a27f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 16:22:31 -0500 Subject: [PATCH 32/60] added elapsed timer and connected status printout --- cubesatsim/cubesatsim.ino | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5100b4e3..c239432b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4555,15 +4555,19 @@ void prompt_for_input() { strcpy(serial_string, pass); Serial.println("Connecting to Wifi"); const char ssid2[] = "CubeSatSim"; -const char pass2[] = "amsatao7"; +const char pass2[] = "amsatao7"; + unsigned int elapsed_timer = (unsigned int) millis(); WiFi.begin(ssid2, pass2); // WiFi.begin(ssid, pass); - while (WiFi.status() != WL_CONNECTED) { + while ((WiFi.status() != WL_CONNECTED) || ((millis() - elapsed_timer) > 10000)) { Serial.print("."); delay(500); - } - + } + if (((millis() - elapsed_timer) > 10000)) + Serial.println("Failed to connect!"); + else + Serial.println("Connected to WiFi!"); } else Serial.println("No password entered."); } else From d2f8d005fefc0599c23043d6eeef684a9351aa60 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 16:33:00 -0500 Subject: [PATCH 33/60] try prompt for ssid and pwd --- cubesatsim/cubesatsim.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c239432b..984419a8 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4554,11 +4554,11 @@ void prompt_for_input() { if ( strlen(serial_string) > 0) { strcpy(serial_string, pass); Serial.println("Connecting to Wifi"); -const char ssid2[] = "CubeSatSim"; -const char pass2[] = "amsatao7"; +//const char ssid2[] = "CubeSatSim"; +//const char pass2[] = "amsatao7"; unsigned int elapsed_timer = (unsigned int) millis(); - WiFi.begin(ssid2, pass2); -// WiFi.begin(ssid, pass); +// WiFi.begin(ssid2, pass2); + WiFi.begin(ssid, pass); while ((WiFi.status() != WL_CONNECTED) || ((millis() - elapsed_timer) > 10000)) { Serial.print("."); From 7fc72db3660b6f14ba2d9e03384c9a1563c66a75 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 16:40:15 -0500 Subject: [PATCH 34/60] fixed timeout wifi --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 984419a8..08230938 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4560,7 +4560,7 @@ void prompt_for_input() { // WiFi.begin(ssid2, pass2); WiFi.begin(ssid, pass); - while ((WiFi.status() != WL_CONNECTED) || ((millis() - elapsed_timer) > 10000)) { + while ((WiFi.status() != WL_CONNECTED) && ((millis() - elapsed_timer) < 10000)) { Serial.print("."); delay(500); } From 84f2ddc52026352fe826350415ff6d4cb4de3151 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 16:48:32 -0500 Subject: [PATCH 35/60] move start time --- cubesatsim/cubesatsim.ino | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 08230938..a8e2ae47 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4376,7 +4376,7 @@ void prompt_for_input() { Serial.println("? Query sensors"); Serial.println("v Read INA219 voltage and current"); Serial.println("o Read diode temperature"); - Serial.println("d Change debug mode\n"); + Serial.println("d Change debug mode"); Serial.println("w Connect to WiFi\n"); Serial.printf("Config file /sim.cfg contains %s %d %f %f %s\n\n", callsign, reset_count, lat_file, long_file, sim_yes); @@ -4556,9 +4556,10 @@ void prompt_for_input() { Serial.println("Connecting to Wifi"); //const char ssid2[] = "CubeSatSim"; //const char pass2[] = "amsatao7"; - unsigned int elapsed_timer = (unsigned int) millis(); // WiFi.begin(ssid2, pass2); - WiFi.begin(ssid, pass); + WiFi.begin(ssid, pass); + + unsigned int elapsed_timer = (unsigned int) millis(); while ((WiFi.status() != WL_CONNECTED) && ((millis() - elapsed_timer) < 10000)) { Serial.print("."); From a93001dd881be33b7907cf7dd4040ac6d0a89501 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 16:52:08 -0500 Subject: [PATCH 36/60] print both credentials --- cubesatsim/cubesatsim.ino | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a8e2ae47..8dfebf9b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4554,9 +4554,13 @@ void prompt_for_input() { if ( strlen(serial_string) > 0) { strcpy(serial_string, pass); Serial.println("Connecting to Wifi"); -//const char ssid2[] = "CubeSatSim"; -//const char pass2[] = "amsatao7"; +const char ssid2[] = "CubeSatSim"; +const char pass2[] = "amsatao7"; // WiFi.begin(ssid2, pass2); + + Serial.printf("%s%s\n",ssid, pass); + Serial.printf("%s%s\n",ssid2, pass2); + WiFi.begin(ssid, pass); unsigned int elapsed_timer = (unsigned int) millis(); From 220b4e6f703f5d5f30c3c1fd5f4239f1cdac5580 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 16:55:51 -0500 Subject: [PATCH 37/60] fixed string copy --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8dfebf9b..305c1682 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4548,11 +4548,11 @@ void prompt_for_input() { print_string(serial_string); if (strlen(serial_string) > 0) { - strcpy(serial_string, ssid); + strcpy(ssid, serial_string); Serial.print("Enter WiFi password: "); get_serial_string(); - if ( strlen(serial_string) > 0) { - strcpy(serial_string, pass); + if (strlen(serial_string) > 0) { + strcpy(pass, serial_string); Serial.println("Connecting to Wifi"); const char ssid2[] = "CubeSatSim"; const char pass2[] = "amsatao7"; From 2e5d0a4beecc2c876b128a976367b323edc78cf4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 16:59:40 -0500 Subject: [PATCH 38/60] removed prints --- cubesatsim/cubesatsim.ino | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 305c1682..5195a769 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4554,17 +4554,11 @@ void prompt_for_input() { if (strlen(serial_string) > 0) { strcpy(pass, serial_string); Serial.println("Connecting to Wifi"); -const char ssid2[] = "CubeSatSim"; -const char pass2[] = "amsatao7"; -// WiFi.begin(ssid2, pass2); - - Serial.printf("%s%s\n",ssid, pass); - Serial.printf("%s%s\n",ssid2, pass2); +// Serial.printf("%s%s\n",ssid, pass); WiFi.begin(ssid, pass); - unsigned int elapsed_timer = (unsigned int) millis(); - + unsigned int elapsed_timer = (unsigned int) millis(); while ((WiFi.status() != WL_CONNECTED) && ((millis() - elapsed_timer) < 10000)) { Serial.print("."); delay(500); From 8dc152cc826e58570fe7d8e7b9aae2d13cd10a7d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 19:20:41 -0500 Subject: [PATCH 39/60] version v0.36 --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5195a769..73e9345b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -102,7 +102,7 @@ void setup() { // otherwise, run CubeSatSim Pico code - Serial.println("CubeSatSim Pico v0.35 starting...\n"); + Serial.println("CubeSatSim Pico v0.36 starting...\n"); config_gpio(); From d12fb3ab3009c1697f656223c482834132e37193 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 21:53:49 -0500 Subject: [PATCH 40/60] added debug_camera --- cubesatsim/cubesatsim.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index fba8e7f4..4fe2d963 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -295,6 +295,8 @@ float lat_file, long_file; double cpuTemp; int frameTime; +bool debug_camera = false; + float axis[3], angle[3], volts_max[3], amps_max[3], batt, rotation_speed, period, tempS, temp_max, temp_min, eclipse; int i2c_bus0 = OFF, i2c_bus1 = OFF, i2c_bus3 = OFF, camera = OFF, sim_mode = FALSE, SafeMode = FALSE, rxAntennaDeployed = 0, txAntennaDeployed = 0; double eclipse_time; From 2995e8e5da0b272bf46cdab4094c69055566d8bd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 21:56:16 -0500 Subject: [PATCH 41/60] added debug_camera --- cubesatsim/cubesatsim.ino | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 73e9345b..357ca9ec 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -75,7 +75,7 @@ MQTTClient client; byte green_led_counter = 0; char call[] = "AMSAT"; // put your callsign here -extern bool get_camera_image(); +extern bool get_camera_image(bool debug); extern bool start_camera(); void setup() { @@ -253,7 +253,7 @@ void loop() { load_sstv_image_1_as_cam_dot_jpg(); first_time_sstv = false; } else { - if (camera_detected = get_camera_image()) { + if (camera_detected = get_camera_image(debug_camera)) { Serial.println("Getting image file"); // Serial.println("Got image file"); // char camera_file[] = "/cam.jpg"; @@ -4277,10 +4277,14 @@ void serial_input() { break; case 'c': - case 'C': Serial.println("Change the CALLSIGN"); prompt = PROMPT_CALLSIGN; break; + + case 'C': + Serial.println("Debug camera"); + debug_camera = true; + break; case 't': case 'T': From 081f345602e6e75dfb83f308c4d4eccd4fc0ba0a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 21:58:55 -0500 Subject: [PATCH 42/60] added debug_camera --- cubesatsim/pico-get-jpeg-serial.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index 530e2f20..96f8c335 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -31,7 +31,7 @@ FastCRC8 CRC8; //#define PICOW true int led_pin = LED_BUILTIN; -bool get_camera_image(); +bool get_camera_image(bool debug_camera); bool start_camera(); bool start_camera() { @@ -67,14 +67,14 @@ bool start_camera() { delay(100); Serial2.begin(115200); #ifdef GET_IMAGE_DEBUG - Serial.println("Started Serial2 to camera v0.2"); + Serial.println("Started Serial2 to camera v0.3"); #endif LittleFS.begin(); bool camera_present = false; // int tries = 0; // while ((tries++ < 5) && !camera_present) { - if (get_camera_image()) { + if (get_camera_image(false)) { camera_present = true; Serial.println("Camera detected!"); } @@ -166,7 +166,7 @@ void loop() { } */ -bool get_camera_image() { +bool get_camera_image(bool debug_camera) { index1 = 0; flag_count = 0; @@ -175,9 +175,10 @@ bool get_camera_image() { end_flag_detected = false; jpeg_start = 0; -#ifdef GET_IMAGE_DEBUG +// #ifdef GET_IMAGE_DEBUG + if (debug_camera) Serial.println("Starting get_image_file"); - #endif + // #endif finished = false; Serial.println("Enabling ESP32-CAM"); From 81ec94966ee6b9131ff48d1d61824ad63a8844d5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 22:03:48 -0500 Subject: [PATCH 43/60] more debug prints --- cubesatsim/pico-get-jpeg-serial.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index 96f8c335..9467e46c 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -196,9 +196,10 @@ bool get_camera_image(bool debug_camera) { if (octet == end_flag[flag_count]) { // looking for end flag // if (end_flag_detected) { flag_count++; -#ifdef GET_IMAGE_DEBUG +//#ifdef GET_IMAGE_DEBUG + if (debug_camera) Serial.println("Found part of end flag!"); -#endif +//#endif if (flag_count >= strlen(end_flag)) { // complete image /// buffer2[index1++] = octet; // Serial.println("\nFound end flag"); @@ -247,7 +248,8 @@ bool get_camera_image(bool debug_camera) { } /// buffer2[index1++] = octet; -#ifdef GET_IMAGE_DEBUG +//#ifdef GET_IMAGE_DEBUG + if (debug_camera) { char hexValue[5]; if (octet != 0x66) { sprintf(hexValue, "%02X", octet); @@ -257,7 +259,8 @@ bool get_camera_image(bool debug_camera) { Serial.print("66"); } // Serial.write(octet); -#endif + } +//#endif if (index1 > 100000) index1 = 0; // } From f42e05bf8f64371c3bce419f10ce83c41f0384de Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 27 Jan 2023 22:12:34 -0500 Subject: [PATCH 44/60] removed end flag prints --- cubesatsim/pico-get-jpeg-serial.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index 9467e46c..f0c9c9ff 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -196,10 +196,10 @@ bool get_camera_image(bool debug_camera) { if (octet == end_flag[flag_count]) { // looking for end flag // if (end_flag_detected) { flag_count++; -//#ifdef GET_IMAGE_DEBUG - if (debug_camera) +#ifdef GET_IMAGE_DEBUG +// if (debug_camera) Serial.println("Found part of end flag!"); -//#endif +#endif if (flag_count >= strlen(end_flag)) { // complete image /// buffer2[index1++] = octet; // Serial.println("\nFound end flag"); @@ -220,13 +220,15 @@ bool get_camera_image(bool debug_camera) { // index1 -= 1; uint8_t * data = (uint8_t *) &buffer2[0]; -#ifdef GET_IMAGE_DEBUG +//#ifdef GET_IMAGE_DEBUG + if (debug_camera) { Serial.println("\nCRC cacluation data:"); Serial.println(buffer2[0], HEX); Serial.println(buffer2[index1 - 1], HEX); Serial.println(index1); - Serial.println(received_crc, HEX); - #endif + Serial.println(received_crc, HEX); + } + //#endif int calculated_crc = CRC8.smbus(data, index1); // Serial.println(calculated_crc, HEX); if (received_crc == calculated_crc) From 9016e6909bcae4665defe78b984db48f1f4b5e8c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 09:07:15 -0500 Subject: [PATCH 45/60] don't do LED if no wifi in cw --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 357ca9ec..e46d7ce9 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3967,7 +3967,7 @@ void configure_wifi() { */ void transmit_cw(int freq, float duration) { // freq in Hz, duration in milliseconds - // if (!wifi) + if (!wifi) digitalWrite(LED_BUILTIN, HIGH); // Transmit LED on digitalWrite(MAIN_LED_BLUE, HIGH); @@ -3996,7 +3996,7 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise clockgen.enableOutputs(false); } -// if (!wifi) + if (!wifi) digitalWrite(LED_BUILTIN, LOW); // Transmit LED off digitalWrite(MAIN_LED_BLUE, LOW); } From b874d8f046aa8b91ba2bb9e43fa6a0144b145e28 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 09:18:36 -0500 Subject: [PATCH 46/60] fix wifi conditional on LED --- cubesatsim/cubesatsim.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index e46d7ce9..3871d031 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3967,7 +3967,8 @@ void configure_wifi() { */ void transmit_cw(int freq, float duration) { // freq in Hz, duration in milliseconds - if (!wifi) +// if (!wifi) + if (wifi) digitalWrite(LED_BUILTIN, HIGH); // Transmit LED on digitalWrite(MAIN_LED_BLUE, HIGH); @@ -3995,8 +3996,9 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise digitalWrite(BPSK_CONTROL_A, LOW); clockgen.enableOutputs(false); } - - if (!wifi) + +// if (!wifi) + if (wifi) digitalWrite(LED_BUILTIN, LOW); // Transmit LED off digitalWrite(MAIN_LED_BLUE, LOW); } From 1479121c911828f7c72fb486a5ddbe5b4454128f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 09:24:19 -0500 Subject: [PATCH 47/60] Pico no W use pin 25 instead of LED_BUILTIN --- cubesatsim/cubesatsim.ino | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 3871d031..19f5bb5d 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -95,7 +95,7 @@ void setup() { new_mode = mode; - pinMode(LED_BUILTIN, OUTPUT); +// pinMode(LED_BUILTIN, OUTPUT); // blinkTimes(1); /// sleep(5.0); @@ -159,9 +159,11 @@ void setup() { /**/ if (check_for_wifi()) { - wifi = true; + wifi = true; + pinMode(LED_BUILTIN, OUTPUT); // configure_wifi(); - } + } else + pinMode(25, OUTPUT); /**/ start_button_isr(); @@ -3970,6 +3972,9 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise // if (!wifi) if (wifi) digitalWrite(LED_BUILTIN, HIGH); // Transmit LED on + else + digitalWrite(25, HIGH); // Transmit LED on + digitalWrite(MAIN_LED_BLUE, HIGH); unsigned long duration_us = duration * 1000; @@ -4000,6 +4005,8 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise // if (!wifi) if (wifi) digitalWrite(LED_BUILTIN, LOW); // Transmit LED off + else + digitalWrite(25, LOW); // Transmit LED on digitalWrite(MAIN_LED_BLUE, LOW); } From 8bb4d34f094b20cb7ab7168994c8024cddc2d83f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 09:29:13 -0500 Subject: [PATCH 48/60] added led_builtin_pin --- cubesatsim/cubesatsim.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 4fe2d963..5ba37b35 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -369,6 +369,8 @@ bool ina219_started = false; bool camera_detected = false; bool rotate_flag = true; +int led_builtin_pin; + #define PRESSED 0 #define HELD 0 #define RELEASED 1 From 651378e352c39dce5ca468a1504ab93412847901 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 09:33:04 -0500 Subject: [PATCH 49/60] test led_builtin_pin variable --- cubesatsim/cubesatsim.ino | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 19f5bb5d..8a36cddd 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -160,10 +160,13 @@ void setup() { /**/ if (check_for_wifi()) { wifi = true; - pinMode(LED_BUILTIN, OUTPUT); + led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W +// pinMode(LED_BUILTIN, OUTPUT); // configure_wifi(); } else - pinMode(25, OUTPUT); + led_builtin_pin = 25; // manually set GPIO 25 for Pico board +// pinMode(25, OUTPUT); + pinMode(led_builtin_pin, OUTPUT); /**/ start_button_isr(); @@ -3969,11 +3972,14 @@ void configure_wifi() { */ void transmit_cw(int freq, float duration) { // freq in Hz, duration in milliseconds -// if (!wifi) +// if (!wifi) +/* if (wifi) digitalWrite(LED_BUILTIN, HIGH); // Transmit LED on else digitalWrite(25, HIGH); // Transmit LED on +*/ + digitalWrite(led_builtin_pin, HIGH); digitalWrite(MAIN_LED_BLUE, HIGH); @@ -4003,10 +4009,13 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise } // if (!wifi) +/* if (wifi) digitalWrite(LED_BUILTIN, LOW); // Transmit LED off else digitalWrite(25, LOW); // Transmit LED on +*/ + digitalWrite(led_builtin_pin, LOW); digitalWrite(MAIN_LED_BLUE, LOW); } From 32e40a39bfcb8ffec0f5c3f0896a736a8881a98c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 09:36:29 -0500 Subject: [PATCH 50/60] changed all to led_builtin_pin --- cubesatsim/cubesatsim.ino | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8a36cddd..9b19ca7e 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3117,11 +3117,11 @@ void blink_setup() void blink(int length) { - digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON + digitalWrite(led_builtin_pin, HIGH); // set the built-in LED ON sleep(length/1000.0); // delay(length); // wait for a lenth of time - digitalWrite(LED_BUILTIN, LOW); // set the built-in LED off + digitalWrite(led_builtin_pin, LOW); // set the built-in LED off } void led_set(int ledPin, bool state) @@ -3407,7 +3407,7 @@ void process_pushbutton() { // return; /// just skip for now // if (!wifi) - digitalWrite(LED_BUILTIN, HIGH); // make sure built in LED is on before starting to blink + digitalWrite(led_builtin_pin, HIGH); // make sure built in LED is on before starting to blink sleep(1.0); @@ -3497,7 +3497,7 @@ void process_pushbutton() { transmit_off(); sleep(2.0); - digitalWrite(LED_BUILTIN, LOW); // make sure built-in LED is off + digitalWrite(led_builtin_pin, LOW); // make sure built-in LED is off } void process_bootsel() { @@ -3507,7 +3507,7 @@ void process_bootsel() { int release = FALSE; // if (!wifi) - digitalWrite(LED_BUILTIN, HIGH); // make sure built in LED is on before blinking + digitalWrite(led_builtin_pin, HIGH); // make sure built in LED is on before blinking sleep(1.0); @@ -3596,18 +3596,18 @@ void process_bootsel() { transmit_off(); // sleep(2.0); - digitalWrite(LED_BUILTIN, LOW); // make sure built-in LED is off + digitalWrite(led_builtin_pin, LOW); // make sure built-in LED is off } void blinkTimes(int blinks) { for (int i = 0; i < blinks; i++) { digitalWrite(MAIN_LED_GREEN, LOW); // if (!wifi) - digitalWrite(LED_BUILTIN, LOW); + digitalWrite(led_builtin_pin, LOW); sleep(0.1); digitalWrite(MAIN_LED_GREEN, HIGH); // if (!wifi) - digitalWrite(LED_BUILTIN, HIGH); + digitalWrite(led_builtin_pin, HIGH); sleep(0.1); } } @@ -3647,7 +3647,7 @@ void config_gpio() { // set LEDs and blink once // if (!wifi) Serial.println("Blinking pins"); - pinMode(LED_BUILTIN, OUTPUT); // Set LED pin to output + pinMode(led_builtin_pin, OUTPUT); // Set LED pin to output pinMode(MAIN_LED_GREEN, OUTPUT); // Set Main Green LED pin to output blink_pin(MAIN_LED_GREEN, 150); digitalWrite(MAIN_LED_GREEN, HIGH); // Leave Green LED on @@ -4915,7 +4915,7 @@ void get_input() { void transmit_led(bool status) { if(filter_present) { // if (!wifi) - digitalWrite(LED_BUILTIN, status); + digitalWrite(led_builtin_pin, status); digitalWrite(MAIN_LED_BLUE, status); } } From 29e50e2057663f46b9278003ba2cad330ca1787e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 09:40:32 -0500 Subject: [PATCH 51/60] added PROMPT_CAMERA --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 5ba37b35..26373e7f 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -130,6 +130,7 @@ #define PROMPT_REBOOT 13 #define PROMPT_I2CSCAN 14 #define PROMPT_WIFI 15 +#define PROMPT_CAMERA 16 #define PAYLOAD_QUERY 1 #define PAYLOAD_RESET 2 From cfb66aec8d7501613cab834e533a0ca4f49960e7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 09:41:54 -0500 Subject: [PATCH 52/60] added PROMPT_CAMERA to debug camera right away --- cubesatsim/cubesatsim.ino | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 9b19ca7e..8f247f1b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4301,7 +4301,8 @@ void serial_input() { case 'C': Serial.println("Debug camera"); - debug_camera = true; + debug_camera = true; + prompt = PROMPT_CAMERA; break; case 't': @@ -4491,6 +4492,10 @@ void prompt_for_input() { payload_command = PAYLOAD_QUERY; break; + case PROMPT_CAMERA: + get_camera_image(debug_camera); + break; + case PROMPT_TEMP: sensorValue = analogRead(TEMPERATURE_PIN); Serial.print("Raw diode voltage: "); From c9a6367044be17e424529708d7fd1151fdd484f4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 15:56:44 -0500 Subject: [PATCH 53/60] added hex encoded print --- cubesatsim/pico-get-jpeg-serial.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index f0c9c9ff..0ce5f652 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -175,15 +175,16 @@ bool get_camera_image(bool debug_camera) { end_flag_detected = false; jpeg_start = 0; + Serial.println("Enabling ESP32-CAM"); + pinMode(ESP32_CAM_ENABLE_PIN, OUTPUT); + digitalWrite(ESP32_CAM_ENABLE_PIN, HIGH); + // #ifdef GET_IMAGE_DEBUG if (debug_camera) - Serial.println("Starting get_image_file"); + Serial.println("Received from ESP32-CAM hex encoded:\n"); // #endif finished = false; - Serial.println("Enabling ESP32-CAM"); - pinMode(ESP32_CAM_ENABLE_PIN, OUTPUT); - digitalWrite(ESP32_CAM_ENABLE_PIN, HIGH); unsigned long time_start = millis(); while ((!finished) && ((millis() - time_start) < CAMERA_TIMEOUT)) { @@ -212,7 +213,7 @@ bool get_camera_image(bool debug_camera) { int received_crc = Serial2.read(); // buffer2[index1++] = octet; - Serial.print("File length: "); + Serial.print("\nFile length: "); Serial.println(index1 - (int)strlen(end_flag)); // index1 -= 1; // 40; // Serial.println(buffer2[index1 - 1], HEX); @@ -220,15 +221,16 @@ bool get_camera_image(bool debug_camera) { // index1 -= 1; uint8_t * data = (uint8_t *) &buffer2[0]; -//#ifdef GET_IMAGE_DEBUG - if (debug_camera) { - Serial.println("\nCRC cacluation data:"); - Serial.println(buffer2[0], HEX); +#ifdef GET_IMAGE_DEBUG + Serial.println(buffer2[0], HEX); Serial.println(buffer2[index1 - 1], HEX); - Serial.println(index1); + Serial.println(index1); + #endif + if (debug_camera) { + Serial.print("\nCRC received:"); Serial.println(received_crc, HEX); } - //#endif + int calculated_crc = CRC8.smbus(data, index1); // Serial.println(calculated_crc, HEX); if (received_crc == calculated_crc) From dc31389b939ba68a3a942757923264b1873c6f05 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 16:23:06 -0500 Subject: [PATCH 54/60] updated help menu, print mode --- cubesatsim/cubesatsim.ino | 50 +++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8f247f1b..a6b7a194 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4233,22 +4233,7 @@ void serial_input() { case 'h': case 'H': // Serial.println("Help"); - prompt = PROMPT_HELP; - /* - Serial.println("\nChange settings by typing the letter:"); - Serial.println("h Help info"); - Serial.println("a AFSK/APRS mode"); - Serial.println("c CW mode"); - Serial.println("f FSK/DUV mode"); - Serial.println("b BPSK mode"); - Serial.println("s SSTV mode"); - Serial.println("i Restart"); - Serial.println("c CALLSIGN"); - Serial.println("t Simulated Telemetry"); - Serial.println("r Resets Count, or payload & EEPROM"); - Serial.println("l Lat and Long"); - Serial.println("? Query sensors\n"); -*/ + prompt = PROMPT_HELP; break; case 'a': @@ -4387,15 +4372,17 @@ void prompt_for_input() { Serial.println("a AFSK/APRS mode"); Serial.println("m CW mode"); Serial.println("f FSK/DUV mode"); + Serial.println("F Format flash memory"); Serial.println("b BPSK mode"); Serial.println("s SSTV mode"); Serial.println("S I2C scan"); Serial.println("i Restart"); - Serial.println("c CALLSIGN"); + Serial.println("c Change CALLSIGN"); + Serial.println("C Debug Camera"); Serial.println("t Simulated Telemetry"); - Serial.println("r Resets Count"); - Serial.println("p Resets payload and stored EEPROM values"); - Serial.println("l Lat and Lon"); + Serial.println("r Reset Count"); + Serial.println("p Reset payload and stored EEPROM values"); + Serial.println("l Change Lat and Lon"); Serial.println("? Query sensors"); Serial.println("v Read INA219 voltage and current"); Serial.println("o Read diode temperature"); @@ -4404,6 +4391,29 @@ void prompt_for_input() { Serial.printf("Config file /sim.cfg contains %s %d %f %f %s\n\n", callsign, reset_count, lat_file, long_file, sim_yes); + switch(mode) { + + case(AFSK): + Serial.println("AFSK mode"); + break; + + case(FSK): + Serial.println("FSK mode"); + break; + + case(BPSK): + Serial.println("BPSK mode"); + break; + + case(SSTV): + Serial.println("SSTV mode"); + break; + + case(CW): + Serial.println("CW mode"); + break; + } + break; case PROMPT_CALLSIGN: From 98946d8e52a0a0b9521a25409bef80da04078764 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 16:35:58 -0500 Subject: [PATCH 55/60] added camera complete --- cubesatsim/pico-get-jpeg-serial.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index 0ce5f652..36cfa469 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -285,6 +285,8 @@ bool get_camera_image(bool debug_camera) { } // Serial.println("writing to Serial2"); } + if (debug_camera) + Serial.print("\nCamera complete"); digitalWrite(ESP32_CAM_ENABLE_PIN, LOW); return(finished); } From df1586143bd1eca0f94a9432b5f6246ce6dd220b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 16:37:42 -0500 Subject: [PATCH 56/60] added show_dir to camera test --- cubesatsim/cubesatsim.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a6b7a194..bbc56055 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -4503,7 +4503,9 @@ void prompt_for_input() { break; case PROMPT_CAMERA: - get_camera_image(debug_camera); + show_dir(); + get_camera_image(debug_camera); + show_dir(); break; case PROMPT_TEMP: From 1d32a3779160ce7faa523455c9900ce02231a45a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 16:40:14 -0500 Subject: [PATCH 57/60] added \n --- cubesatsim/pico-get-jpeg-serial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index 36cfa469..de073ec6 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -286,7 +286,7 @@ bool get_camera_image(bool debug_camera) { // Serial.println("writing to Serial2"); } if (debug_camera) - Serial.print("\nCamera complete"); + Serial.print("\nCamera complete\n"); digitalWrite(ESP32_CAM_ENABLE_PIN, LOW); return(finished); } From e4ec44aeb352b93c645afd17b140d5678993c0bc Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 19:47:05 -0500 Subject: [PATCH 58/60] turn builtin LED on at start --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index bbc56055..28191247 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3647,7 +3647,8 @@ void config_gpio() { // set LEDs and blink once // if (!wifi) Serial.println("Blinking pins"); - pinMode(led_builtin_pin, OUTPUT); // Set LED pin to output + pinMode(led_builtin_pin, OUTPUT); // Set LED pin to output + digitalWrite(led_builtin_pin, HIGH); // Leave Pico LED on pinMode(MAIN_LED_GREEN, OUTPUT); // Set Main Green LED pin to output blink_pin(MAIN_LED_GREEN, 150); digitalWrite(MAIN_LED_GREEN, HIGH); // Leave Green LED on From e2d1c08b18d09c8bfbe9253a451936bd14ff95c3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 19:49:39 -0500 Subject: [PATCH 59/60] move check for wifi up --- cubesatsim/cubesatsim.ino | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 28191247..81f1264e 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -104,6 +104,18 @@ void setup() { Serial.println("CubeSatSim Pico v0.36 starting...\n"); +/**/ + if (check_for_wifi()) { + wifi = true; + led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W +// pinMode(LED_BUILTIN, OUTPUT); +// configure_wifi(); + } else + led_builtin_pin = 25; // manually set GPIO 25 for Pico board +// pinMode(25, OUTPUT); + pinMode(led_builtin_pin, OUTPUT); +/**/ + config_gpio(); get_input(); @@ -157,17 +169,6 @@ void setup() { // if ((i2c_bus3 == false) || (mode == FSK)) // force simulated telemetry mode for FSK config_simulated_telem(); -/**/ - if (check_for_wifi()) { - wifi = true; - led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W -// pinMode(LED_BUILTIN, OUTPUT); -// configure_wifi(); - } else - led_builtin_pin = 25; // manually set GPIO 25 for Pico board -// pinMode(25, OUTPUT); - pinMode(led_builtin_pin, OUTPUT); -/**/ start_button_isr(); // setup_sstv(); From b849d218261a2837faa99053ad795030533bab7f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 28 Jan 2023 19:52:04 -0500 Subject: [PATCH 60/60] blink Pico LED at start --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 81f1264e..a41ff6e5 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3649,7 +3649,8 @@ void config_gpio() { // if (!wifi) Serial.println("Blinking pins"); pinMode(led_builtin_pin, OUTPUT); // Set LED pin to output - digitalWrite(led_builtin_pin, HIGH); // Leave Pico LED on + blink_pin(led_builtin_pin, 150); +// digitalWrite(led_builtin_pin, HIGH); // Leave Pico LED on pinMode(MAIN_LED_GREEN, OUTPUT); // Set Main Green LED pin to output blink_pin(MAIN_LED_GREEN, 150); digitalWrite(MAIN_LED_GREEN, HIGH); // Leave Green LED on