annotate rvinterf/asyncshell/tchrec.c @ 1028:71bbddbcc6a1

fc-shell: tch record implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 31 May 2016 00:43:00 +0000
parents
children 194967e11b2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1028
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * TCH downlink recording functionality
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "pktmux.h"
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "tch_feature.h"
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 extern u_char rvi_msg[];
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 extern int rvi_msg_len;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 static FILE *gsm_data_file;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 static u_long frame_count;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 void
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 tch_dlbits_handler()
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (!gsm_data_file)
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 return;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 fwrite(rvi_msg + 9, 33, 1, gsm_data_file);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 frame_count++;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 static void
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 cmd_tch_record_start(filename)
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 char *filename;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 if (gsm_data_file) {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 printf("error: tch record session already in progress\n");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 return;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 gsm_data_file = fopen(filename, "w");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 if (!gsm_data_file) {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 perror(filename);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 return;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 printf("Starting TCH DL recording\n");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 tch_rx_control(1);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 send_tch_config_req(1);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 frame_count = 0;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 static void
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 cmd_tch_record_stop()
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 if (!gsm_data_file) {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 printf("error: no tch record session in progress\n");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 return;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 fclose(gsm_data_file);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 gsm_data_file = 0;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 printf("TCH DL recording stopped, captured %lu speech frames\n",
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 frame_count);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 send_tch_config_req(0);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 void
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 cmd_tch_record(argc, argv)
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 char **argv;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 if (argc < 2) {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 printf("error: too few arguments\n");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 return;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 if (strcmp(argv[1], "stop"))
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 cmd_tch_record_start(argv[1]);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 else
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 cmd_tch_record_stop();
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 void
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 show_tch_record_status()
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 printf("TCH DL recording: %s\n",
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 gsm_data_file ? "RUNNING" : "not running");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 }