b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1 | #include <stdlib.h>
|
| 2 | #include <stdio.h>
|
| 3 | #include <string.h>
|
| 4 | #include <stdint.h>
|
| 5 | #include <signal.h>
|
| 6 | #include <pthread.h>
|
| 7 | #include <stdbool.h>
|
| 8 | #include <dlfcn.h>
|
| 9 |
|
| 10 |
|
| 11 | static void *ecall_handle = NULL;
|
| 12 | typedef struct
|
| 13 | {
|
| 14 | int cmdIdx;
|
| 15 | char *funcName;
|
| 16 | }st_api_test_case;
|
| 17 |
|
| 18 | #define GSW_EU_ECALL_MAX_MSD 140
|
| 19 | #define GSW_EU_ECALL_MAX_PHONE_NUMBER 82
|
| 20 |
|
| 21 | typedef enum
|
| 22 | {
|
| 23 | GSW_EU_ECALL_TYPE_TEST = 1,
|
| 24 | GSW_EU_ECALL_TYPE_EMERGENCY = 2,
|
| 25 | GSW_EU_ECALL_TYPE_RECONFIG = 3,
|
| 26 | } gsw_eu_ecall_type_e;
|
| 27 |
|
| 28 | typedef struct
|
| 29 | {
|
| 30 | uint32_t msd_len;
|
| 31 | uint8_t msd[GSW_EU_ECALL_MAX_MSD];
|
| 32 | gsw_eu_ecall_type_e type;
|
| 33 | int32_t auto_trigger;
|
| 34 | char ecall_number[GSW_EU_ECALL_MAX_PHONE_NUMBER];
|
| 35 | } gsw_eu_ecall_info_t;
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 | typedef enum {
|
| 40 | GSW_EU_ECALL_STATE_NONE = -1,
|
| 41 | GSW_EU_ECALL_STATE_INACTIVE = 0,
|
| 42 | GSW_EU_ECALL_STATE_ORIGINATING_CALL = 1,
|
| 43 | GSW_EU_ECALL_STATE_IN_CALL_TRANSMITTING = 2,
|
| 44 | GSW_EU_ECALL_STATE_WAITING_FOR_AL_ACK = 3,
|
| 45 | GSW_EU_ECALL_STATE_IN_CALL = 4,
|
| 46 | GSW_EU_ECALL_STATE_IDLE_ALLOW_MT_ECALL = 5,
|
| 47 | } gsw_eu_ecall_state_e;
|
| 48 |
|
| 49 | typedef enum {
|
| 50 | GSW_EU_ECALL_MODE_NORMAL = 0,
|
| 51 | GSW_EU_ECALL_MODE_ONLY = 1,
|
| 52 | GSW_EU_ECALL_MODE_DEFAULT = 2,
|
| 53 | } gsw_eu_ecall_mode_e;
|
| 54 |
|
| 55 |
|
| 56 | typedef struct
|
| 57 | {
|
| 58 | uint8_t enable;
|
| 59 | uint8_t voice_mute;
|
| 60 | gsw_eu_ecall_mode_e mode;
|
| 61 | uint8_t report_event;
|
| 62 | uint16_t start_timer;
|
| 63 | uint16_t hack_timer;
|
| 64 | uint16_t trans_timer;
|
| 65 | uint8_t fail_redial;
|
| 66 | uint8_t drop_redial;
|
| 67 | uint16_t cleardown_timer;
|
| 68 | uint16_t init_timer;
|
| 69 | uint16_t nad_reg_timer;
|
| 70 | uint16_t nad_dereg_timer;
|
| 71 | uint8_t standard;
|
| 72 | uint16_t era_glonass_redial;
|
| 73 | uint16_t auto_answer; //auto_answer
|
| 74 | } gsw_eu_ecall_config_t;
|
| 75 |
|
| 76 | typedef enum {
|
| 77 | GSW_EU_ECALL_CONFIG_ENABLE = (1 << 0),
|
| 78 | GSW_EU_ECALL_CONFIG_VOICE_MUTE = (1 << 1),
|
| 79 | GSW_EU_ECALL_CONFIG_MODE = (1 << 2),
|
| 80 | GSW_EU_ECALL_CONFIG_REPORT_EVENT = (1 << 3),
|
| 81 | GSW_EU_ECALL_CONFIG_START_TIMER = (1 << 4),
|
| 82 | GSW_EU_ECALL_CONFIG_HACK_TIMER = (1 << 5),
|
| 83 | GSW_EU_ECALL_CONFIG_TRANS_TIMER = (1 << 6),
|
| 84 | GSW_EU_ECALL_CONFIG_FAIL_REDIAL = (1 << 7),
|
| 85 | GSW_EU_ECALL_CONFIG_DROP_REDIAL = (1 << 8),
|
| 86 | GSW_EU_ECALL_CONFIG_CLEARDOWN_TIMER = (1 << 9),
|
| 87 | GSW_EU_ECALL_CONFIG_INIT_TIMER = (1 << 10),
|
| 88 | GSW_EU_ECALL_CONFIG_NAD_REG_TIMER = (1 << 11),
|
| 89 | GSW_EU_ECALL_CONFIG_NAD_DEREG_TIMER = (1 << 12),
|
| 90 | GSW_EU_ECALL_CONFIG_STANDARD = (1 << 13),
|
| 91 | GSW_EU_ECALL_CONFIG_ERA_GLONASS_REDIAL = (1 << 14),
|
| 92 | GSW_EU_ECALL_CONFIG_AUTO_ANSWER = (1 << 15),
|
| 93 | } gsw_eu_ecall_config_e;
|
| 94 |
|
| 95 | typedef enum {
|
| 96 | GSW_EU_ECALL_EVENT_FAIL_NONE = 0,
|
| 97 | GSW_EU_ECALL_EVENT_FAIL_TIMEOUT = 1,
|
| 98 | GSW_EU_ECALL_EVENT_FAIL_HACK_TIMEOUT = 2,
|
| 99 | GSW_EU_ECALL_EVENT_FAIL_MSD_TRANS_TIMEOUT = 3,
|
| 100 | GSW_EU_ECALL_EVENT_FAIL_IVS_RESET_TIMEOUT = 4,
|
| 101 | GSW_EU_ECALL_EVENT_FAIL_CLEAR_DOWN_FALLBACK_TIMEOUT = 5,
|
| 102 | GSW_EU_ECALL_EVENT_FAIL_IVS_INITIATION_TIMEOUT = 6,
|
| 103 | } gsw_eu_ecall_event_fail_e;
|
| 104 |
|
| 105 | typedef enum {
|
| 106 | GSW_EU_ECALL_EVENT_PROCESS_IVS_NONE = 0,
|
| 107 | GSW_EU_ECALL_EVENT_PROCESS_IVS_START_RECEIVED_MSD = 1,
|
| 108 | GSW_EU_ECALL_EVENT_PROCESS_IVS_NACK_RECEIVED = 2,
|
| 109 | GSW_EU_ECALL_EVENT_PROCESS_IVS_ACK_RECEIVED = 3,
|
| 110 | GSW_EU_ECALL_EVENT_PROCESS_IVS_TX_COMPLETED = 4,
|
| 111 | GSW_EU_ECALL_EVENT_PROCESS_IVS_HLACK_RECEIVED = 5,
|
| 112 | } gsw_eu_ecall_event_process_e;
|
| 113 |
|
| 114 | typedef enum {
|
| 115 | GSW_EU_ECALL_EVENT_MSDUPADTE_NONE = -1,
|
| 116 | GSW_EU_ECALL_EVENT_MSDUPDATE_IVS_UPDATING_MSD = 0,
|
| 117 | GSW_EU_ECALL_EVENT_MSDUPDATE_PSAP_REQURE_UPDATE_MSD = 1,
|
| 118 | GSW_EU_ECALL_EVENT_MSDUPDATE_IVS_UPDATE_MSD_TIMEOUT = 2,
|
| 119 | } gsw_eu_ecall_event_msdupdate_e;
|
| 120 |
|
| 121 | typedef enum {
|
| 122 | GSW_EU_ECALL_EVENT_ESTABLISH_NONE = -1,
|
| 123 | GSW_EU_ECALL_EVENT_ESTABLISH_SUCCESS = 0,
|
| 124 | GSW_EU_ECALL_EVENT_ESTABLISH_FAIL = 1,
|
| 125 | } gsw_eu_ecall_event_establish_e;
|
| 126 |
|
| 127 | typedef enum {
|
| 128 | GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE = -1,
|
| 129 | GSW_EU_ECALL_EVENT_EXTEND_STATE_START_RECV_SYN = 0,
|
| 130 | GSW_EU_ECALL_EVENT_EXTEND_STATE_T9_TIMEOUT = 1,
|
| 131 | GSW_EU_ECALL_EVENT_EXTEND_STATE_T10_TIMEOUT = 2,
|
| 132 | GSW_EU_ECALL_EVENT_EXTEND_STATE_IVS_ALACK_RECEIVED = 3,
|
| 133 | GSW_EU_ECALL_EVENT_EXTEND_STATE_IVS_LLACK_RECEIVED = 4,
|
| 134 | GSW_EU_ECALL_EVENT_EXTEND_STATE_STOPPED = 5,
|
| 135 | GSW_EU_ECALL_EVENT_EXTEND_STATE_ANSWERING_INCOMING_PSAP_ECALL = 6,
|
| 136 | GSW_EU_ECALL_EVENT_EXTEND_STATE_CLEARDOWN_RECEIVED = 7,
|
| 137 | GSW_EU_ECALL_EVENT_EXTEND_STATE_CALLBACK_TIMEOUT = 8,
|
| 138 | GSW_EU_ECALL_EVENT_IVS_NORMAL_CLEARING = 9,
|
| 139 | GSW_EU_ECALL_EVENT_IVS_ABNORMAL_CLEARING = 10,
|
| 140 | } gsw_eu_ecall_event_extend_state_e;
|
| 141 |
|
| 142 | typedef struct
|
| 143 | {
|
| 144 | uint8_t ori_remainder_times;
|
| 145 | uint16_t time;
|
| 146 | } gsw_eu_ecall_event_originate_fail_redial_t;
|
| 147 |
|
| 148 | typedef struct
|
| 149 | {
|
| 150 | uint8_t drop_remainder_times;
|
| 151 | uint16_t time; /* The minimum time duration between the previous call attempt */
|
| 152 | } gsw_eu_ecall_event_drop_redial_t;
|
| 153 |
|
| 154 |
|
| 155 | typedef struct
|
| 156 | {
|
| 157 | gsw_eu_ecall_event_fail_e fail;
|
| 158 | gsw_eu_ecall_event_process_e process;
|
| 159 | gsw_eu_ecall_event_msdupdate_e msdupdate;
|
| 160 | gsw_eu_ecall_event_establish_e establish;
|
| 161 | uint16_t hack_code;
|
| 162 | gsw_eu_ecall_event_originate_fail_redial_t ori_redial;
|
| 163 | gsw_eu_ecall_event_drop_redial_t drop_redial;
|
| 164 | gsw_eu_ecall_event_extend_state_e extend_state;
|
| 165 | } gsw_eu_ecall_event_t;
|
| 166 |
|
| 167 | typedef void (*gsw_eu_ecall_event_cb_f)(gsw_eu_ecall_event_t *p_event);
|
| 168 |
|
| 169 |
|
| 170 | typedef enum {
|
| 171 | GSW_EU_ECALL_MSD_TRANS_STATUS_NONE = -1,
|
| 172 | GSW_EU_ECALL_MSD_TRANS_STATUS_SUCCESS = 0,
|
| 173 | GSW_EU_ECALL_MSD_TRANS_STATUS_FAILURE = 1,
|
| 174 | } gsw_eu_ecall_msd_trans_status_e;
|
| 175 |
|
| 176 | typedef void (*gsw_eu_ecall_status_cb_f)(uint32_t id, gsw_eu_ecall_msd_trans_status_e status);
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 | typedef int32_t (*gsw_eu_ecall_voice_init)(void);
|
| 181 |
|
| 182 |
|
| 183 | typedef int32_t (*gsw_eu_ecall_voice_deinit)(void);
|
| 184 | typedef int32_t (*gsw_eu_ecall_start)(gsw_eu_ecall_info_t *p_info);
|
| 185 | typedef int32_t (*gsw_eu_ecall_hangup)(void);
|
| 186 | typedef int32_t (*gsw_eu_ecall_updateMsd)(const uint8_t *msd, uint32_t msd_len);
|
| 187 | typedef int32_t (*gsw_eu_ecall_pushMsd)(gsw_eu_ecall_state_e state);
|
| 188 | typedef int32_t (*gsw_eu_ecall_getConfig)(gsw_eu_ecall_config_t *p_config);
|
| 189 | typedef int32_t (*gsw_eu_ecall_setConfig)(int32_t item, gsw_eu_ecall_config_t *p_config);
|
| 190 | typedef int32_t (*gsw_eu_ecall_setEventCB)(gsw_eu_ecall_event_cb_f cb);
|
| 191 | typedef int32_t (*gsw_eu_ecall_setStatusCB)(gsw_eu_ecall_status_cb_f cb);
|
| 192 |
|
| 193 | st_api_test_case api_testcases[] =
|
| 194 | {
|
| 195 | {0, "print_help"},
|
| 196 | {1, "gsw_eu_ecall_voice_init"},
|
| 197 | {2, "gsw_eu_ecall_voice_deinit"},
|
| 198 | {3, "gsw_eu_ecall_start"},
|
| 199 | {4, "gsw_eu_ecall_hangup"},
|
| 200 | {5, "gsw_eu_ecall_updateMsd"},
|
| 201 | {6, "gsw_eu_ecall_pushMsd"},
|
| 202 | {7, "gsw_eu_ecall_getConfig"},
|
| 203 | {8, "gsw_eu_ecall_setConfig"},
|
| 204 | {9, "gsw_eu_ecall_setEventCB"},
|
| 205 | {10, "gsw_eu_ecall_setStatusCB"},
|
| 206 | {-1, NULL}
|
| 207 |
|
| 208 | };
|
| 209 | void sigint_handler(int sig)
|
| 210 | {
|
| 211 | printf("sigint_handler\n");
|
| 212 | dlclose(ecall_handle);
|
| 213 | ecall_handle = NULL;
|
| 214 |
|
| 215 | exit(0);
|
| 216 | }
|
| 217 | static void gsw_eu_ecall_status_cb(uint32_t id, gsw_eu_ecall_msd_trans_status_e status)
|
| 218 | {
|
| 219 | printf("id is %u\n",id);
|
| 220 | printf("status is %d\n",status);
|
| 221 |
|
| 222 | }
|
| 223 |
|
| 224 |
|
| 225 | static void gsw_eu_ecall_event_cb(gsw_eu_ecall_event_t *p_event)
|
| 226 | {
|
| 227 | printf("p_event->fail: %ud\n",p_event->fail);
|
| 228 | printf("p_event->process: %d\n",p_event->process);
|
| 229 | printf("p_event->msdupdate: %d\n",p_event->msdupdate);
|
| 230 | printf("p_event->establish: %d\n",p_event->establish);
|
| 231 | printf("p_event->hack_code: %d\n",p_event->hack_code);
|
| 232 | printf("p_event->ori_redial.ori_remainder_times: %d\n",p_event->ori_redial.ori_remainder_times);
|
| 233 | printf("p_event->ori_redial.time: %d\n",p_event->ori_redial.time);
|
| 234 | printf("p_event->drop_redial.drop_remainder_times: %d\n",p_event->drop_redial.drop_remainder_times);
|
| 235 | printf("p_event->drop_redial.time: %d\n",p_event->drop_redial.time);
|
| 236 | printf("p_event->extend_state: %d\n",p_event->extend_state);
|
| 237 |
|
| 238 | }
|
| 239 |
|
| 240 |
|
| 241 | static void set_config(gsw_eu_ecall_config_t *p_config)
|
| 242 | {
|
| 243 |
|
| 244 | int ret = -1;
|
| 245 | p_config->enable = 0;
|
| 246 | p_config->voice_mute = 0;
|
| 247 | p_config->mode = 0;
|
| 248 | p_config->report_event = 0;
|
| 249 | p_config->start_timer = 0;
|
| 250 | p_config->hack_timer = 0;
|
| 251 | p_config->trans_timer = 0;
|
| 252 | p_config->cleardown_timer = 0;
|
| 253 | p_config->drop_redial = 0;
|
| 254 | p_config->init_timer = 0;
|
| 255 | p_config->nad_reg_timer = 0;
|
| 256 | p_config->nad_dereg_timer = 0;
|
| 257 | p_config->standard = 0;
|
| 258 | p_config->era_glonass_redial = 0;
|
| 259 | p_config->auto_answer = 0;
|
| 260 |
|
| 261 | printf("input p_config->fail_redial\n");
|
| 262 | ret = scanf("%hhu", &p_config->fail_redial);
|
| 263 | if(ret)
|
| 264 | {
|
| 265 | printf("input ret is %d\n",ret);
|
| 266 | }
|
| 267 |
|
| 268 |
|
| 269 | }
|
| 270 |
|
| 271 | static void print_get_config(gsw_eu_ecall_config_t p_config)
|
| 272 | {
|
| 273 |
|
| 274 | printf("input p_config.enable: %d\n",p_config.enable);
|
| 275 | printf("input p_config.voice_mute:%d\n",p_config.voice_mute);
|
| 276 | printf("input p_config.mode:%d\n",p_config.mode);
|
| 277 | printf("input p_config.report_event:%d\n",p_config.report_event);
|
| 278 | printf("input p_config.start_timer:%d\n",p_config.start_timer);
|
| 279 | printf("input p_config.hack_timer:%d\n",p_config.hack_timer);
|
| 280 | printf("input p_config.trans_timer:%d\n",p_config.start_timer);
|
| 281 | printf("input p_config.fail_redial:%d\n",p_config.fail_redial);
|
| 282 | printf("input p_config.drop_redial:%d\n",p_config.drop_redial);
|
| 283 | printf("input p_config.cleardown_timer:%d\n",p_config.cleardown_timer);
|
| 284 | printf("input p_config.init_timer:%d\n",p_config.init_timer);
|
| 285 | printf("input p_config.nad_reg_timer:%d\n",p_config.nad_reg_timer);
|
| 286 | printf("input p_config.nad_dereg_timer:%d\n",p_config.nad_dereg_timer);
|
| 287 | printf("input p_config.standard:%d\n",p_config.standard);
|
| 288 | printf("input p_config.era_glonass_redial:%d\n",p_config.era_glonass_redial);
|
| 289 | printf("input p_config.auto_answer:%d\n",p_config.auto_answer);
|
| 290 |
|
| 291 |
|
| 292 | }
|
| 293 | void print_help(void)
|
| 294 | {
|
| 295 | int i;
|
| 296 |
|
| 297 | printf("Supported test cases:\n");
|
| 298 | for(i = 0; ; i++)
|
| 299 | {
|
| 300 | if(api_testcases[i].cmdIdx == -1)
|
| 301 | {
|
| 302 | break;
|
| 303 | }
|
| 304 | printf("%d:\t%s\n", api_testcases[i].cmdIdx, api_testcases[i].funcName);
|
| 305 | }
|
| 306 | }
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 | //static ecall_init_flag = 0;
|
| 311 | int main(int argc,char *argv[])
|
| 312 | {
|
| 313 | gsw_eu_ecall_voice_init gsw_eu_ecall_voice_init_ptr = NULL;
|
| 314 | gsw_eu_ecall_voice_deinit gsw_eu_ecall_voice_deinit_ptr = NULL;
|
| 315 | gsw_eu_ecall_start gsw_eu_ecall_start_ptr = NULL;
|
| 316 | gsw_eu_ecall_hangup gsw_eu_ecall_hangup_ptr = NULL;
|
| 317 | gsw_eu_ecall_updateMsd gsw_eu_ecall_updateMsd_ptr = NULL;
|
| 318 | gsw_eu_ecall_pushMsd gsw_eu_ecall_pushMsd_ptr = NULL;
|
| 319 | gsw_eu_ecall_getConfig gsw_eu_ecall_getConfig_ptr = NULL;
|
| 320 | gsw_eu_ecall_setConfig gsw_eu_ecall_setConfig_ptr = NULL;
|
| 321 | gsw_eu_ecall_setEventCB gsw_eu_ecall_setEventCB_ptr = NULL;
|
| 322 | gsw_eu_ecall_setStatusCB gsw_eu_ecall_setStatusCB_ptr = NULL;
|
| 323 |
|
| 324 | void *ota_handle = dlopen("/lib/libgsw_lib.so", RTLD_NOW );
|
| 325 | if(ota_handle == NULL)
|
| 326 | {
|
| 327 | printf("open lib failed\n");
|
| 328 | return -1;
|
| 329 | }
|
| 330 |
|
| 331 |
|
| 332 | signal(SIGINT, sigint_handler);
|
| 333 |
|
| 334 | ecall_handle = dlopen("/lib/libgsw_lib.so", RTLD_NOW );
|
| 335 | if(ecall_handle == NULL)
|
| 336 | {
|
| 337 | printf("open lib failed\n");
|
| 338 | return -1;
|
| 339 | }
|
| 340 | gsw_eu_ecall_voice_init_ptr = (gsw_eu_ecall_voice_init)dlsym(ecall_handle, "gsw_eu_ecall_voice_init");
|
| 341 | if(gsw_eu_ecall_voice_init_ptr == NULL)
|
| 342 | {
|
| 343 | printf("dlsym gsw_eu_ecall_voice_init failed\n");
|
| 344 | return -1;
|
| 345 | }
|
| 346 | gsw_eu_ecall_voice_deinit_ptr = (gsw_eu_ecall_voice_deinit)dlsym(ecall_handle, "gsw_eu_ecall_voice_deinit");
|
| 347 | if(gsw_eu_ecall_voice_deinit_ptr == NULL)
|
| 348 | {
|
| 349 | printf("dlsym gsw_eu_ecall_voice_deinit failed\n");
|
| 350 | return -1;
|
| 351 | }
|
| 352 | gsw_eu_ecall_start_ptr = (gsw_eu_ecall_start)dlsym(ecall_handle, "gsw_eu_ecall_start");
|
| 353 | if(gsw_eu_ecall_start_ptr == NULL)
|
| 354 | {
|
| 355 | printf("dlsym gsw_eu_ecall_start failed\n");
|
| 356 | return -1;
|
| 357 | }
|
| 358 | gsw_eu_ecall_hangup_ptr = (gsw_eu_ecall_hangup)dlsym(ecall_handle, "gsw_eu_ecall_hangup");
|
| 359 | if(gsw_eu_ecall_hangup_ptr == NULL)
|
| 360 | {
|
| 361 | printf("dlsym gsw_eu_ecall_hangup failed\n");
|
| 362 | return -1;
|
| 363 | }
|
| 364 | gsw_eu_ecall_updateMsd_ptr = (gsw_eu_ecall_updateMsd)dlsym(ecall_handle, "gsw_eu_ecall_updateMsd");
|
| 365 | if(gsw_eu_ecall_updateMsd_ptr == NULL)
|
| 366 | {
|
| 367 | printf("dlsym gsw_eu_ecall_updateMsd failed\n");
|
| 368 | return -1;
|
| 369 | }
|
| 370 | gsw_eu_ecall_pushMsd_ptr = (gsw_eu_ecall_pushMsd)dlsym(ecall_handle, "gsw_eu_ecall_pushMsd");
|
| 371 | if(gsw_eu_ecall_pushMsd_ptr == NULL)
|
| 372 | {
|
| 373 | printf("dlsym gsw_eu_ecall_pushMsd failed\n");
|
| 374 | return -1;
|
| 375 | }
|
| 376 | gsw_eu_ecall_getConfig_ptr = (gsw_eu_ecall_getConfig)dlsym(ecall_handle, "gsw_eu_ecall_getConfig");
|
| 377 | if(gsw_eu_ecall_getConfig_ptr == NULL)
|
| 378 | {
|
| 379 | printf("dlsym gsw_eu_ecall_getConfig failed\n");
|
| 380 | return -1;
|
| 381 | }
|
| 382 | gsw_eu_ecall_setConfig_ptr = (gsw_eu_ecall_setConfig)dlsym(ecall_handle, "gsw_eu_ecall_setConfig");
|
| 383 | if(gsw_eu_ecall_setConfig_ptr == NULL)
|
| 384 | {
|
| 385 | printf("dlsym gsw_eu_ecall_setConfig failed\n");
|
| 386 | return -1;
|
| 387 | }
|
| 388 | gsw_eu_ecall_setEventCB_ptr = (gsw_eu_ecall_setEventCB)dlsym(ecall_handle, "gsw_eu_ecall_setEventCB");
|
| 389 | if(gsw_eu_ecall_setEventCB_ptr == NULL)
|
| 390 | {
|
| 391 | printf("dlsym gsw_eu_ecall_setEventCB failed\n");
|
| 392 | return -1;
|
| 393 | }
|
| 394 | gsw_eu_ecall_setStatusCB_ptr = (gsw_eu_ecall_setStatusCB)dlsym(ecall_handle, "gsw_eu_ecall_setStatusCB");
|
| 395 | if(gsw_eu_ecall_setStatusCB_ptr == NULL)
|
| 396 | {
|
| 397 | printf("dlsym gsw_eu_ecall_setStatusCB failed\n");
|
| 398 | return -1;
|
| 399 | }
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 | printf("Enter ecall api test \n");
|
| 404 | int opt = -1;
|
| 405 |
|
| 406 | while (1)
|
| 407 | {
|
| 408 |
|
| 409 | print_help();
|
| 410 | int ret = scanf("%d",&opt);
|
| 411 | if (ret == 1)
|
| 412 | {
|
| 413 | printf("输入的整数是:%d\n", opt);
|
| 414 | }
|
| 415 |
|
| 416 | switch(opt)
|
| 417 | {
|
| 418 | case 0 :
|
| 419 | {
|
| 420 | print_help();
|
| 421 | break;
|
| 422 | }
|
| 423 | case 1 :
|
| 424 | {
|
| 425 | int32_t ret = -1;
|
| 426 | printf("enter gsw_eu_ecall_voice_init");
|
| 427 | ret = gsw_eu_ecall_voice_init_ptr();
|
| 428 | printf("gsw_eu_ecall_voice_init ret = %d\n", ret);
|
| 429 |
|
| 430 |
|
| 431 | break;
|
| 432 | }
|
| 433 | case 2 :
|
| 434 | {
|
| 435 | int32_t ret = -1;
|
| 436 | printf("enter gsw_eu_ecall_voice_deinit\n");
|
| 437 | ret = gsw_eu_ecall_voice_deinit_ptr();
|
| 438 | printf("gsw_eu_ecall_voice_deinit ret = %d\n", ret);
|
| 439 | break;
|
| 440 | }
|
| 441 | case 3 :
|
| 442 | {
|
| 443 | printf("enter gsw_eu_ecall_start\n");
|
| 444 | gsw_eu_ecall_info_t info;
|
| 445 | memset(&info,0,sizeof(info));
|
| 446 |
|
| 447 | int type;
|
| 448 | printf("Enter MSD data (hex values, space-separated): ");
|
| 449 |
|
| 450 | ret = scanf("%140s",info.msd);
|
| 451 | if(ret)
|
| 452 | {
|
| 453 | printf("input ret is %d\n",ret);
|
| 454 | }
|
| 455 | info.msd_len = (uint32_t)strlen((char*)info.msd);
|
| 456 |
|
| 457 |
|
| 458 | printf("Enter eCall type (1: Test, 2: Emergency, 3: Reconfig):\n ");
|
| 459 | ret = scanf("%d", &type);
|
| 460 | if(ret)
|
| 461 | {
|
| 462 | printf("input ret is %d\n",ret);
|
| 463 | }
|
| 464 | info.type = (gsw_eu_ecall_type_e)type;
|
| 465 |
|
| 466 | printf("Enter auto trigger (0: No, 1: Yes): \n");
|
| 467 | ret=scanf("%d", &info.auto_trigger);
|
| 468 | if(ret)
|
| 469 | {
|
| 470 | printf("input ret is %d\n",ret);
|
| 471 | }
|
| 472 |
|
| 473 | if(type == 1 || type == 3)
|
| 474 | {
|
| 475 | // 输入 eCall 号码
|
| 476 | printf("Enter eCall number: \n");
|
| 477 | ret = scanf("%82s", info.ecall_number);
|
| 478 | if(ret)
|
| 479 | {
|
| 480 | printf("input ret is %d\n",ret);
|
| 481 | }
|
| 482 | }
|
| 483 | ret = gsw_eu_ecall_start_ptr(&info);
|
| 484 | printf("gsw_eu_ecall_start ret = %d\n", ret);
|
| 485 | break;
|
| 486 | }
|
| 487 | case 4 :
|
| 488 | {
|
| 489 | int32_t ret = -1;
|
| 490 | printf("enter gsw_eu_ecall_hangup\n");
|
| 491 | ret = gsw_eu_ecall_hangup_ptr();
|
| 492 | printf("gsw_eu_ecall_hangup ret = %d\n", ret);
|
| 493 | break;
|
| 494 | }
|
| 495 | case 5 :
|
| 496 | {
|
| 497 | uint8_t msd[100] = "235646023026565";
|
| 498 | int32_t ret = -1;
|
| 499 | printf("enter gsw_eu_ecall_updateMsd\n");
|
| 500 | ret = gsw_eu_ecall_updateMsd_ptr(msd, 100);
|
| 501 | printf("gsw_eu_ecall_updateMsd ret = %d\n", ret);
|
| 502 | break;
|
| 503 | }
|
| 504 | case 6 :
|
| 505 | {
|
| 506 | printf("enter gsw_eu_ecall_pushMsd\n");
|
| 507 | gsw_eu_ecall_state_e state = -1;
|
| 508 | int32_t ret = -1;
|
| 509 | ret = gsw_eu_ecall_pushMsd_ptr(state);
|
| 510 | printf("gsw_eu_ecall_pushMsd ret = %d\n", ret);
|
| 511 | break;
|
| 512 | }
|
| 513 | case 7 :
|
| 514 | {
|
| 515 | printf("enter gsw_eu_ecall_getConfig\n");
|
| 516 | gsw_eu_ecall_config_t config;
|
| 517 | int32_t ret = -1;
|
| 518 | memset(&config,0,sizeof(config));
|
| 519 | ret = gsw_eu_ecall_getConfig_ptr(&config);
|
| 520 | printf("gsw_eu_ecall_getConfig ret = %d\n", ret);
|
| 521 | print_get_config(config);
|
| 522 | break;
|
| 523 | }
|
| 524 | case 8 :
|
| 525 | {
|
| 526 | printf("enter gsw_eu_ecall_setConfig\n");
|
| 527 | gsw_eu_ecall_config_t config;
|
| 528 | //config.ori_timeout = 10;
|
| 529 | int32_t ret = -1;
|
| 530 | int32_t item = 128;
|
| 531 | printf("item value %d\n",item);
|
| 532 | set_config(&config);
|
| 533 | ret = gsw_eu_ecall_setConfig_ptr(item, &config);
|
| 534 | printf("gsw_eu_ecall_setConfig ret = %d\n", ret);
|
| 535 | break;
|
| 536 | }
|
| 537 | case 9 :
|
| 538 | {
|
| 539 | printf("enter gsw_eu_ecall_setEventCB\n");
|
| 540 | //gsw_eu_ecall_event_cb_f cb = NULL;
|
| 541 | int32_t ret = -1;
|
| 542 | ret = gsw_eu_ecall_setEventCB_ptr(gsw_eu_ecall_event_cb);
|
| 543 | printf("gsw_eu_ecall_setEventCB ret = %d\n", ret);
|
| 544 | break;
|
| 545 | }
|
| 546 | case 10 :
|
| 547 | {
|
| 548 | printf("""enter gsw_eu_ecall_setStatusCB\n");
|
| 549 | int32_t ret = -1;
|
| 550 | ret = gsw_eu_ecall_setStatusCB_ptr(gsw_eu_ecall_status_cb);
|
| 551 | printf("gsw_eu_ecall_setStatusCB ret = %d\n", ret);
|
| 552 | break;
|
| 553 |
|
| 554 | }
|
| 555 | default:
|
| 556 | {
|
| 557 | printf("default");
|
| 558 | print_help();
|
| 559 | break;
|
| 560 | }
|
| 561 | }
|
| 562 | }
|
| 563 |
|
| 564 | return 0;
|
| 565 | }
|
| 566 |
|