changeset 1028:71bbddbcc6a1

fc-shell: tch record implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 31 May 2016 00:43:00 +0000
parents 1178befeda76
children 333015c662bc
files rvinterf/asyncshell/Makefile rvinterf/asyncshell/tchcmd.c rvinterf/asyncshell/tchrec.c
diffstat 3 files changed, 89 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/asyncshell/Makefile	Mon May 30 23:19:30 2016 +0000
+++ b/rvinterf/asyncshell/Makefile	Tue May 31 00:43:00 2016 +0000
@@ -2,7 +2,7 @@
 CFLAGS=	-O2 -I../include
 PROG=	fc-shell
 OBJS=	at.o init.o main.o oneshot.o parse.o pktsort.o poweroff.o rxctl.o \
-	sendarb.o sendsp.o tchcmd.o usercmd.o
+	sendarb.o sendsp.o tchcmd.o tchrec.o usercmd.o
 LIBS=	../libasync/libasync.a ../libg23/libg23.a
 INSTBIN=/usr/local/bin
 
--- a/rvinterf/asyncshell/tchcmd.c	Mon May 30 23:19:30 2016 +0000
+++ b/rvinterf/asyncshell/tchcmd.c	Tue May 31 00:43:00 2016 +0000
@@ -112,7 +112,9 @@
 		/* TCH UL play code will hook in here */
 		return;
 	case TCH_DLBITS_IND:
-		/* TCH DL record code will hook in here */
+		if (rvi_msg_len != 43)
+			goto inv;
+		tch_dlbits_handler();
 		return;
 	default:
 		goto inv;
@@ -145,6 +147,7 @@
 		printf("error: too many arguments\n");
 		return;
 	}
+	show_tch_record_status();
 	printf("TCH raw dump mode is %s\n",
 		tch_rawdump_mode ? "enabled" : "disabled");
 }
@@ -163,6 +166,10 @@
 		cmd_tch_dumpraw(argc, argv);
 		return;
 	}
+	if (!strcmp(argv[0], "record")) {
+		cmd_tch_record(argc, argv);
+		return;
+	}
 	if (!strcmp(argv[0], "status")) {
 		cmd_tch_status(argc, argv);
 		return;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/asyncshell/tchrec.c	Tue May 31 00:43:00 2016 +0000
@@ -0,0 +1,80 @@
+/*
+ * TCH downlink recording functionality
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include "pktmux.h"
+#include "tch_feature.h"
+
+extern u_char rvi_msg[];
+extern int rvi_msg_len;
+
+static FILE *gsm_data_file;
+static u_long frame_count;
+
+void
+tch_dlbits_handler()
+{
+	if (!gsm_data_file)
+		return;
+	fwrite(rvi_msg + 9, 33, 1, gsm_data_file);
+	frame_count++;
+}
+
+static void
+cmd_tch_record_start(filename)
+	char *filename;
+{
+	if (gsm_data_file) {
+		printf("error: tch record session already in progress\n");
+		return;
+	}
+	gsm_data_file = fopen(filename, "w");
+	if (!gsm_data_file) {
+		perror(filename);
+		return;
+	}
+	printf("Starting TCH DL recording\n");
+	tch_rx_control(1);
+	send_tch_config_req(1);
+	frame_count = 0;
+}
+
+static void
+cmd_tch_record_stop()
+{
+	if (!gsm_data_file) {
+		printf("error: no tch record session in progress\n");
+		return;
+	}
+	fclose(gsm_data_file);
+	gsm_data_file = 0;
+	printf("TCH DL recording stopped, captured %lu speech frames\n",
+		frame_count);
+	send_tch_config_req(0);
+}
+
+void
+cmd_tch_record(argc, argv)
+	char **argv;
+{
+	if (argc < 2) {
+		printf("error: too few arguments\n");
+		return;
+	}
+	if (strcmp(argv[1], "stop"))
+		cmd_tch_record_start(argv[1]);
+	else
+		cmd_tch_record_stop();
+}
+
+void
+show_tch_record_status()
+{
+	printf("TCH DL recording: %s\n",
+		gsm_data_file ? "RUNNING" : "not running");
+}