b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 1 | #include <stdlib.h> |
| 2 | #include <stdio.h> |
| 3 | #include <string.h> |
| 4 | #include <errno.h> |
| 5 | #include "ql_voice.h" |
| 6 | |
| 7 | |
| 8 | |
| 9 | void 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 | |
| 21 | void voice_servicie_error_cb(int error) |
| 22 | { |
| 23 | printf("===== voice Service Abort =====\n"); |
| 24 | } |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | int main(int argc, char *argv[]) |
| 32 | { |
l.yang | e4f94f4 | 2025-04-29 18:08:39 -0700 | [diff] [blame] | 33 | |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 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" |
l.yang | e4f94f4 | 2025-04-29 18:08:39 -0700 | [diff] [blame] | 54 | "\t10 voice set sim card\n" |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 55 | "operator: >> \n"); |
| 56 | |
| 57 | while(1) |
| 58 | { |
l.yang | e4f94f4 | 2025-04-29 18:08:39 -0700 | [diff] [blame] | 59 | scanf("%d",&opt); |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 60 | switch (opt) |
| 61 | { |
| 62 | case 0: |
| 63 | printf("main exit\n"); |
| 64 | return 0; |
| 65 | case 1: |
| 66 | { |
| 67 | printf(">>>>>voice init\n"); |
| 68 | ret = ql_voice_init(); |
| 69 | if(ret != 0) |
| 70 | { |
| 71 | printf("ql_voice_init fail\n"); |
| 72 | } |
| 73 | else |
| 74 | { |
| 75 | printf("ql_voice_init success\n"); |
| 76 | } |
| 77 | } |
| 78 | break; |
| 79 | case 2: |
| 80 | { |
| 81 | printf(">>>>>voice uninit\n"); |
| 82 | |
| 83 | ret = ql_voice_deinit(); |
| 84 | if(ret != 0) |
| 85 | { |
| 86 | printf("ql_voice_uninit fail\n"); |
| 87 | printf("ret=%d\n", ret); |
| 88 | } |
| 89 | else |
| 90 | { |
| 91 | printf("ql_voice_uninit success\n"); |
| 92 | |
| 93 | } |
| 94 | } |
| 95 | break; |
| 96 | case 3: |
| 97 | { |
| 98 | printf(">>>>>Input set recv cb<<<<<\n"); |
| 99 | |
| 100 | ret = ql_voice_set_call_cb(voice_call_cb); |
| 101 | if(ret != 0) |
| 102 | { |
| 103 | printf("ql_voice_set_msg_recv_cb fail\n"); |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | printf("ql_voice_set_msg_recv_cb success\n"); |
| 108 | } |
| 109 | |
| 110 | } |
| 111 | break; |
| 112 | case 4: |
| 113 | { |
| 114 | printf(">>>>>Input set ser cb<<<<<\n"); |
| 115 | |
| 116 | ret = ql_voice_set_service_error_cb(voice_servicie_error_cb); |
| 117 | if(ret < 0) |
| 118 | { |
| 119 | printf("ql_voice_set_service_error_cb fail\n"); |
| 120 | } |
| 121 | else |
| 122 | { |
| 123 | printf("ql_voice_set_service_error_cb success\n"); |
| 124 | } |
| 125 | |
| 126 | } |
| 127 | break; |
| 128 | case 5: |
| 129 | { |
| 130 | printf(">>>>>Input ql_voice_dial<<<<<\n"); |
| 131 | |
| 132 | uint32_t id = 0; |
l.yang | e4f94f4 | 2025-04-29 18:08:39 -0700 | [diff] [blame] | 133 | char phone_num[16] = {0}; |
| 134 | printf("Please input dial number\n"); |
| 135 | scanf("%s",phone_num); |
| 136 | ret = ql_voice_dial(phone_num,11, &id); |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 137 | printf("id:%d", id); |
| 138 | if(ret < 0) |
| 139 | { |
| 140 | printf("ql_voice_dial fail\n"); |
| 141 | } |
| 142 | else |
| 143 | { |
| 144 | printf("ql_voice_dial success\n"); |
| 145 | } |
| 146 | } |
| 147 | break; |
| 148 | case 6: |
| 149 | { |
| 150 | printf(">>>>>Input ql_voice_hangup_all<<<<<\n"); |
| 151 | |
| 152 | int id = 0; |
| 153 | ret = ql_voice_hangup_all(); |
| 154 | if(ret < 0) |
| 155 | { |
| 156 | printf("ql_voice_hangup_all fail\n"); |
| 157 | } |
| 158 | else |
| 159 | { |
| 160 | printf("ql_voice_hangup_all success\n"); |
| 161 | } |
| 162 | } |
| 163 | break; |
| 164 | case 7: |
| 165 | { |
| 166 | printf(">>>>>Input ql_voice_answer<<<<<\n"); |
| 167 | |
| 168 | int id = 0; |
| 169 | ret = ql_voice_answer(1); |
| 170 | if(ret < 0) |
| 171 | { |
| 172 | printf("ql_voice_answer fail\n"); |
| 173 | } |
| 174 | else |
| 175 | { |
| 176 | printf("ql_voice_answer success\n"); |
| 177 | } |
| 178 | } |
| 179 | break; |
| 180 | case 8: |
| 181 | { |
| 182 | printf(">>>>>Input ql_voice_get_records<<<<<\n"); |
| 183 | |
| 184 | ql_voice_record_array_t arr; |
| 185 | ret = ql_voice_get_records(&arr); |
| 186 | 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, |
| 187 | arr.records[0].dir, arr.records[0].end_reason); |
| 188 | if(2 == arr.len) |
| 189 | { |
| 190 | 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, |
| 191 | arr.records[1].dir, arr.records[1].end_reason); |
| 192 | } |
| 193 | |
| 194 | if(ret < 0) |
| 195 | { |
| 196 | printf("ql_voice_get_records fail\n"); |
| 197 | } |
| 198 | else |
| 199 | { |
| 200 | printf("ql_voice_get_records success\n"); |
| 201 | } |
| 202 | } |
| 203 | break; |
| 204 | case 9: |
| 205 | { |
| 206 | printf(">>>>>Input ql_voice_send_dtmf_char<<<<<\n"); |
| 207 | |
| 208 | |
| 209 | char inputChar; |
| 210 | |
| 211 | printf("Enter set dtmf\n"); |
| 212 | scanf(" %c", &inputChar); |
| 213 | printf("inputChar is %c\n", inputChar); |
| 214 | |
| 215 | ret = ql_voice_send_dtmf_char(1, inputChar); |
| 216 | if(ret < 0) |
| 217 | { |
| 218 | printf("ql_voice_send_dtmf_char fail\n"); |
| 219 | } |
| 220 | else |
| 221 | { |
| 222 | printf("ql_voice_send_dtmf_char success\n"); |
| 223 | } |
| 224 | } |
| 225 | break; |
l.yang | e4f94f4 | 2025-04-29 18:08:39 -0700 | [diff] [blame] | 226 | |
| 227 | case 10: |
| 228 | { |
| 229 | int ret = -1; |
| 230 | int choice = -1; |
| 231 | printf("1:sim card 1, 2:sim card 2\n"); |
| 232 | while (1) |
| 233 | { |
| 234 | if (scanf("%d", &choice) == 1) |
| 235 | { |
| 236 | if (choice == 1 || choice == 2) |
| 237 | { |
| 238 | break; |
| 239 | } |
| 240 | else |
| 241 | { |
| 242 | printf("invlid input \n"); |
| 243 | } |
| 244 | } |
| 245 | else |
| 246 | { |
| 247 | |
| 248 | int c; |
| 249 | while ((c = getchar()) != '\n' && c != EOF); |
| 250 | printf("invalid input \n"); |
| 251 | } |
| 252 | |
| 253 | } |
| 254 | if (choice == 1) |
| 255 | { |
| 256 | ret = ql_set_sms_slot(QL_SIM_SLOT_1); |
| 257 | if(ret != 0) |
| 258 | { |
| 259 | printf("ql_set_sms_slot failed %d\n",ret); |
| 260 | } |
| 261 | else |
| 262 | { |
| 263 | printf("ql_set_sms_slot success \n"); |
| 264 | } |
| 265 | } |
| 266 | else if (choice == 2) |
| 267 | { |
| 268 | ret = ql_set_sms_slot(QL_SIM_SLOT_2); |
| 269 | if(ret != 0) |
| 270 | { |
| 271 | printf("ql_set_sms_slot failed %d\n",ret); |
| 272 | } |
| 273 | else |
| 274 | { |
| 275 | printf("ql_set_sms_slot success \n"); |
| 276 | } |
| 277 | } |
| 278 | break; |
| 279 | } |
b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame] | 280 | default: |
| 281 | break; |
| 282 | } |
| 283 | |
| 284 | } |
| 285 | |
| 286 | return 0; |
| 287 | |
| 288 | } |