aboutsummaryrefslogtreecommitdiffstats
path: root/src/zeitansage/main.c
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2020-01-11 18:00:25 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2020-01-18 18:54:28 +0100
commitb2089bb529a43ea136609b099eb77e88e21c087a (patch)
tree08c0347f1562aad7fbaa73c92f0ca395580e38aa /src/zeitansage/main.c
parentb1ea4e574f3d76c28de0c79ce253d5d9634c00cf (diff)
Implementation of German "Zeitansage", spoken by Elvira Bader
Diffstat (limited to 'src/zeitansage/main.c')
-rw-r--r--src/zeitansage/main.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/zeitansage/main.c b/src/zeitansage/main.c
new file mode 100644
index 0000000..779573b
--- /dev/null
+++ b/src/zeitansage/main.c
@@ -0,0 +1,103 @@
+/* Zeitansage main
+ *
+ * (C) 2020 by Andreas Eversberg <jolly@eversberg.eu>
+ * All Rights Reserved
+ *
+ * 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, either version 3 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
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include "../libsample/sample.h"
+#include "../libdebug/debug.h"
+#include "../libmobile/call.h"
+#include "../libmobile/main_mobile.h"
+#include "../liboptions/options.h"
+#include "zeitansage.h"
+#include "samples.h"
+
+double audio_level_dBm = -16.0;
+int alerting = 0;
+
+
+void print_help(const char *arg0)
+{
+ main_mobile_print_help(arg0, "-c hw:0,0 ");
+ /* - - */
+ printf(" -G --gain\n");
+ printf(" Gain of audio level relative to 1 mW on a 600 Ohm line. (default = %.0f)\n", audio_level_dBm);
+ printf(" -A --alerting\n");
+ printf(" Play as early audio while alerting. Don't send a connect.\n");
+ main_mobile_print_hotkeys();
+}
+
+static void add_options(void)
+{
+ main_mobile_add_options();
+ option_add('G', "gain", 1);
+ option_add('A', "alerting", 0);
+}
+
+static int handle_options(int short_option, int argi, char **argv)
+{
+ switch (short_option) {
+ case 'G':
+ audio_level_dBm = atof(argv[argi]);
+ break;
+ case 'A':
+ alerting = 1;
+ send_patterns = 0;
+ break;
+ default:
+ return main_mobile_handle_options(short_option, argi, argv);
+ }
+
+ return 1;
+}
+
+int main(int argc, char *argv[])
+{
+ int rc, argi;
+
+ /* init system specific tones */
+ init_samples();
+
+ main_mobile_init();
+
+ /* handle options / config file */
+ add_options();
+ rc = options_config_file("~/.osmocom/analog/zeitansage.conf", handle_options);
+ if (rc < 0)
+ return 0;
+ argi = options_command_line(argc, argv, handle_options);
+ if (argi <= 0)
+ return argi;
+
+ /* inits */
+ fm_init(fast_math);
+ zeit_init(audio_level_dBm, alerting);
+
+ main_mobile(&quit, latency, interval, NULL, "1191", 4);
+
+//fail:
+ /* exits */
+ zeit_exit();
+ fm_exit();
+
+ return 0;
+}
+