altos/altosui: Add ability to disable telemetry/rdf completely
authorKeith Packard <keithp@keithp.com>
Fri, 19 Aug 2011 01:02:02 +0000 (18:02 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 20 Aug 2011 18:36:51 +0000 (11:36 -0700)
This turns off the telemetry system so that it never transmits telemetry
or RDF tones. In idle mode, it will still accept packet mode connections.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosConfig.java
altosui/AltosConfigUI.java
src/ao.h
src/ao_config.c
src/ao_telemetry.c

index 84c8a4a307d74528d42ff28af07dbd757be3bd51..b1e6bc12cf578f0ba51309b90774befbe19c5056 100644 (file)
@@ -79,6 +79,7 @@ public class AltosConfig implements ActionListener {
        int_ref         storage_size;
        int_ref         storage_erase_unit;
        int_ref         stored_flight;
        int_ref         storage_size;
        int_ref         storage_erase_unit;
        int_ref         stored_flight;
+       int_ref         radio_enable;
        string_ref      version;
        string_ref      product;
        string_ref      callsign;
        string_ref      version;
        string_ref      product;
        string_ref      callsign;
@@ -148,6 +149,7 @@ public class AltosConfig implements ActionListener {
                config_ui.set_radio_calibration(radio_calibration.get());
                config_ui.set_radio_frequency(frequency());
                config_ui.set_flight_log_max_enabled(stored_flight.get() < 0);
                config_ui.set_radio_calibration(radio_calibration.get());
                config_ui.set_radio_frequency(frequency());
                config_ui.set_flight_log_max_enabled(stored_flight.get() < 0);
+               config_ui.set_radio_enable(radio_enable.get());
                config_ui.set_flight_log_max_limit(log_limit());
                config_ui.set_flight_log_max(flight_log_max.get());
                config_ui.set_ignite_mode(ignite_mode.get());
                config_ui.set_flight_log_max_limit(log_limit());
                config_ui.set_flight_log_max(flight_log_max.get());
                config_ui.set_ignite_mode(ignite_mode.get());
@@ -177,6 +179,7 @@ public class AltosConfig implements ActionListener {
                get_int(line, "Ignite mode:", ignite_mode);
                get_int(line, "Pad orientation:", pad_orientation);
                get_int(line, "Radio setting:", radio_setting);
                get_int(line, "Ignite mode:", ignite_mode);
                get_int(line, "Pad orientation:", pad_orientation);
                get_int(line, "Radio setting:", radio_setting);
+               get_int(line, "Radio enable:", radio_enable);
                get_int(line, "Storage size:", storage_size);
                get_int(line, "Storage erase unit:", storage_erase_unit);
                get_int(line, "flight", stored_flight);
                get_int(line, "Storage size:", storage_size);
                get_int(line, "Storage erase unit:", storage_erase_unit);
                get_int(line, "flight", stored_flight);
@@ -255,6 +258,8 @@ public class AltosConfig implements ActionListener {
                                serial_line.printf("c c %s\n", callsign.get());
                                if (flight_log_max.get() != 0)
                                        serial_line.printf("c l %d\n", flight_log_max.get());
                                serial_line.printf("c c %s\n", callsign.get());
                                if (flight_log_max.get() != 0)
                                        serial_line.printf("c l %d\n", flight_log_max.get());
+                               if (radio_enable.get() >= 0)
+                                       serial_line.printf("c e %d\n", radio_enable.get());
                                if (ignite_mode.get() >= 0)
                                        serial_line.printf("c i %d\n", ignite_mode.get());
                                if (pad_orientation.get() >= 0)
                                if (ignite_mode.get() >= 0)
                                        serial_line.printf("c i %d\n", ignite_mode.get());
                                if (pad_orientation.get() >= 0)
@@ -373,6 +378,8 @@ public class AltosConfig implements ActionListener {
                radio_calibration.set(config_ui.radio_calibration());
                set_frequency(config_ui.radio_frequency());
                flight_log_max.set(config_ui.flight_log_max());
                radio_calibration.set(config_ui.radio_calibration());
                set_frequency(config_ui.radio_frequency());
                flight_log_max.set(config_ui.flight_log_max());
+               if (radio_enable.get() >= 0)
+                       radio_enable.set(config_ui.radio_enable());
                if (ignite_mode.get() >= 0)
                        ignite_mode.set(config_ui.ignite_mode());
                if (pad_orientation.get() >= 0)
                if (ignite_mode.get() >= 0)
                        ignite_mode.set(config_ui.ignite_mode());
                if (pad_orientation.get() >= 0)
@@ -412,6 +419,7 @@ public class AltosConfig implements ActionListener {
                radio_channel = new int_ref(0);
                radio_setting = new int_ref(0);
                radio_calibration = new int_ref(1186611);
                radio_channel = new int_ref(0);
                radio_setting = new int_ref(0);
                radio_calibration = new int_ref(1186611);
+               radio_enable = new int_ref(-1);
                flight_log_max = new int_ref(0);
                ignite_mode = new int_ref(-1);
                pad_orientation = new int_ref(-1);
                flight_log_max = new int_ref(0);
                ignite_mode = new int_ref(-1);
                pad_orientation = new int_ref(-1);
index 69afd691791c7ad01181a0e312f8ec6813742518..bb9e1cd23031ff3eb9c0e3434089fe848ffb1e00 100644 (file)
@@ -46,6 +46,7 @@ public class AltosConfigUI
        JLabel          frequency_label;
        JLabel          radio_calibration_label;
        JLabel          radio_frequency_label;
        JLabel          frequency_label;
        JLabel          radio_calibration_label;
        JLabel          radio_frequency_label;
+       JLabel          radio_enable_label;
        JLabel          flight_log_max_label;
        JLabel          ignite_mode_label;
        JLabel          pad_orientation_label;
        JLabel          flight_log_max_label;
        JLabel          ignite_mode_label;
        JLabel          pad_orientation_label;
@@ -61,6 +62,7 @@ public class AltosConfigUI
        JComboBox       apogee_delay_value;
        AltosFreqList   radio_frequency_value;
        JTextField      radio_calibration_value;
        JComboBox       apogee_delay_value;
        AltosFreqList   radio_frequency_value;
        JTextField      radio_calibration_value;
+       JRadioButton    radio_enable_value;
        JComboBox       flight_log_max_value;
        JComboBox       ignite_mode_value;
        JComboBox       pad_orientation_value;
        JComboBox       flight_log_max_value;
        JComboBox       ignite_mode_value;
        JComboBox       pad_orientation_value;
@@ -287,7 +289,7 @@ public class AltosConfigUI
                        radio_calibration_value.setEnabled(false);
                pane.add(radio_calibration_value, c);
 
                        radio_calibration_value.setEnabled(false);
                pane.add(radio_calibration_value, c);
 
-               /* Callsign */
+               /* Radio Enable */
                c = new GridBagConstraints();
                c.gridx = 0; c.gridy = 7;
                c.gridwidth = 4;
                c = new GridBagConstraints();
                c.gridx = 0; c.gridy = 7;
                c.gridwidth = 4;
@@ -295,11 +297,34 @@ public class AltosConfigUI
                c.anchor = GridBagConstraints.LINE_START;
                c.insets = il;
                c.ipady = 5;
                c.anchor = GridBagConstraints.LINE_START;
                c.insets = il;
                c.ipady = 5;
+               radio_enable_label = new JLabel("Telemetry/RDF Enable:");
+               pane.add(radio_enable_label, c);
+
+               c = new GridBagConstraints();
+               c.gridx = 4; c.gridy = 7;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.HORIZONTAL;
+               c.weightx = 1;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = ir;
+               c.ipady = 5;
+               radio_enable_value = new JRadioButton("Enabled");
+               radio_enable_value.addItemListener(this);
+               pane.add(radio_enable_value, c);
+
+               /* Callsign */
+               c = new GridBagConstraints();
+               c.gridx = 0; c.gridy = 8;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.NONE;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = il;
+               c.ipady = 5;
                callsign_label = new JLabel("Callsign:");
                pane.add(callsign_label, c);
 
                c = new GridBagConstraints();
                callsign_label = new JLabel("Callsign:");
                pane.add(callsign_label, c);
 
                c = new GridBagConstraints();
-               c.gridx = 4; c.gridy = 7;
+               c.gridx = 4; c.gridy = 8;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.HORIZONTAL;
                c.weightx = 1;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.HORIZONTAL;
                c.weightx = 1;
@@ -312,7 +337,7 @@ public class AltosConfigUI
 
                /* Flight log max */
                c = new GridBagConstraints();
 
                /* Flight log max */
                c = new GridBagConstraints();
-               c.gridx = 0; c.gridy = 8;
+               c.gridx = 0; c.gridy = 9;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_START;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_START;
@@ -322,7 +347,7 @@ public class AltosConfigUI
                pane.add(flight_log_max_label, c);
 
                c = new GridBagConstraints();
                pane.add(flight_log_max_label, c);
 
                c = new GridBagConstraints();
-               c.gridx = 4; c.gridy = 8;
+               c.gridx = 4; c.gridy = 9;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.HORIZONTAL;
                c.weightx = 1;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.HORIZONTAL;
                c.weightx = 1;
@@ -336,7 +361,7 @@ public class AltosConfigUI
 
                /* Ignite mode */
                c = new GridBagConstraints();
 
                /* Ignite mode */
                c = new GridBagConstraints();
-               c.gridx = 0; c.gridy = 9;
+               c.gridx = 0; c.gridy = 10;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_START;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_START;
@@ -346,7 +371,7 @@ public class AltosConfigUI
                pane.add(ignite_mode_label, c);
 
                c = new GridBagConstraints();
                pane.add(ignite_mode_label, c);
 
                c = new GridBagConstraints();
-               c.gridx = 4; c.gridy = 9;
+               c.gridx = 4; c.gridy = 10;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.HORIZONTAL;
                c.weightx = 1;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.HORIZONTAL;
                c.weightx = 1;
@@ -360,7 +385,7 @@ public class AltosConfigUI
 
                /* Pad orientation */
                c = new GridBagConstraints();
 
                /* Pad orientation */
                c = new GridBagConstraints();
-               c.gridx = 0; c.gridy = 10;
+               c.gridx = 0; c.gridy = 11;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_START;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_START;
@@ -370,7 +395,7 @@ public class AltosConfigUI
                pane.add(pad_orientation_label, c);
 
                c = new GridBagConstraints();
                pane.add(pad_orientation_label, c);
 
                c = new GridBagConstraints();
-               c.gridx = 4; c.gridy = 10;
+               c.gridx = 4; c.gridy = 11;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.HORIZONTAL;
                c.weightx = 1;
                c.gridwidth = 4;
                c.fill = GridBagConstraints.HORIZONTAL;
                c.weightx = 1;
@@ -384,7 +409,7 @@ public class AltosConfigUI
 
                /* Buttons */
                c = new GridBagConstraints();
 
                /* Buttons */
                c = new GridBagConstraints();
-               c.gridx = 0; c.gridy = 11;
+               c.gridx = 0; c.gridy = 12;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_START;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_START;
@@ -395,7 +420,7 @@ public class AltosConfigUI
                save.setActionCommand("Save");
 
                c = new GridBagConstraints();
                save.setActionCommand("Save");
 
                c = new GridBagConstraints();
-               c.gridx = 2; c.gridy = 11;
+               c.gridx = 2; c.gridy = 12;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
@@ -406,7 +431,7 @@ public class AltosConfigUI
                reset.setActionCommand("Reset");
 
                c = new GridBagConstraints();
                reset.setActionCommand("Reset");
 
                c = new GridBagConstraints();
-               c.gridx = 4; c.gridy = 11;
+               c.gridx = 4; c.gridy = 12;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
@@ -417,7 +442,7 @@ public class AltosConfigUI
                reboot.setActionCommand("Reboot");
 
                c = new GridBagConstraints();
                reboot.setActionCommand("Reboot");
 
                c = new GridBagConstraints();
-               c.gridx = 6; c.gridy = 11;
+               c.gridx = 6; c.gridy = 12;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_END;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_END;
@@ -559,6 +584,22 @@ public class AltosConfigUI
                return Integer.parseInt(radio_calibration_value.getText());
        }
 
                return Integer.parseInt(radio_calibration_value.getText());
        }
 
+       public void set_radio_enable(int new_radio_enable) {
+               if (new_radio_enable >= 0)
+                       radio_enable_value.setSelected(new_radio_enable > 0);
+               else {
+                       radio_enable_value.setSelected(true);
+                       radio_enable_value.setEnabled(false);
+               }
+       }
+
+       public int radio_enable() {
+               if (radio_enable_value.isEnabled())
+                       return radio_enable_value.isSelected() ? 1 : 0;
+               else
+                       return -1;
+       }
+
        public void set_callsign(String new_callsign) {
                callsign_value.setText(new_callsign);
        }
        public void set_callsign(String new_callsign) {
                callsign_value.setText(new_callsign);
        }
index 79452862e77d16a06f2e942dc673b732a1af67ee..8ac9ac3d09a30ede2a3825f669552de9e05afc1f 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -1415,7 +1415,7 @@ ao_igniter_init(void);
  */
 
 #define AO_CONFIG_MAJOR        1
  */
 
 #define AO_CONFIG_MAJOR        1
-#define AO_CONFIG_MINOR        7
+#define AO_CONFIG_MINOR        8
 
 struct ao_config {
        uint8_t         major;
 
 struct ao_config {
        uint8_t         major;
@@ -1431,6 +1431,7 @@ struct ao_config {
        uint8_t         ignite_mode;            /* minor version 5 */
        uint8_t         pad_orientation;        /* minor version 6 */
        uint32_t        radio_setting;          /* minor version 7 */
        uint8_t         ignite_mode;            /* minor version 5 */
        uint8_t         pad_orientation;        /* minor version 6 */
        uint32_t        radio_setting;          /* minor version 7 */
+       uint8_t         radio_enable;           /* minor version 8 */
 };
 
 #define AO_IGNITE_MODE_DUAL            0
 };
 
 #define AO_IGNITE_MODE_DUAL            0
index e0eae78e46cf6c5631efaa5b041b3d7a5ef8a879..eb1eea3fa843bcbd68833b2035ff068260a73bbd 100644 (file)
@@ -99,6 +99,8 @@ _ao_config_get(void)
                        ao_config.pad_orientation = AO_CONFIG_DEFAULT_PAD_ORIENTATION;
                if (ao_config.minor < 7)
                        ao_config.radio_setting = ao_config.radio_cal;
                        ao_config.pad_orientation = AO_CONFIG_DEFAULT_PAD_ORIENTATION;
                if (ao_config.minor < 7)
                        ao_config.radio_setting = ao_config.radio_cal;
+               if (ao_config.minor < 8)
+                       ao_config.radio_enable = TRUE;
                ao_config.minor = AO_CONFIG_MINOR;
                ao_config_dirty = 1;
        }
                ao_config.minor = AO_CONFIG_MINOR;
                ao_config_dirty = 1;
        }
@@ -392,6 +394,23 @@ ao_config_radio_setting_set(void) __reentrant
        ao_radio_recv_abort();
 }
 
        ao_radio_recv_abort();
 }
 
+void
+ao_config_radio_enable_show(void) __reentrant
+{
+       printf("Radio enable: %d\n", ao_config.radio_enable);
+}
+
+void
+ao_config_radio_enable_set(void) __reentrant
+{
+       ao_cmd_decimal();
+       if (ao_cmd_status != ao_cmd_success)
+               return;
+       _ao_config_edit_start();
+       ao_config.radio_enable = ao_cmd_lex_i;
+       _ao_config_edit_finish();
+}
+       
 struct ao_config_var {
        __code char     *str;
        void            (*set)(void) __reentrant;
 struct ao_config_var {
        __code char     *str;
        void            (*set)(void) __reentrant;
@@ -418,6 +437,10 @@ __code struct ao_config_var ao_config_vars[] = {
          ao_config_radio_channel_set,  ao_config_radio_channel_show },
        { "c <call>\0Callsign (8 char max)",
          ao_config_callsign_set,       ao_config_callsign_show },
          ao_config_radio_channel_set,  ao_config_radio_channel_show },
        { "c <call>\0Callsign (8 char max)",
          ao_config_callsign_set,       ao_config_callsign_show },
+       { "R <setting>\0Radio freq control (freq = 434.550 * setting/cal)",
+         ao_config_radio_setting_set,  ao_config_radio_setting_show },
+       { "e <0 disable, 1 enable>\0Enable telemetry and RDF",
+         ao_config_radio_enable_set, ao_config_radio_enable_show },
 #if HAS_ACCEL
        { "a <+g> <-g>\0Accel calib (0 for auto)",
          ao_config_accel_calibrate_set,ao_config_accel_calibrate_show },
 #if HAS_ACCEL
        { "a <+g> <-g>\0Accel calib (0 for auto)",
          ao_config_accel_calibrate_set,ao_config_accel_calibrate_show },
@@ -436,8 +459,6 @@ __code struct ao_config_var ao_config_vars[] = {
        { "o <0 antenna up, 1 antenna down>\0Set pad orientation",
          ao_config_pad_orientation_set,ao_config_pad_orientation_show },
 #endif
        { "o <0 antenna up, 1 antenna down>\0Set pad orientation",
          ao_config_pad_orientation_set,ao_config_pad_orientation_show },
 #endif
-       { "R <setting>\0Radio freq control (freq = 434.550 * setting/cal)",
-         ao_config_radio_setting_set,  ao_config_radio_setting_show },
        { "s\0Show",
          ao_config_show,               0 },
 #if HAS_EEPROM
        { "s\0Show",
          ao_config_show,               0 },
 #if HAS_EEPROM
index 8a18ba07a7e2f7544c5a660951582fd30a96abd8..c7338a581f64cef7e1dd73ac2c4dd94e274d9209 100644 (file)
@@ -180,6 +180,8 @@ ao_telemetry(void)
        int16_t         delay;
 
        ao_config_get();
        int16_t         delay;
 
        ao_config_get();
+       if (!ao_config.radio_enable)
+               ao_exit();
        while (!ao_flight_number)
                ao_sleep(&ao_flight_number);
 
        while (!ao_flight_number)
                ao_sleep(&ao_flight_number);