Get telemetry sequence to save.

Still needs some cleanup of comments.
pull/75/head
Matt 2021-09-18 09:59:09 -05:00
rodzic b3adda48e9
commit 052589a608
3 zmienionych plików z 30 dodań i 15 usunięć

Wyświetl plik

@ -54,7 +54,7 @@ build_flags =
-D 'NETWORK_GPS_PORT=10110' ; GPS NMEA Port -D 'NETWORK_GPS_PORT=10110' ; GPS NMEA Port
-D 'ENABLE_TNC_SELF_TELEMETRY' ; can be set from www interface -D 'ENABLE_TNC_SELF_TELEMETRY' ; can be set from www interface
-D 'TNC_SELF_TELEMETRY_INTERVAL=3600L' ; can be set from www interface (seconds) -D 'TNC_SELF_TELEMETRY_INTERVAL=3600L' ; can be set from www interface (seconds)
-D 'TNC_SELF_TELEMETRY_SEQ=0L' ; start number for telemetry sequence ; -D 'TNC_SELF_TELEMETRY_SEQ=0L' ; start number for telemetry sequence
-D 'SHOW_OLED_TIME=15000' ; OLED Timeout -D 'SHOW_OLED_TIME=15000' ; OLED Timeout
[env:ttgo-t-beam-v1.0] [env:ttgo-t-beam-v1.0]

Wyświetl plik

