Skip to content

Commit e20564a

Browse files
committed
Updates:
- Set config.c example of using POS for DIGI beacon - Collector waits 60S max for GPS fix before giving result - New datapoint with state GPS_TIME is written when RTC is first set
1 parent 28da0ce commit e20564a

File tree

6 files changed

+56
-61
lines changed

6 files changed

+56
-61
lines changed

tracker/software/source/config/config.c

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,43 @@ const conf_t conf_flash_default = {
1616
.active = false,
1717
.cycle = TIME_S2I(60 * 5),
1818
.init_delay = TIME_S2I(60),
19-
.fixed = false // Add lat, lon alt fields if enabling fixed
19+
.fixed = false // Add lat, lon, alt fields when enabling fixed
2020
},
2121
.radio_conf = {
22-
.pwr = 0x1F,
23-
.freq = FREQ_APRS_DYNAMIC,
24-
.mod = MOD_AFSK,
22+
.pwr = 0x7F,
23+
.freq = 144800000,
24+
.mod = MOD_2FSK,
2525
.cca = 0x4F,
2626
},
2727
// App identity
2828
.call = "VK2GJ-12",
2929
.path = "WIDE1-1",
3030
.symbol = SYM_ANTENNA,
31-
.aprs_msg = true, // Enable APRS message reception on this call sign
31+
.aprs_msg = true, // Enable APRS message reception on this app
3232
},
3333

3434
// Secondary position app
3535
.pos_sec = {
3636
.beacon = {
3737
.active = true,
38-
.cycle = TIME_S2I(60 * 5),
38+
.cycle = TIME_S2I(60 * 30), // Beacon interval
3939
.init_delay = TIME_S2I(60),
40-
.fixed = true, // Add lat, lon alt fields if enabling fixed
40+
.fixed = true, // Add lat, lon alt fields when enabling fixed
4141
.lat = -337331175, // Degrees (expressed in 1e-7 form)
4242
.lon = 1511143478, // Degrees (expressed in 1e-7 form)
4343
.alt = 144 // Altitude in metres
4444
},
4545
.radio_conf = {
4646
.pwr = 0x7F,
47-
.freq = 144800000,
48-
.mod = MOD_2FSK,
47+
.freq = FREQ_APRS_RECEIVE,
48+
.mod = MOD_AFSK,
4949
.cca = 0x4F
5050
},
5151
// App identity
52-
.call = "VK2GJ-15",
53-
.path = "",
54-
.symbol = SYM_ANTENNA,
55-
.aprs_msg = true, // Enable APRS message reception on this call sign
52+
.call = "VK2GJ-5",
53+
.path = "WIDE2-1",
54+
.symbol = SYM_DIGIPEATER,
55+
.aprs_msg = false, // Enable APRS message reception on this app
5656
},
5757

5858
// Primary image app
@@ -159,17 +159,9 @@ const conf_t conf_flash_default = {
159159
.call = "VK2GJ-5",
160160
.path = "WIDE2-1",
161161
.symbol = SYM_DIGIPEATER,
162-
.beacon = {
163-
// The telemetry beacon service is enabled if true when RX and DIGI are enabled
164-
// Receive is resumed after any transmission
165-
.active = true,
166-
.init_delay = TIME_S2I(20),
167-
.cycle = TIME_S2I(60 * 30), // Beacon interval
168-
.fixed = true, // Use fixed position data if true
169-
.lat = -337331175, // Degrees (expressed in 1e-7 form)
170-
.lon = 1511143478, // Degrees (expressed in 1e-7 form)
171-
.alt = 144 // Altitude in metres
172-
},
162+
// A digipeater beacon can be added using one of the POS apps
163+
// Set the POS identity the same as the dipipeater TX call sign
164+
// Alternatively the digipeater can have its own .beacon entry here
173165
},
174166
},
175167

