- 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
pull/4/head
bob 2018-08-08 17:00:19 +10:00
rodzic 28da0ce01b
commit e20564ae4f
6 zmienionych plików z 56 dodań i 61 usunięć

Wyświetl plik

@ -16,43 +16,43 @@ const conf_t conf_flash_default = {
.active = false,
.cycle = TIME_S2I(60 * 5),
.init_delay = TIME_S2I(60),
.fixed = false // Add lat, lon alt fields if enabling fixed
.fixed = false // Add lat, lon, alt fields when enabling fixed
},
.radio_conf = {
.pwr = 0x1F,
.freq = FREQ_APRS_DYNAMIC,
.mod = MOD_AFSK,
.pwr = 0x7F,
.freq = 144800000,
.mod = MOD_2FSK,
.cca = 0x4F,
},
// App identity
.call = "VK2GJ-12",
.path = "WIDE1-1",
.symbol = SYM_ANTENNA,
.aprs_msg = true, // Enable APRS message reception on this call sign
.aprs_msg = true, // Enable APRS message reception on this app
},
// Secondary position app
.pos_sec = {
.beacon = {
.active = true,
.cycle = TIME_S2I(60 * 5),
.cycle = TIME_S2I(60 * 30), // Beacon interval
.init_delay = TIME_S2I(60),
.fixed = true, // Add lat, lon alt fields if enabling fixed
.fixed = true, // Add lat, lon alt fields when enabling fixed
.lat = -337331175, // Degrees (expressed in 1e-7 form)
.lon = 1511143478, // Degrees (expressed in 1e-7 form)
.alt = 144 // Altitude in metres
},
.radio_conf = {
.pwr = 0x7F,
.freq = 144800000,
.mod = MOD_2FSK,
.freq = FREQ_APRS_RECEIVE,
.mod = MOD_AFSK,
.cca = 0x4F
},
// App identity
.call = "VK2GJ-15",
.path = "",
.symbol = SYM_ANTENNA,
.aprs_msg = true, // Enable APRS message reception on this call sign
.call = "VK2GJ-5",
.path = "WIDE2-1",
.symbol = SYM_DIGIPEATER,
.aprs_msg = false, // Enable APRS message reception on this app
},
// Primary image app
@ -159,17 +159,9 @@ const conf_t conf_flash_default = {
.call = "VK2GJ-5",
.path = "WIDE2-1",
.symbol = SYM_DIGIPEATER,
.beacon = {
// The telemetry beacon service is enabled if true when RX and DIGI are enabled
// Receive is resumed after any transmission
.active = true,
.init_delay = TIME_S2I(20),
.cycle = TIME_S2I(60 * 30), // Beacon interval
.fixed = true, // Use fixed position data if true
.lat = -337331175, // Degrees (expressed in 1e-7 form)
.lon = 1511143478, // Degrees (expressed in 1e-7 form)
.alt = 144 // Altitude in metres
},
// A digipeater beacon can be added using one of the POS apps
// Set the POS identity the same as the dipipeater TX call sign
// Alternatively the digipeater can have its own .beacon entry here
},
},

Wyświetl plik

