[flight][gps-no-lock] Change behaviour when GPS looses lock, refactor gps_is_locked to return enum

* Transmit UHF telemetery with no lock
* Hibernate for <1s with no lock, regardless of flight state
main-solar-only
Richard Meadows 2016-01-19 18:21:53 +00:00
rodzic bcaa65d7c3
commit c5c9da8af4
4 zmienionych plików z 34 dodań i 21 usunięć

Wyświetl plik

@ -31,7 +31,7 @@
/**
* GPS Error types
*/
enum gps_error_t {
enum gps_error {
GPS_NOERROR,
GPS_ERROR_BAD_CHECKSUM,
GPS_ERROR_INVALID_FRAME,
@ -40,11 +40,19 @@ enum gps_error_t {
/**
* GPS Flight State
*/
enum gps_flight_state_t {
enum gps_flight_state {
GPS_FLIGHT_STATE_LAUNCH,
GPS_FLIGHT_STATE_FLOAT,
};
/**
* GPS Lock State
*/
enum gps_lock_state {
GPS_NO_LOCK = 0,
GPS_LOCKED = 1,
};
/* UBX ------------------------------------------------------------- */
#ifdef GPS_TYPE_UBX
@ -93,7 +101,7 @@ struct gps_data_t {
};
enum gps_error_t gps_get_error_state(void);
enum gps_error gps_get_error_state(void);
struct gps_data_t gps_get_data(void);
void gps_setup(void);
@ -117,7 +125,7 @@ struct gps_data_t {
uint8_t time_to_first_fix; /* seconds / counts */
};
enum gps_error_t gps_get_error_state(void);
enum gps_error gps_get_error_state(void);
struct gps_data_t gps_get_data(void);
void gps_setup(void);
@ -125,8 +133,8 @@ void gps_setup(void);
#endif /* GPS_TYPE_DUMMY */
/* All ------------------------------------------------------------ */
enum gps_flight_state_t gps_get_flight_state(void);
uint8_t gps_is_locked(void);
enum gps_flight_state gps_get_flight_state(void);
enum gps_lock_state gps_is_locked(void);
void gps_usart_init_enable(uint32_t baud_rate);
void gps_reset(void);

Wyświetl plik

@ -56,26 +56,26 @@ int32_t osp_index = SFD_WAITING;
uint16_t osp_payload_length = 0;
uint8_t osp_irq_buffer[OSP_BUFFER_LEN];
volatile enum gps_error_t gps_error_state;
volatile enum gps_error gps_error_state;
/**
* GPS Active?
*/
enum gps_power_state_t {
enum gps_power_state {
GPS_HIBERNATE = 0,
GPS_ACTIVE = 1,
};
enum gps_power_state_t gps_power_state = GPS_HIBERNATE;
enum gps_power_state gps_power_state = GPS_HIBERNATE;
/**
* Flight State
*/
enum gps_flight_state_t gps_flight_state = GPS_FLIGHT_STATE_LAUNCH;
enum gps_flight_state gps_flight_state = GPS_FLIGHT_STATE_LAUNCH;
/**
* Lock State
*/
uint8_t gps_is_locked_priv = 0;
enum gps_lock_state gps_is_locked_priv = GPS_NO_LOCK;
/**
* OSP Output Ack/Nack
@ -476,7 +476,7 @@ void _osp_send_message(osp_message_t* message, uint8_t* payload, uint16_t length
/**
* Returns current flight state
*/
enum gps_flight_state_t gps_get_flight_state(void)
enum gps_flight_state gps_get_flight_state(void)
{
return gps_flight_state;
}
@ -532,7 +532,7 @@ void gps_make_hibernate(void)
/**
* Lock state. Set by gps_get_data
*/
uint8_t gps_is_locked(void)
enum gps_lock_state gps_is_locked(void)
{
return gps_is_locked_priv;
}
@ -547,7 +547,7 @@ uint8_t gps_is_locked(void)
* Gets the current error state of the GPS to check validity of last
* request
*/
enum gps_error_t gps_get_error_state(void)
enum gps_error gps_get_error_state(void)
{
return gps_error_state;
}

Wyświetl plik

@ -170,7 +170,7 @@ void aprs_telemetry(struct tracker_datapoint* dp)
{
struct tracker_datapoint* backlog_dp_ptr;
if (!gps_is_locked()) return; /* Don't bother with no GPS */
if (gps_is_locked() == GPS_NO_LOCK) return; /* Don't bother with no GPS */
/* Set location */
aprs_set_datapoint(dp);
@ -215,10 +215,14 @@ uint32_t hibernate_time_s = 1;
*/
void set_hibernate_time(void)
{
if (gps_get_flight_state() == GPS_FLIGHT_STATE_LAUNCH) {
hibernate_time_s = 60-20; /* approx every minute */
if (gps_is_locked() == GPS_NO_LOCK) { /* no lock */
hibernate_time_s = 0; /* shortest hibernate */
} else if (gps_get_flight_state() == GPS_FLIGHT_STATE_LAUNCH) {
hibernate_time_s = 60-20; /* approx every minute */
} else {
hibernate_time_s = 240-20; /* approx every 4 minutes */
hibernate_time_s = 240-20; /* approx every 4 minutes */
}
}
/**

Wyświetl plik

@ -55,7 +55,8 @@ void telemetry_sequence(struct tracker_datapoint* dp, uint32_t n)
#if RF_TX_ENABLE
#if TELEMETRY_ENABLE
#if TELEMETRY_USE_GEOFENCE
if (location_telemetry_active()) {
if (location_telemetry_active() || /* in geofence */
(gps_is_locked() == GPS_NO_LOCK)) { /* or no lock */
#endif
/* Pips */
@ -106,8 +107,8 @@ void run_sequencer(uint32_t n)
telemetry_sequence(dp, n);
/* Backlog */
if (((n % 15) == 10) && /* Once per hour with 4 minute wakeup */
gps_is_locked()) { /* And the gps is locked */
if (((n % 15) == 10) && /* Once per hour with 4 minute wakeup */
gps_is_locked() == GPS_LOCKED) { /* And the gps is locked */
record_backlog(dp);
}
}