tracker/software/source/drivers/si446x.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,18 @@ static bool Si446x_init(const radio_unit_t radio) {
499499

500500
/* RSSI value compensation. */
501501
if(is_part_Si4463(handler->radio_part))
502-
Si446x_setProperty8(radio, Si446x_MODEM_RSSI_COMP, 0x48);
502+
Si446x_setProperty8(radio, Si446x_MODEM_RSSI_COMP, 0x44);
503503
else
504504
Si446x_setProperty8(radio, Si446x_MODEM_RSSI_COMP, 0x40);
505505

506506
/*
507-
* TODO: Preamble control should be set in each mode.
507+
* TODO: Preamble configuration should be set in each mode.
508508
* Will be needed for RX FSK mode.
509509
* For now it is not relevant since:
510510
* - we don't have RX FSK implemented yet.
511511
* - RX AFSK preamble is decoded in the MCU DSP chain.
512512
* - TX AFSK encodes its own preamble and then upsamples the entire packet.
513+
* - TX 2FSK also encodes its own preamble which is sent as data by the PH.
513514
*/
514515
Si446x_setProperty8(radio, Si446x_PREAMBLE_CONFIG, 0x21);
515516

tracker/software/source/threads/collector.c

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ static bool aquirePosition(dataPoint_t* tp, dataPoint_t* ltp,
176176

177177
TRACE_WARN("COLL > GPS acquisition stopped due low battery");
178178
getPositionFallback(tp, ltp, GPS_LOWBATT2);
179+
tp->gps_sats = 0;
180+
tp->gps_ttff = 0;
181+
tp->gps_pdop = 0;
179182
GPS_Deinit();
180183
return false;
181184

@@ -232,6 +235,14 @@ static bool aquirePosition(dataPoint_t* tp, dataPoint_t* ltp,
232235
// Debug
233236
TRACE_INFO("COLL > GPS sampling finished GPS LOCK");
234237

238+
// Read time from RTC
239+
ptime_t time;
240+
getTime(&time);
241+
if(time.year == RTC_BASE_YEAR) {
242+
/* Snapshot the RTC time. Old time entries can be adjusted using this data. */
243+
ltp->gps_state = GPS_TIME;
244+
ltp->gps_time = date2UnixTimestamp(&time);
245+
}
235246
// Calibrate RTC
236247
setTime(&gpsFix.time);
237248

@@ -478,11 +489,8 @@ THD_FUNCTION(collectorThread, arg) {
478489
}
479490
/* Now check if the controller has been reset (RTC not set). */
480491
getTime(&time);
481-
if(time.year == RTC_BASE_YEAR)
482-
/* Let initializer know this is a cold start (power loss). */
483-
(void)chMsgSend(caller, MSG_RESET);
484-
else
485-
(void)chMsgSend(caller, MSG_OK);
492+
/* Let initializer know if this is a normal or cold start (power loss). */
493+
(void)chMsgSend(caller, time.year == RTC_BASE_YEAR ? MSG_RESET : MSG_OK);
486494

487495
/*
488496
* Done with initialization now.
@@ -506,22 +514,28 @@ THD_FUNCTION(collectorThread, arg) {
506514
getGPIO(tp);
507515
setSystemStatus(tp);
508516

509-
getTime(&time);
510517
/* Set timeout based on cycle or minimum 1 minute. */
511-
sysinterval_t gps_wait_time;
512-
if(config->beacon.cycle < TIME_S2I(60))
513-
gps_wait_time = TIME_S2I(60);
514-
else
515-
gps_wait_time = config->beacon.cycle;
518+
sysinterval_t gps_wait_time =
519+
config->beacon.cycle > TIME_S2I(60)
520+
? TIME_S2I(60) : config->beacon.cycle;
521+
522+
getTime(&time);
516523
if(time.year == RTC_BASE_YEAR) {
517524
/*
518525
* The RTC is not set.
519526
* Enable the GPS and attempt a lock which results in setting the RTC.
520527
*/
521-
TRACE_INFO("COLL > Acquire time using GPS");
528+
TRACE_INFO("COLL > Attempt time acquisition using GPS for 60 seconds");
522529

523530
if(aquirePosition(tp, ltp, gps_wait_time)) {
524531
/* Acquisition succeeded. */
532+
if(ltp->gps_state == GPS_TIME) {
533+
/* Write the timestamp where RTC was calibrated. */
534+
ltp->gps_sats = 0;
535+
ltp->gps_ttff = 0;
536+
ltp->gps_pdop = 0;
537+
flash_writeLogDataPoint(ltp);
538+
}
525539
TRACE_INFO("COLL > Time update acquired from GPS");
526540
} else {
527541
/* Time is stale record. */

tracker/software/source/threads/collector.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
#define GPS_STATE_NAMES \
3636
"LOCKED1", "LOCKED2", "LOSS", "LOWBATT1", "LOWBATT2", "LOG", "OFF", \
37-
"ERROR", "FIXED"
37+
"ERROR", "FIXED", "TIME"
3838

3939
typedef enum {
4040
GPS_LOCKED1, // The GPS is locked, the GPS has been switched off
@@ -45,10 +45,11 @@ typedef enum {
4545
GPS_LOG, // The tracker has just been switched on and the position has been taken from the log
4646
GPS_OFF, // There was no prior acquisition by GPS
4747
GPS_ERROR, // The GPS has a communication error
48-
GPS_FIXED // Fixed location data used from APRS location
48+
GPS_FIXED, // Fixed location data used from APRS location
49+
GPS_TIME // Time stamp of RTC on first getting GPS time
4950
} gpsState_t;
5051

51-
#define GPS_STATE_MAX GPS_FIXED
52+
#define GPS_STATE_MAX GPS_TIME
5253

5354
typedef struct {
5455
// Voltage and current measurement

tracker/software/source/threads/rxtx/beacon.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,6 @@ THD_FUNCTION(bcnThread, arg) {
6262

6363
/* Continue here when collector responds. */
6464
if(!p_sleep(&conf->beacon.sleep_conf)) {
65-
//if(!isPositionValid(dataPoint) || dataPoint == NULL) {
66-
/* TRACE_INFO("BCN > Waiting for position data for"
67-
" %s (GPS state=%d)", conf->call, dataPoint->gps_state);*/
68-
//if(conf->run_once) {
69-
/* If this is run once so don't retry. */
70-
//chHeapFree(conf);
71-
//pktThdTerminateSelf();
72-
//}
73-
//if(isGPSbatteryOperable(dataPoint)) {
74-
/* If the battery is good retry quickly.
75-
* TODO: Rework and involve the p_sleep setting?
76-
* Limit to a number of retries? */
77-
//chThdSleep(TIME_S2I(60));
78-
//continue;
79-
//}
80-
/* Else battery weak so beacon fallback data (TX may fail). */
81-
//}
82-
8365
// Telemetry encoding parameter transmissions
8466
if(conf_sram.tel_enc_cycle != 0
8567
&& chVTTimeElapsedSinceX(last_conf_transmission)

tracker/software/source/threads/rxtx/radio.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void start_aprs_threads(radio_unit_t radio, radio_freq_t base_freq,
103103
*
104104
*/
105105
bool transmitOnRadio(packet_t pp, const radio_freq_t base_freq,
106-
const channel_hz_t step, const radio_ch_t chan,
106+
const channel_hz_t step, radio_ch_t chan,
107107
const radio_pwr_t pwr, const mod_t mod,
108108
const radio_squelch_t cca) {
109109
/* Select a radio by frequency. */
@@ -140,6 +140,11 @@ bool transmitOnRadio(packet_t pp, const radio_freq_t base_freq,
140140
return false;
141141
}
142142

143+
/* Channel is only used with absolute base frequencies. */
144+
if(base_freq < FREQ_CODES_END) {
145+
chan = 0;
146+
}
147+
143148
uint16_t len = ax25_get_info(pp, NULL);
144149

145150
/* Check information size. */
@@ -166,7 +171,7 @@ bool transmitOnRadio(packet_t pp, const radio_freq_t base_freq,
166171
rt.handler = handler;
167172
rt.command = PKT_RADIO_TX_SEND;
168173
rt.type = mod;
169-
rt.base_frequency = base_freq;
174+
rt.base_frequency = op_freq;
170175
rt.step_hz = step;
171176
rt.channel = chan;
172177
rt.tx_power = pwr;

0 commit comments

Comments
 (0)