summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-08-17 21:03:12 -0700
committerKeith Packard <keithp@keithp.com>2014-08-17 21:03:12 -0700
commit44e389c31e5958c1a050fbe0dce5d7971a9d6a86 (patch)
tree555052ed26c42b5595d6298a2027ea004fd01e4c /src/kernel
parent5a51efd7f9b49ffadc91ccaf7a0d69566301c009 (diff)
altos: Add telerepeat-v1.0
This uses TeleBT hardware to provide a telemetry repeater, receiving packets on one frequency and re-transmitting them on another. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/ao_config.c41
-rw-r--r--src/kernel/ao_config.h9
-rw-r--r--src/kernel/ao_forward.c48
-rw-r--r--src/kernel/ao_forward.h24
4 files changed, 121 insertions, 1 deletions
diff --git a/src/kernel/ao_config.c b/src/kernel/ao_config.c
index d1b93122..6b8a1813 100644
--- a/src/kernel/ao_config.c
+++ b/src/kernel/ao_config.c
@@ -93,10 +93,18 @@ ao_config_put(void)
#endif
#if HAS_RADIO
+
+#if HAS_RADIO_FORWARD
+__xdata uint32_t ao_send_radio_setting;
+#endif
+
void
ao_config_set_radio(void)
{
ao_config.radio_setting = ao_freq_to_set(ao_config.frequency, ao_config.radio_cal);
+#if HAS_RADIO_FORWARD
+ ao_send_radio_setting = ao_freq_to_set(ao_config.send_frequency, ao_config.radio_cal);
+#endif
}
#endif /* HAS_RADIO */
@@ -208,6 +216,10 @@ _ao_config_get(void)
if (minor < 20)
ao_config.radio_rate = AO_CONFIG_DEFAULT_RADIO_RATE;
#endif
+#if HAS_RADIO_FORWARD
+ if (minor < 21)
+ ao_config.send_frequency = 434550;
+#endif
ao_config.minor = AO_CONFIG_MINOR;
ao_config_dirty = 1;
}
@@ -302,6 +314,31 @@ ao_config_frequency_set(void) __reentrant
#endif
+#if HAS_RADIO_FORWARD
+void
+ao_config_send_frequency_show(void) __reentrant
+{
+ printf("Send frequency: %ld\n",
+ ao_config.send_frequency);
+}
+
+void
+ao_config_send_frequency_set(void) __reentrant
+{
+ ao_cmd_decimal();
+ if (ao_cmd_status != ao_cmd_success)
+ return;
+ _ao_config_edit_start();
+ ao_config.send_frequency = ao_cmd_lex_u32;
+ ao_config_set_radio();
+ _ao_config_edit_finish();
+#if HAS_RADIO_RECV
+ ao_radio_recv_abort();
+#endif
+}
+
+#endif
+
#if HAS_FLIGHT
void
@@ -863,6 +900,10 @@ __code struct ao_config_var ao_config_vars[] = {
#if HAS_RADIO
{ "F <freq>\0Frequency (kHz)",
ao_config_frequency_set, ao_config_frequency_show },
+#if HAS_RADIO_FORWARD
+ { "R <freq>\0Repeater output frequency (kHz)",
+ ao_config_send_frequency_set, ao_config_send_frequency_show },
+#endif
{ "c <call>\0Callsign (8 char max)",
ao_config_callsign_set, ao_config_callsign_show },
{ "e <0 disable, 1 enable>\0Enable telemetry and RDF",
diff --git a/src/kernel/ao_config.h b/src/kernel/ao_config.h
index 0be3e14d..164584a5 100644
--- a/src/kernel/ao_config.h
+++ b/src/kernel/ao_config.h
@@ -57,7 +57,7 @@
#endif
#define AO_CONFIG_MAJOR 1
-#define AO_CONFIG_MINOR 20
+#define AO_CONFIG_MINOR 21
#define AO_AES_LEN 16
@@ -112,8 +112,15 @@ struct ao_config {
#if HAS_RADIO_RATE
uint8_t radio_rate; /* minor version 20 */
#endif
+#if HAS_RADIO_FORWARD
+ uint32_t send_frequency; /* minor version 21 */
+#endif
};
+#if HAS_RADIO_FORWARD
+extern __xdata uint32_t ao_send_radio_setting;
+#endif
+
#define AO_IGNITE_MODE_DUAL 0
#define AO_IGNITE_MODE_APOGEE 1
#define AO_IGNITE_MODE_MAIN 2
diff --git a/src/kernel/ao_forward.c b/src/kernel/ao_forward.c
new file mode 100644
index 00000000..2a937183
--- /dev/null
+++ b/src/kernel/ao_forward.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright © 2014 Keith Packard <keithp@keithp.com>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "ao.h"
+#include "ao_telem.h"
+
+static void
+ao_monitor_forward(void)
+{
+ uint32_t recv_radio_setting;
+ static __xdata struct ao_telemetry_all_recv packet;
+
+ for (;;) {
+ while (ao_monitoring)
+ ao_sleep(DATA_TO_XDATA(&ao_monitoring));
+
+ if (!ao_radio_recv(&packet, sizeof(packet), 0))
+ continue;
+ if (!(packet.status & PKT_APPEND_STATUS_1_CRC_OK))
+ continue;
+ recv_radio_setting = ao_config.radio_setting;
+ ao_config.radio_setting = ao_send_radio_setting;
+ ao_radio_send(&packet.telemetry, sizeof (packet.telemetry));
+ ao_config.radio_setting = recv_radio_setting;
+ }
+}
+
+static __xdata struct ao_task ao_monitor_forward_task;
+
+void
+ao_monitor_forward_init(void) __reentrant
+{
+ ao_add_task(&ao_monitor_forward_task, ao_monitor_forward, "monitor_forward");
+}
diff --git a/src/kernel/ao_forward.h b/src/kernel/ao_forward.h
new file mode 100644
index 00000000..1897dc08
--- /dev/null
+++ b/src/kernel/ao_forward.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright © 2014 Keith Packard <keithp@keithp.com>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef _AO_FORWARD_H_
+#define _AO_FORWARD_H_
+
+void
+ao_monitor_forward_init(void) __reentrant;
+
+#endif /* _AO_FORWARD_H_ */