From 32bd6f4e83315baf8617d15637478bae8e04b330 Mon Sep 17 00:00:00 2001 From: Mateusz Lubecki Date: Tue, 12 Jan 2021 15:19:31 +0100 Subject: [PATCH] some configuration moved to the separate structure instead of direct defines. bugfix for callsigns shorter than 6 characters --- Debug/src/subdir.mk | 3 ++ include/PathConfig.h | 3 +- include/config_data.h | 70 ++++++++++++++++++++++++++++++++++++ include/main.h | 2 +- src/PathConfig.c | 45 +++++++++++++++-------- src/config_data.c | 71 +++++++++++++++++++++++++++++++++++++ src/main.c | 7 +++- system/src/aprs/telemetry.c | 19 +++++----- 8 files changed, 194 insertions(+), 26 deletions(-) create mode 100644 include/config_data.h create mode 100644 src/config_data.c diff --git a/Debug/src/subdir.mk b/Debug/src/subdir.mk index d237fde..9d777dd 100644 --- a/Debug/src/subdir.mk +++ b/Debug/src/subdir.mk @@ -9,6 +9,7 @@ C_SRCS += \ ../src/PathConfig.c \ ../src/TimerConfig.c \ ../src/_write.c \ +../src/config_data.c \ ../src/delay.c \ ../src/io.c \ ../src/it_handlers.c \ @@ -26,6 +27,7 @@ OBJS += \ ./src/PathConfig.o \ ./src/TimerConfig.o \ ./src/_write.o \ +./src/config_data.o \ ./src/delay.o \ ./src/io.o \ ./src/it_handlers.o \ @@ -43,6 +45,7 @@ C_DEPS += \ ./src/PathConfig.d \ ./src/TimerConfig.d \ ./src/_write.d \ +./src/config_data.d \ ./src/delay.d \ ./src/io.d \ ./src/it_handlers.d \ diff --git a/include/PathConfig.h b/include/PathConfig.h index 4027475..b17c8aa 100644 --- a/include/PathConfig.h +++ b/include/PathConfig.h @@ -9,13 +9,14 @@ #define PATH_H_ #include "aprs/ax25.h" +#include "config_data.h" /* C++ detection */ #ifdef __cplusplus extern "C" { #endif - uint8_t ConfigPath(AX25Call* p); + uint8_t ConfigPath(AX25Call* p, const config_data_basic_t* conf); #ifdef __cplusplus } diff --git a/include/config_data.h b/include/config_data.h new file mode 100644 index 0000000..54b4d70 --- /dev/null +++ b/include/config_data.h @@ -0,0 +1,70 @@ +/* + * config_data.h + * + * Created on: Jan 12, 2021 + * Author: mateusz + */ + +#ifndef CONFIG_DATA_H_ +#define CONFIG_DATA_H_ + +#include + +/** + * This is NOT an editable configuration file where ParaTNC settings are made! Do not touch this! + * Please look at 'station_config.h' instead to set all parameters. + */ + +typedef struct config_data_mode_t { + + uint8_t digi; + + uint8_t wx; + + uint8_t victron; + + + +} config_data_mode_t; + +typedef struct config_data_basic_t { + + char * callsign; + + uint8_t ssid; + + float latitude; + + // N or S + uint8_t zero_to_n_one_to_s; + + float longitude; + + // E or W + uint8_t zero_to_e_one_to_w; + + char * comment; + + // 0 - _SYMBOL_DIGI // uncomment if you want digi symbol(green star with D inside) + // 1 - _SYMBOL_WIDE1_DIGI // uncomment if you want 'little' digi symbol (green star with digit 1 overlaid) + // 2 - _SYMBOL_HOUSE // uncomment if you want house symbol + // 3 - _SYMBOL_RXIGATE // uncomment if you want rxigate symbol (black diamond with R) + // 4 - _SYMBOL_IGATE // uncomment if you want igate symol (black diamond with I) + uint8_t symbol; + + // 0 - no path + // 1 - WIDE1-1 path + // 2 - WIDE2-1 path + uint8_t path_type; + + uint8_t beacon_at_bootup; + + uint8_t wx_transmit_period; + + uint8_t beacon_transmit_period; + +} config_data_basic_t; + +extern const config_data_basic_t config_data_basic; + +#endif /* CONFIG_DATA_H_ */ diff --git a/include/main.h b/include/main.h index a15d1f5..c3730e8 100644 --- a/include/main.h +++ b/include/main.h @@ -5,7 +5,7 @@ #include "drivers/serial.h" #define SW_VER "DF11" -#define SW_DATE "09012021" +#define SW_DATE "12012021" #define SYSTICK_TICKS_PER_SECONDS 100 #define SYSTICK_TICKS_PERIOD 10 diff --git a/src/PathConfig.c b/src/PathConfig.c index 688700a..abe635d 100644 --- a/src/PathConfig.c +++ b/src/PathConfig.c @@ -9,23 +9,40 @@ #include "station_config.h" #include -uint8_t ConfigPath(AX25Call* p) { +uint8_t ConfigPath(AX25Call* p, const config_data_basic_t* conf) { memcpy(p[0].call, "AKLPRZ", 6), p[0].ssid = 0; -#if (defined(_WIDE1_PATH) && !defined(_WIDE21_PATH)) - memcpy(p[1].call, _CALL, 6), p[1].ssid = _SSID; - memcpy(p[2].call, "WIDE1", 6), p[2].ssid = 1; - return 3; -#elif (!defined(_WIDE1_PATH) && defined(_WIDE21_PATH)) - memcpy(p[1].call, _CALL, 6), p[1].ssid = _SSID; - memcpy(p[2].call, "WIDE2", 6), p[2].ssid = 1; - return 3; -#else - memcpy(p[1].call, _CALL, 6), p[1].ssid = _SSID; - return 2; - #endif - return 0; + switch (conf->path_type) { + case 1: + strncpy(p[1].call, conf->callsign, 6), p[1].ssid = conf->ssid; + memcpy(p[2].call, "WIDE1", 6), p[2].ssid = 1; + return 3; + case 2: + strncpy(p[1].call, conf->callsign, 6), p[1].ssid = conf->ssid; + memcpy(p[2].call, "WIDE2", 6), p[2].ssid = 1; + return 3; + case 0: + default: + strncpy(p[1].call, conf->callsign, 6), p[1].ssid = conf->ssid; + return 2; + + } + +//#if (defined(_WIDE1_PATH) && !defined(_WIDE21_PATH)) +// memcpy(p[1].call, _CALL, 6), p[1].ssid = _SSID; +// memcpy(p[2].call, "WIDE1", 6), p[2].ssid = 1; +// return 3; +//#elif (!defined(_WIDE1_PATH) && defined(_WIDE21_PATH)) +// memcpy(p[1].call, _CALL, 6), p[1].ssid = _SSID; +// memcpy(p[2].call, "WIDE2", 6), p[2].ssid = 1; +// return 3; +//#else +// memcpy(p[1].call, _CALL, 6), p[1].ssid = _SSID; +// return 2; +// #endif +// +// return 0; } diff --git a/src/config_data.c b/src/config_data.c new file mode 100644 index 0000000..a80730b --- /dev/null +++ b/src/config_data.c @@ -0,0 +1,71 @@ +/* + * config_data.c + * + * Created on: Jan 12, 2021 + * Author: mateusz + */ + +/** + * This is NOT an editable configuration file where ParaTNC settings are made! Do not touch this! + * Please look at 'station_config.h' instead to set all parameters. + */ + +#include "config_data.h" + +#include "station_config.h" + + +const config_data_basic_t config_data_basic = { + .callsign = _CALL, + .ssid = _SSID, + .latitude = _LAT, + .longitude = _LON, +#if (_LATNS == 'N') + .zero_to_n_one_to_s = 0, +#else + .zero_to_n_one_to_s = 1, +#endif + +#if (_LONWE == 'E') + .zero_to_e_one_to_w = 0, +#else + .zero_to_e_one_to_w = 1, +#endif + + .comment = _COMMENT, + +#ifdef _SYMBOL_DIGI + .symbol = 0, +#endif +#ifdef _SYMBOL_WIDE1_DIGI + .symbol = 1, +#endif +#ifdef _SYMBOL_HOUSE + .symbol = 2, +#endif +#ifdef _SYMBOL_RXIGATE + .symbol = 3, +#endif +#ifdef _SYMBOL_IGATE + .symbol = 4, +#endif + +#if defined(_WIDE1_PATH) + .path_type = 1, +#elif defined(_WIDE21_PATH) + .path_type = 2, +#else + .path_type = 0, +#endif + + .wx_transmit_period = _WX_INTERVAL, + + .beacon_transmit_period = _BCN_INTERVAL, + +#ifdef _BCN_ON_STARTUP + .beacon_at_bootup = 1 +#else + .beacon_at_bootup = 0 +#endif + +}; diff --git a/src/main.c b/src/main.c index 639da30..cd07f61 100644 --- a/src/main.c +++ b/src/main.c @@ -10,7 +10,9 @@ #include "main.h" #include "packet_tx_handler.h" + #include "station_config.h" +#include "config_data.h" #include "diag/Trace.h" #include "antilib_adc.h" @@ -390,8 +392,11 @@ int main(int argc, char* argv[]){ #endif + // initialize APRS path with zeros + memset (main_own_path, 0x00, sizeof(main_own_path)); + // configuring an APRS path used to transmit own packets (telemetry, wx, beacons) - main_own_path_ln = ConfigPath(main_own_path); + main_own_path_ln = ConfigPath(main_own_path, &config_data_basic); #ifdef INTERNAL_WATCHDOG // enable write access to watchdog registers diff --git a/system/src/aprs/telemetry.c b/system/src/aprs/telemetry.c index 09c349b..d0d7907 100644 --- a/system/src/aprs/telemetry.c +++ b/system/src/aprs/telemetry.c @@ -16,6 +16,7 @@ #include #include +#include uint16_t telemetry_counter = 0; @@ -187,13 +188,13 @@ void telemetry_send_chns_description(void) { // prepare a frame with channel names depending on SSID #if (_SSID == 0) - main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s :PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,QNH_QF_NAVBLE,HUM_QF_NAVBLE,WIND_QF_DEGR,WIND_QF_NAVB", _CALL); + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s :PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,QNH_QF_NAVBLE,HUM_QF_NAVBLE,WIND_QF_DEGR,WIND_QF_NAVB", _CALL); #endif #if (_SSID > 0 && _SSID <= 9) - main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d :PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,QNH_QF_NAVBLE,HUM_QF_NAVBLE,WIND_QF_DEGR,WIND_QF_NAVB", _CALL, _SSID); + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s-%d :PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,QNH_QF_NAVBLE,HUM_QF_NAVBLE,WIND_QF_DEGR,WIND_QF_NAVB", _CALL, _SSID); #endif #if (_SSID > 9 && _SSID <= 15) -main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,QNH_QF_NAVBLE,HUM_QF_NAVBLE,WIND_QF_DEGR,WIND_QF_NAVB", _CALL, _SSID); +main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s-%d:PARM.Rx10min,Tx10min,Digi10min,HostTx10m,Tempre,DS_QF_FULL,DS_QF_DEGRAD,DS_QF_NAVBLE,QNH_QF_NAVBLE,HUM_QF_NAVBLE,WIND_QF_DEGR,WIND_QF_NAVB", _CALL, _SSID); #endif // place a null terminator at the end @@ -213,13 +214,13 @@ main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:PARM.Rx10min,Tx10min, while (main_ax25.dcd == 1); #if (_SSID == 0) - main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.5,-50", _CALL); + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.5,-50", _CALL); #endif #if (_SSID > 0 && _SSID <= 9) - main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.5,-50", _CALL, _SSID); + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s-%d :EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.5,-50", _CALL, _SSID); #endif #if (_SSID > 9 && _SSID <= 15) - main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.5,-50", _CALL, _SSID); + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s-%d:EQNS.0,1,0,0,1,0,0,1,0,0,1,0,0,0.5,-50", _CALL, _SSID); #endif main_own_aprs_msg[main_own_aprs_msg_len] = 0; ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len); @@ -233,13 +234,13 @@ main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:PARM.Rx10min,Tx10min, while (main_ax25.dcd == 1); #if (_SSID == 0) - main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s :UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,Hi,Hi", _CALL); + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s :UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,Hi,Hi", _CALL); #endif #if (_SSID > 0 && _SSID <= 9) - main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d :UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,Hi,Hi", _CALL, _SSID); + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s-%d :UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,Hi,Hi", _CALL, _SSID); #endif #if (_SSID > 9 && _SSID <= 15) - main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%s-%d:UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,Hi,Hi", _CALL, _SSID); + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s-%d:UNIT.Pkt,Pkt,Pkt,Pkt,DegC,Hi,Hi,Hi,Hi,Hi,Hi,Hi", _CALL, _SSID); #endif main_own_aprs_msg[main_own_aprs_msg_len] = 0; ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len);