@ -103,8 +103,11 @@ boolean key_up = true;
boolean t_lock = false; boolean t_lock = false;
boolean fixed_beacon_enabled = false; boolean fixed_beacon_enabled = false;
boolean show_cmt = true; boolean show_cmt = true;
// Telemetry interval, seconds
int tel_interval; int tel_interval;
// Telemetry sequence, current value
int tel_sequence; int tel_sequence;
//int tel_sequence = preferences.getInt(PREF_TNC_SELF_TELEMETRY_SEQ, 0);
#ifdef SHOW_ALT #ifdef SHOW_ALT
boolean showAltitude = true; boolean showAltitude = true;
@ -121,6 +124,11 @@ int tel_sequence;
#else #else
boolean enable_tel = false; boolean enable_tel = false;
#endif #endif
//#ifdef TNC_SELF_TELEMETRY_SEQ
// int tel_sequence = TNC_SELF_TELEMETRY_SEQ;
//#else
// int tel_sequence = PREF_TNC_SELF_TELEMETRY_SEQ;
//#endif
#ifdef ENABLE_BLUETOOTH #ifdef ENABLE_BLUETOOTH
boolean enable_bluetooth = true; boolean enable_bluetooth = true;
#else #else
@ -517,9 +525,10 @@ String prepareCallsign(const String& callsign){
#endif #endif
// Determine sequence number (or 'MIC') // Determine sequence number (or 'MIC')
tel_sequence = preferences.getUInt(PREF_TNC_SELF_TELEMETRY_SEQ, 0);
// Pad to 3 digits // Pad to 3 digits
char tel_sequence_char[3]; char tel_sequence_char[3];
sprintf_P(tel_sequence_char, "%03i", tel_sequence); sprintf_P(tel_sequence_char, "%03u", tel_sequence);
String tel_sequence_str = String(tel_sequence_char); String tel_sequence_str = String(tel_sequence_char);
String telemetryParamsNames = String(":") + Tcall_message + ":PARM.B Volt,B In,B Out,AC V,AC C"; String telemetryParamsNames = String(":") + Tcall_message + ":PARM.B Volt,B In,B Out,AC V,AC C";
@ -543,11 +552,14 @@ String prepareCallsign(const String& callsign){
#endif #endif
// Update the telemetry sequence number // Update the telemetry sequence number
if(tel_sequence >= 0 & tel_sequence < 999){ //if(tel_sequence >= 0 & tel_sequence < 999){
tel_sequence = tel_sequence + 1; tel_sequence = tel_sequence + 1;
} else { //}
tel_sequence = 0; //else {
} // tel_sequence = 0;
//}
preferences.putUInt(PREF_TNC_SELF_TELEMETRY_SEQ, tel_sequence);
} }
#endif #endif
} }
@ -576,16 +588,14 @@ void setup(){
relay_path = ""; relay_path = "";
#endif #endif
#ifdef TNC_SELF_TELEMETRY_SEQ
tel_sequence = TNC_SELF_TELEMETRY_SEQ;
#else
tel_sequence = 0;
#endif
#ifdef FIXED_BEACON_EN #ifdef FIXED_BEACON_EN
fixed_beacon_enabled = true; fixed_beacon_enabled = true;
#endif #endif
// This section loads values from saved preferences,
// if available.
// https://randomnerdtutorials.com/esp32-save-data-permanently-preferences/
#ifdef ENABLE_PREFERENCES #ifdef ENABLE_PREFERENCES
int clear_preferences = 0; int clear_preferences = 0;
if(digitalRead(BUTTON)==LOW){ if(digitalRead(BUTTON)==LOW){
@ -1144,6 +1154,7 @@ void loop() {
} }
#if defined(ENABLE_TNC_SELF_TELEMETRY) && defined(KISS_PROTOCOL) #if defined(ENABLE_TNC_SELF_TELEMETRY) && defined(KISS_PROTOCOL)
if (nextTelemetryFrame < millis()){ if (nextTelemetryFrame < millis()){
// Schedule the next telemetry frame
nextTelemetryFrame = millis() + (tel_interval * 1000); nextTelemetryFrame = millis() + (tel_interval * 1000);
sendTelemetryFrame(); sendTelemetryFrame();
} }

Wyświetl plik

@ -272,6 +272,12 @@ void handle_SaveAPRSCfg() {
if (server.hasArg(PREF_APRS_LONGITUDE_PRESET)){ if (server.hasArg(PREF_APRS_LONGITUDE_PRESET)){
preferences.putString(PREF_APRS_LONGITUDE_PRESET, server.arg(PREF_APRS_LONGITUDE_PRESET)); preferences.putString(PREF_APRS_LONGITUDE_PRESET, server.arg(PREF_APRS_LONGITUDE_PRESET));
} }
if (server.hasArg(PREF_TNC_SELF_TELEMETRY_INTERVAL)){
preferences.putInt(PREF_TNC_SELF_TELEMETRY_INTERVAL, server.arg(PREF_TNC_SELF_TELEMETRY_INTERVAL).toInt());
}
//Arg(PREF_TNC_SELF_TELEMETRY_SEQ)){
// preferences.putInt(PREF_TNC_SELF_TELEMETRY_SEQ, server.arg(PREF_TNC_SELF_TELEMETRY_SEQ).toInt());
//}
// Smart Beaconing settings // Smart Beaconing settings
if (server.hasArg(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET)){ if (server.hasArg(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET)){
@ -292,9 +298,7 @@ void handle_SaveAPRSCfg() {
if (server.hasArg(PREF_APRS_SB_ANGLE_PRESET)){ if (server.hasArg(PREF_APRS_SB_ANGLE_PRESET)){
preferences.putDouble(PREF_APRS_SB_ANGLE_PRESET, server.arg(PREF_APRS_SB_ANGLE_PRESET).toDouble()); preferences.putDouble(PREF_APRS_SB_ANGLE_PRESET, server.arg(PREF_APRS_SB_ANGLE_PRESET).toDouble());
} }
if (server.hasArg(PREF_TNC_SELF_TELEMETRY_INTERVAL)){
preferences.putInt(PREF_TNC_SELF_TELEMETRY_INTERVAL, server.arg(PREF_TNC_SELF_TELEMETRY_INTERVAL).toInt());
}
preferences.putBool(PREF_APRS_SHOW_BATTERY, server.hasArg(PREF_APRS_SHOW_BATTERY)); preferences.putBool(PREF_APRS_SHOW_BATTERY, server.hasArg(PREF_APRS_SHOW_BATTERY));
preferences.putBool(PREF_ENABLE_TNC_SELF_TELEMETRY, server.hasArg(PREF_ENABLE_TNC_SELF_TELEMETRY)); preferences.putBool(PREF_ENABLE_TNC_SELF_TELEMETRY, server.hasArg(PREF_ENABLE_TNC_SELF_TELEMETRY));