blob: 61a6cc35c6d2477f7b8d4c7e4e36fa21148a6240 [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001#include <stdlib.h>
2#include <stdio.h>
3#include <string.h>
4#include <errno.h>
5#include "ql_voice.h"
6
7
8
9void voice_call_cb(ql_voice_record_array_t *p_arr)
10{
11
12 printf("len1-voice_call_cb-id:%d, number:%s, state:%d, tech:%d, dir:%d, end_reason:%d\n", p_arr->records[0].id, p_arr->records[0].number, p_arr->records[0].state, p_arr->records[0].tech,
13 p_arr->records[0].dir, p_arr->records[0].end_reason);
14 if(2 == p_arr->len)
15 {
16 printf("len2-id:%d, number:%s, state:%d, tech:%d, dir:%d, end_reason:%d\n", p_arr->records[1].id, p_arr->records[1].number, p_arr->records[1].state, p_arr->records[1].tech,
17 p_arr->records[1].dir, p_arr->records[1].end_reason);
18 }
19}
20
21void voice_servicie_error_cb(int error)
22{
23 printf("===== voice Service Abort =====\n");
24}
25
26
27
28
29
30
31int main(int argc, char *argv[])
32{
33 char operator[10];
34 int opt;
35 int ret;
36 int voice;
37 int direction;
38 int value;
39 int pullsel;
40
41 mbtk_log_init("radio", "voice_TEST");
42
43 printf("=========ql voice main=========\n"
44 "\t0 exit\n"
45 "\t1 voice init\n"
46 "\t2 voice deinit\n"
47 "\t3 voice set call cb\n"
48 "\t4 voice set ser error cb\n"
49 "\t5 voice dial\n"
50 "\t6 voice hangup all\n"
51 "\t7 voice answer\n"
52 "\t8 voice get records\n"
53 "\t9 voice send dtmf char\n"
54 "operator: >> \n");
55
56 while(1)
57 {
58 memset(operator, 0, sizeof(operator));
59 fgets(operator, sizeof(operator), stdin);
60 fflush(stdin);
61 opt = atoi(operator);
62 switch (opt)
63 {
64 case 0:
65 printf("main exit\n");
66 return 0;
67 case 1:
68 {
69 printf(">>>>>voice init\n");
70 ret = ql_voice_init();
71 if(ret != 0)
72 {
73 printf("ql_voice_init fail\n");
74 }
75 else
76 {
77 printf("ql_voice_init success\n");
78 }
79 }
80 break;
81 case 2:
82 {
83 printf(">>>>>voice uninit\n");
84
85 ret = ql_voice_deinit();
86 if(ret != 0)
87 {
88 printf("ql_voice_uninit fail\n");
89 printf("ret=%d\n", ret);
90 }
91 else
92 {
93 printf("ql_voice_uninit success\n");
94
95 }
96 }
97 break;
98 case 3:
99 {
100 printf(">>>>>Input set recv cb<<<<<\n");
101
102 ret = ql_voice_set_call_cb(voice_call_cb);
103 if(ret != 0)
104 {
105 printf("ql_voice_set_msg_recv_cb fail\n");
106 }
107 else
108 {
109 printf("ql_voice_set_msg_recv_cb success\n");
110 }
111
112 }
113 break;
114 case 4:
115 {
116 printf(">>>>>Input set ser cb<<<<<\n");
117
118 ret = ql_voice_set_service_error_cb(voice_servicie_error_cb);
119 if(ret < 0)
120 {
121 printf("ql_voice_set_service_error_cb fail\n");
122 }
123 else
124 {
125 printf("ql_voice_set_service_error_cb success\n");
126 }
127
128 }
129 break;
130 case 5:
131 {
132 printf(">>>>>Input ql_voice_dial<<<<<\n");
133
134 uint32_t id = 0;
135 ret = ql_voice_dial("13388257090", 11, &id);
136 printf("id:%d", id);
137 if(ret < 0)
138 {
139 printf("ql_voice_dial fail\n");
140 }
141 else
142 {
143 printf("ql_voice_dial success\n");
144 }
145 }
146 break;
147 case 6:
148 {
149 printf(">>>>>Input ql_voice_hangup_all<<<<<\n");
150
151 int id = 0;
152 ret = ql_voice_hangup_all();
153 if(ret < 0)
154 {
155 printf("ql_voice_hangup_all fail\n");
156 }
157 else
158 {
159 printf("ql_voice_hangup_all success\n");
160 }
161 }
162 break;
163 case 7:
164 {
165 printf(">>>>>Input ql_voice_answer<<<<<\n");
166
167 int id = 0;
168 ret = ql_voice_answer(1);
169 if(ret < 0)
170 {
171 printf("ql_voice_answer fail\n");
172 }
173 else
174 {
175 printf("ql_voice_answer success\n");
176 }
177 }
178 break;
179 case 8:
180 {
181 printf(">>>>>Input ql_voice_get_records<<<<<\n");
182
183 ql_voice_record_array_t arr;
184 ret = ql_voice_get_records(&arr);
185 printf("len1-id:%d, number:%s, state:%d, tech:%d, dir:%d, end_reason:%d\n", arr.records[0].id, arr.records[0].number, arr.records[0].state, arr.records[0].tech,
186 arr.records[0].dir, arr.records[0].end_reason);
187 if(2 == arr.len)
188 {
189 printf("len2-id:%d, number:%s, state:%d, tech:%d, dir:%d, end_reason:%d\n", arr.records[1].id, arr.records[1].number, arr.records[1].state, arr.records[1].tech,
190 arr.records[1].dir, arr.records[1].end_reason);
191 }
192
193 if(ret < 0)
194 {
195 printf("ql_voice_get_records fail\n");
196 }
197 else
198 {
199 printf("ql_voice_get_records success\n");
200 }
201 }
202 break;
203 case 9:
204 {
205 printf(">>>>>Input ql_voice_send_dtmf_char<<<<<\n");
206
207
208 char inputChar;
209
210 printf("Enter set dtmf\n");
211 scanf(" %c", &inputChar);
212 printf("inputChar is %c\n", inputChar);
213
214 ret = ql_voice_send_dtmf_char(1, inputChar);
215 if(ret < 0)
216 {
217 printf("ql_voice_send_dtmf_char fail\n");
218 }
219 else
220 {
221 printf("ql_voice_send_dtmf_char success\n");
222 }
223 }
224 break;
225
226
227
228 default:
229 break;
230 }
231
232 }
233
234 return 0;
235
236}