altoslib: renamed AltosSensorTMini2, but didn't update AltosIdleFetch
[fw/altos] / altoslib / AltosIdleFetch.java
index 9ff5a53ed35d54ece442520c126970586d70beb2..73717e178c38569fbe2e426cae50f04ce809fccf 100644 (file)
@@ -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_7;
+package org.altusmetrum.altoslib_11;
 
 import java.io.*;
 import java.util.*;
@@ -37,10 +38,11 @@ class AltosIdler {
        static final int        idle_sensor_metrum = 11;
        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_tmini2 = 14;
        static final int        idle_sensor_tgps = 15;
+       static final int        idle_sensor_tmini3 = 16;
 
-       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) {
@@ -71,12 +73,15 @@ class AltosIdler {
                        case idle_sensor_emini:
                                AltosSensorEMini.update_state(state, link, config_data);
                                break;
-                       case idle_sensor_tmini:
-                               AltosSensorTMini.update_state(state, link, config_data);
+                       case idle_sensor_tmini2:
+                               AltosSensorTMini2.update_state(state, link, config_data);
                                break;
                        case idle_sensor_tgps:
                                AltosSensorTGPS.update_state(state, link, config_data);
                                break;
+                       case idle_sensor_tmini3:
+                               AltosSensorTMini3.update_state(state, link, config_data);
+                               break;
                        }
                        if (idle != null)
                                idle.update_state(state);
@@ -107,7 +112,11 @@ public class AltosIdleFetch implements AltosStateUpdate {
 
                new AltosIdler("TeleMini-v2",
                               AltosIdler.idle_ms5607,
-                              AltosIdler.idle_sensor_tmini),
+                              AltosIdler.idle_sensor_tmini2),
+
+               new AltosIdler("TeleMini-v3",
+                              AltosIdler.idle_ms5607,
+                              AltosIdler.idle_sensor_tmini3),
 
                new AltosIdler("TeleMetrum-v1",
                               AltosIdler.idle_gps,
@@ -134,11 +143,9 @@ public class AltosIdleFetch implements AltosStateUpdate {
 
        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_stateless);
@@ -147,12 +154,17 @@ public class AltosIdleFetch implements AltosStateUpdate {
                        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) {
                }