Fixed a couple of APRS timing/format issues. APRS txes after rtty, on 144.8 when geofence is disabled

master
Richard Meadows 2015-07-12 00:17:04 +01:00
rodzic c3ce6a5bae
commit cd46495152
7 zmienionych plików z 63 dodań i 46 usunięć

Wyświetl plik

@ -32,6 +32,6 @@ bool latlon_in_aprs_zone(int32_t aprs_zone, int32_t aprs_zone_outline, float lon
bool aprs_location_tx_allow(void);
int32_t aprs_location_frequency(void);
void aprs_location_update(float lon, float lat, uint32_t altitude);
void aprs_location_update(float lon, float lat);
#endif /* LOCATION_H */

Wyświetl plik

@ -112,10 +112,15 @@ void encode_backlog(char* str, tracker_datapoint* dp)
char compressed_altitude[3];
char telemetry[TELEMETRY_FIELD_LEN];
/* Process lat/lon/alt */
float lat = (float)dp->latitude / 10000000.0; /* degrees */
float lon = (float)dp->longitude / 10000000.0; /* degrees */
uint32_t altitude = dp->altitude / 1000; /* meters */
/* Prepare the aprs position report */
encode_latitude(compressed_lat, dp->latitude);
encode_longitude(compressed_lon, dp->longitude);
encode_altitude(compressed_altitude, dp->altitude);
encode_latitude(compressed_lat, lat);
encode_longitude(compressed_lon, lon);
encode_altitude(compressed_altitude, altitude);
/* Encode telemetry string */
encode_telemetry(telemetry, dp);
@ -168,6 +173,11 @@ uint8_t aprs_start(void)
/* Don't run without a valid position */
if (!_dp || (_dp->latitude == 0 && _dp->longitude == 0)) return 0;
/* Process lat/lon/alt */
float lat = (float)_dp->latitude / 10000000.0; /* degrees */
float lon = (float)_dp->longitude / 10000000.0; /* degrees */
uint32_t altitude = _dp->altitude / 1000; /* meters */
/* Encode the destination / source / path addresses */
uint32_t addresses_len = sprintf(addresses, "%-6s%c%-6s%c%-6s%c",
"APRS", 0,
@ -175,9 +185,9 @@ uint8_t aprs_start(void)
"WIDE2", 1);
/* Prepare the aprs position report */
encode_latitude(compressed_lat, _dp->latitude);
encode_longitude(compressed_lon, _dp->longitude);
uint32_t altitude_feet = _dp->altitude * 3.2808; /* Oh yeah feet! Everyone loves feet */
encode_latitude(compressed_lat, lat);
encode_longitude(compressed_lon, lon);
uint32_t altitude_feet = altitude * 3.2808; /* Oh yeah feet! Everyone loves feet */
/* Encode telemetry string */
encode_telemetry(telemetry, _dp);

Wyświetl plik

@ -40,7 +40,7 @@ struct tracker_time time = {0};
struct tracker_datapoint* dp;
/* Low Power Mode */
#define LOW_POWER(d) (d->solar < 0.2)
#define LOW_POWER(d) ((d->solar < 0.2) || (d->solar < 1.1))
void rtty_telemetry(struct tracker_datapoint* dp);
void contestia_telemetry(struct tracker_datapoint* dp);
@ -74,6 +74,40 @@ void read_gps_time(void)
/* TODO calculate epoch time here */
}
/**
* Pars of cron job that handles telemetry
*/
void cron_telemetry(struct tracker_time* t)
{
/* ---- Telemetry output ---- */
/* RTTY */
if (t->second == 0 && !LOW_POWER(dp)) {
rtty_telemetry(dp);
/* Contestia */
} else if (t->second == 30 && !LOW_POWER(dp)) {
contestia_telemetry(dp);
/* Low Power */
} else if (t->second == 0 && LOW_POWER(dp)) {
if ((t->minute % 2) == 0) {
rtty_telemetry(dp);
} else {
contestia_telemetry(dp);
}
/* Pip */
} else if ((t->second % 1) == 0) {
pips_telemetry();
}
/* APRS */
#ifdef APRS_ENABLE
if ((t->minute % 2) == 0 && t->second == 0) {
aprs_telemetry(dp);
}
#endif
}
/**
* Cron job for the system.
*
@ -93,38 +127,11 @@ void do_cron(void)
collect_data_async();
}
/* ---- Telemetry output ---- */
/* RTTY */
if (t.second == 0 && !LOW_POWER(dp)) {
rtty_telemetry(dp);
/* Contestia */
} else if (t.second == 30 && !LOW_POWER(dp)) {
contestia_telemetry(dp);
/* Low Power */
} else if (t.second == 0 && LOW_POWER(dp)) {
if ((t.minute % 2) == 0) {
rtty_telemetry(dp);
} else {
contestia_telemetry(dp);
}
/* APRS */
#ifdef APRS_ENABLE
} else if ((t.minute % 2) == 0 && t.second == 0) {
aprs_telemetry(dp);
#endif
/* Pips */
} else if ((t.second % 1) == 0) {
pips_telemetry();
}
cron_telemetry(&t);
/* ---- Record for backlog ---- */
if ((t.minute % 1 == 0) && (t.second == 0)) {
if ((t.minute == 0) && (t.second == 0)) { /* Once per hour */
kick_the_watchdog();

Wyświetl plik

@ -119,13 +119,10 @@ int32_t aprs_location_frequency(void) {
/**
* Updates the aprs location based on the current lat/lon
*/
void aprs_location_update(float lon, float lat, uint32_t altitude) {
void aprs_location_update(float lon, float lat) {
uint32_t z, outline;
/* Record altitude */
_altitude = altitude;
/* Were we in an aprs zone last time? */
if (current_aprs_zone >= 0 && current_aprs_zone_outline >= 0) {

Wyświetl plik

@ -166,10 +166,9 @@ void aprs_telemetry(struct tracker_datapoint* dp) {
float lat = (float)dp->latitude / 10000000.0; /* degrees */
float lon = (float)dp->longitude / 10000000.0; /* degrees */
uint32_t altitude = dp->altitude / 1000; /* meters */
/* Update location */
aprs_location_update(lon, lat, altitude);
aprs_location_update(lon, lat);
#if APRS_USE_GEOFENCE
/* aprs okay here? */
@ -180,7 +179,7 @@ void aprs_telemetry(struct tracker_datapoint* dp) {
aprs_set_datapoint(dp);
/* Set comment */
if ((dp->time.hour % 2) == 0) {
if ((dp->time.minute % 4) == 0) {
aprs_set_comment(APRS_COMMENT);
} else {
backlog_dp_ptr = get_backlog();
@ -193,7 +192,11 @@ void aprs_telemetry(struct tracker_datapoint* dp) {
}
/* Set frequency */
#if APRS_USE_GEOFENCE
telemetry_aprs_set_frequency(aprs_location_frequency());
#else
telemetry_aprs_set_frequency(144800000);
#endif
/* Transmit packet and wait */
telemetry_start(TELEMETRY_APRS, 0xFFFF);

Wyświetl plik

@ -21,7 +21,7 @@ struct location_aprs_tc_results {
/* Function */
__verification__ void location_aprs_tc(void) {
aprs_location_update(location_aprs_tc_params.lon, location_aprs_tc_params.lat, 1000);
aprs_location_update(location_aprs_tc_params.lon, location_aprs_tc_params.lat);
location_aprs_tc_results.tx_allow = aprs_location_tx_allow();
location_aprs_tc_results.frequency = aprs_location_frequency();

Wyświetl plik

@ -26,7 +26,7 @@ struct location_aprs_file_tc_results {
/* Function */
__verification__ void location_aprs_file_tc(void) {
aprs_location_update(location_aprs_file_tc_params.lon, location_aprs_file_tc_params.lat, 1000);
aprs_location_update(location_aprs_file_tc_params.lon, location_aprs_file_tc_params.lat);
location_aprs_file_tc_results.tx_allow = aprs_location_tx_allow();
location_aprs_file_tc_results.frequency = aprs_location_frequency();