From 3408c801a8d6584b7aafcf337cc0dfa8d8d2e9bf Mon Sep 17 00:00:00 2001 From: Richard Meadows Date: Thu, 24 Mar 2016 14:06:24 +0000 Subject: [PATCH] [ariss] add ariss routines. These are geofenced only by areas where aprs is disallowed --- firmware/inc/hw_config.h | 9 +++++++ firmware/inc/location.h | 3 ++- firmware/src/location.c | 16 ++++++++++-- firmware/src/main.c | 37 +++++++++++++++++++++++++++ firmware/src/sequencer.c | 27 ++++++++++++++++++- firmware/test/tc/location_aprs.h | 2 +- firmware/test/tc/location_aprs_file.h | 2 +- 7 files changed, 90 insertions(+), 6 deletions(-) diff --git a/firmware/inc/hw_config.h b/firmware/inc/hw_config.h index aa716a3..1804bcf 100644 --- a/firmware/inc/hw_config.h +++ b/firmware/inc/hw_config.h @@ -254,6 +254,15 @@ #define APRS_USE_GEOFENCE 1 #define APRS_POWER RF_POWER_14dBm +/** + * ARISS APRS + * Geofence used is only "no aprs" + */ +#define ARISS_ENABLE 1 +#define ARISS_USE_PREDICT 0 +#define ARISS_USE_GEOFENCE 0 +#define ARISS_FREQUENCY 145825000 + /** * Prefix */ diff --git a/firmware/inc/location.h b/firmware/inc/location.h index 3fde862..69d1452 100644 --- a/firmware/inc/location.h +++ b/firmware/inc/location.h @@ -37,7 +37,8 @@ void location_prefix_update(int32_t lon_hn, int32_t lat_hn); /* Decisions */ bool location_telemetry_active(void); -bool location_aprs_active(void); +bool location_aprs_could_tx(void); +bool location_aprs_should_tx(void); int32_t location_aprs_frequency(void); char* location_aprs_call(void); char* location_prefix(void); diff --git a/firmware/src/location.c b/firmware/src/location.c index aa56e77..5cbde45 100644 --- a/firmware/src/location.c +++ b/firmware/src/location.c @@ -340,10 +340,22 @@ bool location_telemetry_active(void) /* Are we in a telemetry zone? */ return (current_telemetry_outline != -1); } + + +/** + * Returns if aprs could be transmitted in the current location + */ +bool location_aprs_could_tx(void) +{ + /* true if aprs disallowed */ + uint8_t no_aprs = (current_no_aprs_outline != -1); + + return !no_aprs; +} /** * Returns if aprs should be transmitted in the current location */ -bool location_aprs_active(void) +bool location_aprs_should_tx(void) { /* true if aprs disallowed */ uint8_t no_aprs = (current_no_aprs_outline != -1); @@ -354,7 +366,7 @@ bool location_aprs_active(void) return in_zone && (!no_aprs); } /** - * Returns the aprs frequency in the current zone. + * Returns the local aprs frequency in the current zone. * * Where aprs is inactive this function return 144.8MHz anyhow */ diff --git a/firmware/src/main.c b/firmware/src/main.c index 6eb0cd7..1bc9cf9 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -201,6 +201,43 @@ void aprs_telemetry(struct tracker_datapoint* dp) idle(IDLE_TELEMETRY_ACTIVE); } } +/** + * ARISS telemetry + */ +void ariss_telemetry(struct tracker_datapoint* dp) +{ + struct tracker_datapoint* backlog_dp_ptr; + + if (gps_is_locked() == GPS_NO_LOCK) return; /* Don't bother with no GPS */ + + char* prefix = location_prefix(); + char* call = location_aprs_call(); + + /* Set location */ + aprs_set_datapoint(dp); + + /* Set callsign and path */ + aprs_set_callsign(call); + aprs_set_path(APRS_PATH_ARISS); + + /* Set comment */ + backlog_dp_ptr = get_backlog(); + + if (backlog_dp_ptr != NULL) { /* Backlog comment if we can */ + aprs_set_backlog_comment(backlog_dp_ptr, prefix); + } else { + aprs_set_comment(prefix); + } + + /* Set frequency */ + telemetry_aprs_set_frequency(ARISS_FREQUENCY); + + /* Transmit packet and wait */ + telemetry_start(TELEMETRY_APRS, 0xFFFF); + while (telemetry_active()) { + idle(IDLE_TELEMETRY_ACTIVE); + } +} /** * Pips telemetry */ diff --git a/firmware/src/sequencer.c b/firmware/src/sequencer.c index d5edef0..4e8fec0 100644 --- a/firmware/src/sequencer.c +++ b/firmware/src/sequencer.c @@ -38,6 +38,7 @@ void rtty_telemetry(struct tracker_datapoint* dp); void contestia_telemetry(struct tracker_datapoint* dp); void aprs_telemetry(struct tracker_datapoint* dp); +void ariss_telemetry(struct tracker_datapoint* dp); void pips_telemetry(void); @@ -74,10 +75,11 @@ void telemetry_sequence(struct tracker_datapoint* dp, uint32_t n) #endif #endif /* TELEMETRY_ENABLE */ + /* APRS */ #if APRS_ENABLE #if APRS_USE_GEOFENCE - if (location_aprs_active()) { + if (location_aprs_should_tx()) { /* transmit only when we *should* */ #endif /* APRS */ @@ -87,6 +89,29 @@ void telemetry_sequence(struct tracker_datapoint* dp, uint32_t n) } #endif #endif /* APRS_ENABLE */ + + + /* ARISS */ +#if ARISS_ENABLE +#if ARISS_USE_PREDICT + if (true) { /* todo */ +#endif +#if ARISS_USE_GEOFENCE + if (location_aprs_could_tx()) { /* transmit anywhere it's no disallowed */ +#endif + + /* ARISS */ + ariss_telemetry(dp); + +#if ARISS_USE_GEOFENCE + } +#endif +#if ARISS_USE_PREDICT + } +#endif +#endif /* ARISS_ENABLE */ + + #endif /* RF_TX_ENABLE */ } diff --git a/firmware/test/tc/location_aprs.h b/firmware/test/tc/location_aprs.h index 3d3497f..090472c 100644 --- a/firmware/test/tc/location_aprs.h +++ b/firmware/test/tc/location_aprs.h @@ -36,7 +36,7 @@ __verification__ void location_aprs_tc(void) { ); - location_aprs_tc_results.tx_allow = location_aprs_active(); + location_aprs_tc_results.tx_allow = location_aprs_could_tx(); location_aprs_tc_results.frequency = location_aprs_frequency(); location_aprs_tc_results.prefix = location_prefix(); location_aprs_tc_results.callsign = aprs_callsign(location_aprs_call()); diff --git a/firmware/test/tc/location_aprs_file.h b/firmware/test/tc/location_aprs_file.h index 51a57d5..1db6f70 100644 --- a/firmware/test/tc/location_aprs_file.h +++ b/firmware/test/tc/location_aprs_file.h @@ -32,6 +32,6 @@ __verification__ void location_aprs_file_tc(void) { (int32_t)(location_aprs_file_tc_params.lon * 10 * 1000 * 1000) ); - location_aprs_file_tc_results.tx_allow = location_aprs_active(); + location_aprs_file_tc_results.tx_allow = location_aprs_could_tx(); location_aprs_file_tc_results.frequency = location_aprs_frequency(); }