@ -499,17 +499,18 @@ static bool Si446x_init(const radio_unit_t radio) {
/* RSSI value compensation. */
if(is_part_Si4463(handler->radio_part))
Si446x_setProperty8(radio, Si446x_MODEM_RSSI_COMP, 0x48);
Si446x_setProperty8(radio, Si446x_MODEM_RSSI_COMP, 0x44);
else
Si446x_setProperty8(radio, Si446x_MODEM_RSSI_COMP, 0x40);
/*
* TODO: Preamble control should be set in each mode.
* TODO: Preamble configuration should be set in each mode.
* Will be needed for RX FSK mode.
* For now it is not relevant since:
* - we don't have RX FSK implemented yet.
* - RX AFSK preamble is decoded in the MCU DSP chain.
* - TX AFSK encodes its own preamble and then upsamples the entire packet.
* - TX 2FSK also encodes its own preamble which is sent as data by the PH.
*/
Si446x_setProperty8(radio, Si446x_PREAMBLE_CONFIG, 0x21);

Wyświetl plik

@ -176,6 +176,9 @@ static bool aquirePosition(dataPoint_t* tp, dataPoint_t* ltp,
TRACE_WARN("COLL > GPS acquisition stopped due low battery");
getPositionFallback(tp, ltp, GPS_LOWBATT2);
tp->gps_sats = 0;
tp->gps_ttff = 0;
tp->gps_pdop = 0;
GPS_Deinit();
return false;
@ -232,6 +235,14 @@ static bool aquirePosition(dataPoint_t* tp, dataPoint_t* ltp,
// Debug
TRACE_INFO("COLL > GPS sampling finished GPS LOCK");
// Read time from RTC
ptime_t time;
getTime(&time);
if(time.year == RTC_BASE_YEAR) {
/* Snapshot the RTC time. Old time entries can be adjusted using this data. */
ltp->gps_state = GPS_TIME;
ltp->gps_time = date2UnixTimestamp(&time);
}
// Calibrate RTC
setTime(&gpsFix.time);
@ -478,11 +489,8 @@ THD_FUNCTION(collectorThread, arg) {
}
/* Now check if the controller has been reset (RTC not set). */
getTime(&time);
if(time.year == RTC_BASE_YEAR)
/* Let initializer know this is a cold start (power loss). */
(void)chMsgSend(caller, MSG_RESET);
else
(void)chMsgSend(caller, MSG_OK);
/* Let initializer know if this is a normal or cold start (power loss). */
(void)chMsgSend(caller, time.year == RTC_BASE_YEAR ? MSG_RESET : MSG_OK);
/*
* Done with initialization now.
@ -506,22 +514,28 @@ THD_FUNCTION(collectorThread, arg) {
getGPIO(tp);
setSystemStatus(tp);
getTime(&time);
/* Set timeout based on cycle or minimum 1 minute. */
sysinterval_t gps_wait_time;
if(config->beacon.cycle < TIME_S2I(60))
gps_wait_time = TIME_S2I(60);
else
gps_wait_time = config->beacon.cycle;
sysinterval_t gps_wait_time =
config->beacon.cycle > TIME_S2I(60)
? TIME_S2I(60) : config->beacon.cycle;
getTime(&time);
if(time.year == RTC_BASE_YEAR) {
/*
* The RTC is not set.
* Enable the GPS and attempt a lock which results in setting the RTC.
*/
TRACE_INFO("COLL > Acquire time using GPS");
TRACE_INFO("COLL > Attempt time acquisition using GPS for 60 seconds");
if(aquirePosition(tp, ltp, gps_wait_time)) {
/* Acquisition succeeded. */
if(ltp->gps_state == GPS_TIME) {
/* Write the timestamp where RTC was calibrated. */
ltp->gps_sats = 0;
ltp->gps_ttff = 0;
ltp->gps_pdop = 0;
flash_writeLogDataPoint(ltp);
}
TRACE_INFO("COLL > Time update acquired from GPS");
} else {
/* Time is stale record. */

Wyświetl plik

@ -34,7 +34,7 @@
*/
#define GPS_STATE_NAMES \
"LOCKED1", "LOCKED2", "LOSS", "LOWBATT1", "LOWBATT2", "LOG", "OFF", \
"ERROR", "FIXED"
"ERROR", "FIXED", "TIME"
typedef enum {
GPS_LOCKED1, // The GPS is locked, the GPS has been switched off
@ -45,10 +45,11 @@ typedef enum {
GPS_LOG, // The tracker has just been switched on and the position has been taken from the log
GPS_OFF, // There was no prior acquisition by GPS
GPS_ERROR, // The GPS has a communication error
GPS_FIXED // Fixed location data used from APRS location
GPS_FIXED, // Fixed location data used from APRS location
GPS_TIME // Time stamp of RTC on first getting GPS time
} gpsState_t;
#define GPS_STATE_MAX GPS_FIXED
#define GPS_STATE_MAX GPS_TIME
typedef struct {
// Voltage and current measurement

Wyświetl plik

@ -62,24 +62,6 @@ THD_FUNCTION(bcnThread, arg) {
/* Continue here when collector responds. */
if(!p_sleep(&conf->beacon.sleep_conf)) {
//if(!isPositionValid(dataPoint) || dataPoint == NULL) {
/* TRACE_INFO("BCN > Waiting for position data for"
" %s (GPS state=%d)", conf->call, dataPoint->gps_state);*/
//if(conf->run_once) {
/* If this is run once so don't retry. */
//chHeapFree(conf);
//pktThdTerminateSelf();
//}
//if(isGPSbatteryOperable(dataPoint)) {
/* If the battery is good retry quickly.
* TODO: Rework and involve the p_sleep setting?
* Limit to a number of retries? */
//chThdSleep(TIME_S2I(60));
//continue;
//}
/* Else battery weak so beacon fallback data (TX may fail). */
//}
// Telemetry encoding parameter transmissions
if(conf_sram.tel_enc_cycle != 0
&& chVTTimeElapsedSinceX(last_conf_transmission)

Wyświetl plik

@ -103,7 +103,7 @@ void start_aprs_threads(radio_unit_t radio, radio_freq_t base_freq,
*
*/
bool transmitOnRadio(packet_t pp, const radio_freq_t base_freq,
const channel_hz_t step, const radio_ch_t chan,
const channel_hz_t step, radio_ch_t chan,
const radio_pwr_t pwr, const mod_t mod,
const radio_squelch_t cca) {
/* Select a radio by frequency. */
@ -140,6 +140,11 @@ bool transmitOnRadio(packet_t pp, const radio_freq_t base_freq,
return false;
}
/* Channel is only used with absolute base frequencies. */
if(base_freq < FREQ_CODES_END) {
chan = 0;
}
uint16_t len = ax25_get_info(pp, NULL);
/* Check information size. */
@ -166,7 +171,7 @@ bool transmitOnRadio(packet_t pp, const radio_freq_t base_freq,
rt.handler = handler;
rt.command = PKT_RADIO_TX_SEND;
rt.type = mod;
rt.base_frequency = base_freq;
rt.base_frequency = op_freq;
rt.step_hz = step;
rt.channel = chan;
rt.tx_power = pwr;