X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosIdleFetch.java;h=8871e9cc1089d6c3aab624052962efa302a3f852;hp=4adc6c41d9d619feb5700c733bcc252d9b6a05d0;hb=1085ec5d57e0ed5d132f2bbdac1a0b6a32c0ab4a;hpb=e26306c9350ef1d107d4257ef1c09d15165c9154 diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index 4adc6c41..8871e9cc 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_2; +package org.altusmetrum.altoslib_11; import java.io.*; import java.util.*; @@ -38,8 +39,9 @@ class AltosIdler { static final int idle_sensor_mega = 12; static final int idle_sensor_emini = 13; static final int idle_sensor_tmini = 14; + static final int idle_sensor_tgps = 15; - public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException { + public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException, AltosUnknownProduct { for (int idler : idlers) { AltosIdle idle = null; switch (idler) { @@ -72,6 +74,10 @@ class AltosIdler { break; case idle_sensor_tmini: AltosSensorTMini.update_state(state, link, config_data); + break; + case idle_sensor_tgps: + AltosSensorTGPS.update_state(state, link, config_data); + break; } if (idle != null) idle.update_state(state); @@ -118,31 +124,43 @@ public class AltosIdleFetch implements AltosStateUpdate { AltosIdler.idle_ms5607, AltosIdler.idle_mma655x, AltosIdler.idle_imu, AltosIdler.idle_mag, AltosIdler.idle_sensor_mega), + new AltosIdler("EasyMega", + AltosIdler.idle_ms5607, AltosIdler.idle_mma655x, + AltosIdler.idle_imu, AltosIdler.idle_mag, + AltosIdler.idle_sensor_mega), + new AltosIdler("TeleGPS", + AltosIdler.idle_gps, + AltosIdler.idle_sensor_tgps), }; AltosLink link; - double frequency; - String callsign; - - public void update_state(AltosState state) throws InterruptedException { + public void update_state(AltosState state) throws InterruptedException, AltosUnknownProduct { try { + boolean matched = false; + /* Fetch config data from remote */ AltosConfigData config_data = new AltosConfigData(link); - state.set_state(AltosLib.ao_flight_startup); + state.set_state(AltosLib.ao_flight_stateless); state.set_serial(config_data.serial); state.set_callsign(config_data.callsign); state.set_ground_accel(config_data.accel_cal_plus); state.set_accel_g(config_data.accel_cal_plus, config_data.accel_cal_minus); + state.set_product(config_data.product); + state.set_firmware_version(config_data.version); + state.set_log_space(config_data.log_space); for (AltosIdler idler : idlers) { if (idler.matches(config_data)) { idler.update_state(state, link, config_data); + matched = true; break; } } + if (!matched) + throw new AltosUnknownProduct(config_data.product); state.set_received_time(System.currentTimeMillis()); } catch (TimeoutException te) { } - + } public AltosIdleFetch(AltosLink link) {