altos: Make APRS interval configurable
authorKeith Packard <keithp@keithp.com>
Sat, 8 Dec 2012 01:18:32 +0000 (17:18 -0800)
committerKeith Packard <keithp@keithp.com>
Sat, 8 Dec 2012 01:18:32 +0000 (17:18 -0800)
This provides a separate configuration value for APRS, allowing the
interval between APRS reports to vary.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/core/ao.h
src/core/ao_config.c
src/core/ao_telemetry.c
src/drivers/ao_aprs.h

index fa873efeba12b49f67c754677d0c4baa7c529e74..df5bbf487e2469702421b27a25d7ac9378351d03 100644 (file)
@@ -684,7 +684,7 @@ extern __xdata uint8_t ao_force_freq;
 #endif
 
 #define AO_CONFIG_MAJOR        1
-#define AO_CONFIG_MINOR        12
+#define AO_CONFIG_MINOR        13
 
 #define AO_AES_LEN 16
 
@@ -711,6 +711,7 @@ struct ao_config {
 #if AO_PYRO_NUM
        struct ao_pyro  pyro[AO_PYRO_NUM];      /* minor version 12 */
 #endif
+       uint16_t        aprs_interval;          /* minor version 13 */
 };
 
 #define AO_IGNITE_MODE_DUAL            0
@@ -718,9 +719,8 @@ struct ao_config {
 #define AO_IGNITE_MODE_MAIN            2
 
 #define AO_RADIO_ENABLE_CORE           1
-#define AO_RADIO_ENABLE_APRS           2
-#define AO_RADIO_DISABLE_TELEMETRY     4
-#define AO_RADIO_DISABLE_RDF           8
+#define AO_RADIO_DISABLE_TELEMETRY     2
+#define AO_RADIO_DISABLE_RDF           4
 
 #define AO_PAD_ORIENTATION_ANTENNA_UP  0
 #define AO_PAD_ORIENTATION_ANTENNA_DOWN        1
index 631581586e5c2c6168d69416b63a8be3843b24dc..0aac16a678ad1a6296bb1c4278bf5985bfbc0576 100644 (file)
@@ -139,6 +139,8 @@ _ao_config_get(void)
                if (minor < 12)
                        memset(&ao_config.pyro, '\0', sizeof (ao_config.pyro));
 #endif
+               if (minor < 13)
+                       ao_config.aprs_interval = 0;
                ao_config.minor = AO_CONFIG_MINOR;
                ao_config_dirty = 1;
        }
@@ -498,6 +500,27 @@ ao_config_key_set(void) __reentrant
 }
 #endif
 
+#if HAS_APRS
+
+void
+ao_config_aprs_show(void)
+{
+       printf ("APRS interval: %d\n", ao_config.aprs_interval);
+}
+
+void
+ao_config_aprs_set(void)
+{
+       ao_cmd_decimal();
+       if (ao_cmd_status != ao_cmd_success)
+               return;
+       _ao_config_edit_start();
+       ao_config.aprs_interval = ao_cmd_lex_i;
+       _ao_config_edit_finish();
+}
+
+#endif /* HAS_APRS */
+
 struct ao_config_var {
        __code char     *str;
        void            (*set)(void) __reentrant;
@@ -553,6 +576,10 @@ __code struct ao_config_var ao_config_vars[] = {
 #if AO_PYRO_NUM
        { "P <n,?>\0Configure pyro channels",
          ao_pyro_set, ao_pyro_show },
+#endif
+#if HAS_APRS
+       { "A <secs>\0APRS packet interval (0 disable)",
+         ao_config_aprs_set, ao_config_aprs_show },
 #endif
        { "s\0Show",
          ao_config_show,               0 },
index cfc72e048fe4b3c19f4c71fd41184be2dc110dcc..8d440e15410ff4bd7833bcd5da6e1380d8ba46f9 100644 (file)
@@ -299,7 +299,6 @@ ao_telemetry(void)
 #endif
                while (ao_telemetry_interval) {
 
-
 #if HAS_APRS
                        if (!(ao_config.radio_enable & AO_RADIO_DISABLE_TELEMETRY))
 #endif
@@ -343,10 +342,10 @@ ao_telemetry(void)
                                        ao_radio_rdf();
                        }
 #if HAS_APRS
-                       if ((ao_config.radio_enable & AO_RADIO_ENABLE_APRS) &&
+                       if (ao_config.aprs_interval != 0 &&
                            (int16_t) (ao_time() - ao_aprs_time) >= 0)
                        {
-                               ao_aprs_time = ao_time() + AO_APRS_INTERVAL_TICKS;
+                               ao_aprs_time = ao_time() + AO_SEC_TO_TICKS(ao_config.aprs_interval);
                                ao_aprs_send();
                        }
 #endif
index e00dd75bf6d79405778305f31535d88850464163..a033fa0b991b49edbf5ea264835d8d02199e8441 100644 (file)
@@ -18,8 +18,6 @@
 #ifndef _AO_APRS_H_
 #define _AO_APRS_H_
 
-#define AO_APRS_INTERVAL_TICKS AO_SEC_TO_TICKS(2)
-
 void
 ao_aprs_send(void);