blob: b25bbb0b176b335edbccd7fe8ff17f008924a2bf [file] [log] [blame]
b.liu68a94c92025-05-24 12:53:41 +08001#include <stdlib.h>
2#include <stdio.h>
3#include <string.h>
4#include <sys/stat.h>
5#include <sys/types.h>
6#include <unistd.h>
7#include <dlfcn.h>
8#include <stdint.h>
9
10#include <errno.h>
11#include <stdbool.h>
12#include <pthread.h>
13
l.yang2678d6f2025-05-28 03:58:49 -070014#include "gsw_eu_ecall_interface.h"
q.huang6e4f4732025-07-22 18:46:32 +080015#include "gsw_log_interface.h"
16
b.liu68a94c92025-05-24 12:53:41 +080017
18#define RIL_MAX_NUMBER_LEN 40
19#define MBTK_ECALL_MSD_LEN_MAX 600
20
l.yang6a42e4d2025-05-28 01:04:20 -070021#define GSW_ECALL "[HAL][GSW_ECALL]"
22
b.liu68a94c92025-05-24 12:53:41 +080023typedef unsigned int uint32;
24typedef unsigned char uint8;
25typedef unsigned short uint16;
26
27typedef enum {
28 MBTK_ECALL_URC_ID_ALACK = 0, // AL-ACK signal received (refer to : urc_data)
29 MBTK_ECALL_URC_ID_SYNC_LOST, // eIM lost synchronization with PSAP
30 // (A resynch occurs after the synchronization is lost.)
31 MBTK_ECALL_URC_ID_NACK, // NACK signal received
32 MBTK_ECALL_URC_ID_RESERVED_3,
33 MBTK_ECALL_URC_ID_RESERVED_4,
34 MBTK_ECALL_URC_ID_RESERVED_5, // 5
35 MBTK_ECALL_URC_ID_3GPP_FATAL, // eIM is terminated: fatal error (3GPP Abort function)
36 MBTK_ECALL_URC_ID_CALL_DROP, // eIM is terminated: call drop
37 MBTK_ECALL_URC_ID_GENERIC, // Generic error
38 MBTK_ECALL_URC_ID_MSD_REQ, // PSAP request MSD (Only for PULL modem)
39 MBTK_ECALL_URC_ID_MSD_SEND_START, // 10 : eIM starts sending MSD
40 MBTK_ECALL_URC_ID_INITIATION, // The eIM starts sending the Initiation signal (Only for PUSH modem).
41 // It also indicates that the call setup is completed.
42 MBTK_ECALL_URC_ID_SEND_MSD, // PUSH: SEND_MSD -> MSD_SEND_START
43 // PULL: SEND_MSD -> MSD_REQ -> MSD_SEND_START
44 MBTK_ECALL_URC_ID_SEND_MSD_FULL,// SEND MSD signal received too often, PSAP sync failure assumed
45 MBTK_ECALL_URC_ID_SYNCED_PSAP, // IVS eIM is synced with PSAP
46 MBTK_ECALL_URC_ID_SYNCED_PSAP_EIM, // 15: IVS eIM is synced with PSAP eIM
47 MBTK_ECALL_URC_ID_LLACK, // Link layer ACK received
48 MBTK_ECALL_URC_ID_HLACK, // Higher Layer ACK received (similar to AL-ACK (#0) but without data)
49 MBTK_ECALL_URC_ID_EIM_RESET, // The eIM transmitter idles after a full reset. The eIM transmitter is reset after sync loss
50 // (for example, because of the end of PSAP transmission).
51 MBTK_ECALL_URC_ID_EIM_IDLES, // The eIM transmitter idles after the transmission of the Initiation signal (push mode)
52 MBTK_ECALL_URC_ID_MSD_UPDATE, // 20 : MSD update request is received.
53 MBTK_ECALL_URC_ID_MSD_UPDATE_DONE, // MSD update is done.
54 MBTK_ECALL_URC_ID_MSD_UPDATE_ERR, // MSD update request cannot be processed.
55 MBTK_ECALL_URC_ID_T3_EXPIRED, // T3 expired
56 MBTK_ECALL_URC_ID_T5_EXPIRED, // T5 expired
57 MBTK_ECALL_URC_ID_T6_EXPIRED, // 25 : T6 expired
58 MBTK_ECALL_URC_ID_T7_EXPIRED, // T7 expired
59 MBTK_ECALL_URC_ID_TH_EXPIRED, // TH expired
60 MBTK_ECALL_URC_ID_RESERVED_28,
61 MBTK_ECALL_URC_ID_RESERVED_29,
62 MBTK_ECALL_URC_ID_RESERVED_30, // 30
63 MBTK_ECALL_URC_ID_IVS_EVENT_TIMEOUT,
64 MBTK_ECALL_URC_ID_PSAP_REQ, // Only for ERA
65 MBTK_ECALL_URC_ID_MSD_SEND_FAIL_FOR_NG // NG-eCall fail to transfer MSD
66} mbtk_ecall_urc_id_enum;
67
68typedef enum {
69 MBTK_CLCC = 1,
70 MBTK_CPAS,
71 MBTK_DISCONNECTED,
72} mbtk_call_enum;
73
74typedef enum {
75 MBTK_CALL_RADY, //MT allows commands from TA/TE
76 MBTK_CALL_UNAVAILABLE, //MT does not allow commands from TA/TE
77 MBTK_CALL_UNKNOWN, //MT is not guaranteed to respond to instructions
78 MBTK_CALL_RINGING, //MT is ready for commands from TA/TE, but the ringer is active
79 MBTK_CALL_PROGRESS, //MT is ready for commands from TA/TE, but a call is in progress
80 MBTK_CALL_ASLEEP, //MT is unable to process commands from TA/TE because it is in a low functionality state
81 MBTK_CALL_ACTIVE,
82} mbtk_call_pas_enum;
83
84#define MBTK_ECALL_CFG_T3 (1 << MBTK_ECALL_CFG_ITEM_T3) // ms
85#define MBTK_ECALL_CFG_T5 (1 << MBTK_ECALL_CFG_ITEM_T5) // ms
86#define MBTK_ECALL_CFG_T6 (1 << MBTK_ECALL_CFG_ITEM_T6) // ms
87#define MBTK_ECALL_CFG_T7 (1 << MBTK_ECALL_CFG_ITEM_T7) // ms
88#define MBTK_ECALL_CFG_TH (1 << MBTK_ECALL_CFG_ITEM_TH) // ms
89#define MBTK_ECALL_CFG_TIMER_CALLBACK (1 << MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK) // T9
90#define MBTK_ECALL_CFG_TIMER_CLEARDOWN (1 << MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN) // T2
91#define MBTK_ECALL_CFG_TIMER_DEREG (1 << MBTK_ECALL_CFG_ITEM_TIMER_DEREG) // T10
92#define MBTK_ECALL_CFG_TIMER_DIAL (1 << MBTK_ECALL_CFG_ITEM_TIMER_DIAL) // "dial"
93#define MBTK_ECALL_CFG_TIMER_REDIAL (1 << MBTK_ECALL_CFG_ITEM_TIMER_REDIAL) // "redialtmr"
94#define MBTK_ECALL_CFG_TIMER_SMS (1 << MBTK_ECALL_CFG_ITEM_TIMER_SMS) // "sms" // 10
95#define MBTK_ECALL_CFG_REDIALCNT (1 << MBTK_ECALL_CFG_ITEM_REDIALCNT) // "redialcnt"
96#define MBTK_ECALL_CFG_SMSPROCESS (1 << MBTK_ECALL_CFG_ITEM_SMSPROCESS) // "smsprocess"
97#define MBTK_ECALL_CFG_SMSMSDCNT (1 << MBTK_ECALL_CFG_ITEM_SMSMSDCNT) // "smsmsdcnt"
98
99
100typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
101
102typedef struct
103{
104 int client_fd;
105 pthread_t read_thread_id;
106 int exit_fd[2];
107 bool is_waitting;
108 pthread_cond_t cond;
109 pthread_mutex_t mutex;
110
111 pthread_mutex_t send_mutex;
112
113 // Temp response data.
114 uint16 info_err;
115 uint16 data_len;
116 void *data;
117
118 //mbtk wyq for server_ready_status add start
119 char server_ready_status;
120 //mbtk wyq for server_ready_status add end
121
122 mbtk_info_callback_func net_state_cb;
123 mbtk_info_callback_func call_state_cb;
124 mbtk_info_callback_func sms_state_cb;
125 mbtk_info_callback_func radio_state_cb;
126 mbtk_info_callback_func sim_state_cb;
127 mbtk_info_callback_func pdp_state_cb;
128 //add signal by xr
129 mbtk_info_callback_func signal_state_cb;
130} mbtk_info_handle_t;
131
132typedef enum {
133 MBTK_ECALL_CFG_ITEM_T3 = 0, // ms
134 MBTK_ECALL_CFG_ITEM_T5, // ms
135 MBTK_ECALL_CFG_ITEM_T6, // ms
136 MBTK_ECALL_CFG_ITEM_T7, // ms
137 MBTK_ECALL_CFG_ITEM_TH, // ms
138 MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK, // T9 // 5
139 MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN, // T2
140 MBTK_ECALL_CFG_ITEM_TIMER_DEREG, // T10
141 MBTK_ECALL_CFG_ITEM_TIMER_DIAL, // "dial"
142 MBTK_ECALL_CFG_ITEM_TIMER_REDIAL, // "redialtmr"
143 MBTK_ECALL_CFG_ITEM_TIMER_SMS, // "sms" // 10
144 MBTK_ECALL_CFG_ITEM_REDIALCNT, // "redialcnt"
145 MBTK_ECALL_CFG_ITEM_SMSPROCESS, // "smsprocess"
146 MBTK_ECALL_CFG_ITEM_SMSMSDCNT, // "smsmsdcnt"
147
148 MBTK_ECALL_CFG_ITEM_MAX
149} mbtk_ecall_cfg_item_enum;
150
151
152typedef enum {
153 MBTK_ECALL_MSD_ITEM_VERSION = 0,
154 MBTK_ECALL_MSD_ITEM_MSG_ID,
155 MBTK_ECALL_MSD_ITEM_CONTROLTYPE,
156 MBTK_ECALL_MSD_ITEM_VIN,
157 MBTK_ECALL_MSD_ITEM_STORAGETYPE,
158 MBTK_ECALL_MSD_ITEM_TIMESTAMP,
159 MBTK_ECALL_MSD_ITEM_LOCATION,
160 MBTK_ECALL_MSD_ITEM_DIRECTION,
161 MBTK_ECALL_MSD_ITEM_LOCATIONN1,
162 MBTK_ECALL_MSD_ITEM_LOCATIONN2,
163 MBTK_ECALL_MSD_ITEM_NUMBEROFOCCUPANTS,
164 MBTK_ECALL_MSD_ITEM_ADDITIONALDATA,
165 MBTK_ECALL_MSD_ITEM_ALL_IN_ONE,
166 MBTK_ECALL_MSD_ITEM_ASI,
167 MBTK_ECALL_MSD_ITEM_VEHICLE_DIAGNOSTIC,
168 MBTK_ECALL_MSD_ITEM_CRASH_INFO,
169 MBTK_ECALL_MSD_ITEM_GNSS_TYPE
170} mbtk_ecall_msd_item_enum;
171
172typedef enum {
173 MBTK_ECALL_ONLY_TYPE_DISABLE = 0,
174 MBTK_ECALL_ONLY_TYPE_ENABLE_ECALL,
175 MBTK_ECALL_ONLY_TYPE_ENABLE_NG_ECALL,
176 MBTK_ECALL_ONLY_TYPE_ENABLE_ALL,
177 MBTK_ECALL_ONLY_TYPE_CONF_NUM,
178 MBTK_ECALL_ONLY_TYPE_NORMAL
179} mbtk_ecall_only_type_enum;
180
181typedef struct
182{
183 mbtk_ecall_msd_item_enum item_type;
184
185 uint8 data[64];
186} mbtk_ecall_msd_cfg_info_t;
187
188typedef enum {
189 MBTK_ECALL_SIM_TYPE_NO_SUPPORT = 0,
190 MBTK_ECALL_SIM_TYPE_SUPPORT_ECALL,
191 MBTK_ECALL_SIM_TYPE_SUPPORT_ECALL_ONLY
192} mbtk_ecall_sim_type_enum;
193
194
195typedef struct {
196 mbtk_ecall_only_type_enum active : 8;
197 mbtk_ecall_sim_type_enum sim_type : 8; // Only for GET.
198 uint8 test_num[RIL_MAX_NUMBER_LEN];
199 uint8 reconfig_num[RIL_MAX_NUMBER_LEN];
200} mbtk_ecall_only_info_t;
201
202typedef enum {
203 MBTK_ECALL_MODE_TYPE_EU = 0,
204 MBTK_ECALL_MODE_TYPE_ERA
205} mbtk_ecall_mode_type_enum;
206
207
208typedef enum {
209 MBTK_ECALL_DIAL_TYPE_TEST = 0,
210 MBTK_ECALL_DIAL_TYPE_RECONFIG,
211 MBTK_ECALL_DIAL_TYPE_MANUALLY,
212 MBTK_ECALL_DIAL_TYPE_AUTO,
213 MBTK_ECALL_DIAL_TYPE_NOT_ACTIVATED,
214 MBTK_ECALL_DIAL_TYPE_RELEASE
215} mbtk_ecall_dial_type_enum;
216
217typedef struct {
218 uint32 type; // mbtk_ecall_cfg_item_enum
219
220#if 0
221 uint32 timer_t3; // ms
222 uint32 timer_t5; // ms
223 uint32 timer_t6; // ms
224 uint32 timer_t7; // ms
225 uint32 timer_th; // ms
226
227 uint32 timer_callback; // s (T9)
228 uint32 timer_cleardown; // s (T2)
229 uint32 timer_dereg; // s (T10)
230 uint32 timer_dial; // s
231 uint32 timer_redialtmr; // s
232 uint32 timer_sms; // s
233
234 uint32 redialcnt;
235 uint32 smsprocess;
236 uint32 smsmsdcnt;
237#else
238 uint8 data_valid[MBTK_ECALL_CFG_ITEM_MAX];
239 uint32 data[MBTK_ECALL_CFG_ITEM_MAX];
240#endif
241} mbtk_ecall_cfg_info_t;
242
243
244typedef struct
245{
246 uint8 urc_id;
247 uint8 urc_data[5];
248} mbtk_ril_ecall_state_info_t;
249
250
251typedef mbtk_info_handle_t* (*mbtk_info_handle_get)(void);
252static mbtk_info_handle_get mbtk_info_handle_get_ptr = NULL;
253
254typedef int (*mbtk_info_handle_free)(mbtk_info_handle_t** handle);
255static mbtk_info_handle_free mbtk_info_handle_free_ptr = NULL;
256
257static gsw_eu_ecall_status_cb_f gsw_eu_ecall_status_cb;
258
259static pthread_t gsw_ecall_status_cb_thread;
260static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
261static pthread_cond_t g_cond = PTHREAD_COND_INITIALIZER;
262static bool g_thread_running = false;
263
264static uint32_t g_sta_cb_id = 0;
265static gsw_eu_ecall_msd_trans_status_e g_msd_send_status = 0;
266
267#define LIB_PATH "/lib/libmbtk_lib.so"
268
269
270
271
272
273
274typedef int (*mbtk_ecall_msd_set)(mbtk_info_handle_t* handle, const void* msd);
275static mbtk_ecall_msd_set mbtk_ecall_msd_set_ptr = NULL;
276
277typedef int (*mbtk_ecall_push)(mbtk_info_handle_t* handle);
278static mbtk_ecall_push mbtk_ecall_push_ptr = NULL;
279
280typedef int (*mbtk_ecall_only_set)(mbtk_info_handle_t* handle, const mbtk_ecall_only_info_t* info);
281static mbtk_ecall_only_set mbtk_ecall_only_set_ptr = NULL;
282
283
284typedef int (*mbtk_ecall_reg_set)(mbtk_info_handle_t* handle, int reg);
285static mbtk_ecall_reg_set mbtk_ecall_reg_set_ptr = NULL;
286
287typedef int (*mbtk_ecall_dial_start)(mbtk_info_handle_t* handle, mbtk_ecall_dial_type_enum type);
288static mbtk_ecall_dial_start mbtk_ecall_dial_start_ptr = NULL;
289
290typedef int (*mbtk_ecall_mode_set)(mbtk_info_handle_t* handle, mbtk_ecall_mode_type_enum mode);
291static mbtk_ecall_mode_set mbtk_ecall_mode_set_ptr = NULL;
292
293
294typedef int (*mbtk_ecall_cfg_set)(mbtk_info_handle_t* handle, const mbtk_ecall_cfg_info_t *cfg);
295static mbtk_ecall_cfg_set mbtk_ecall_cfg_set_ptr = NULL;
296
297typedef int (*mbtk_ecall_cfg_get)(mbtk_info_handle_t* handle, mbtk_ecall_cfg_info_t* cfg);
298static mbtk_ecall_cfg_get mbtk_ecall_cfg_get_ptr = NULL;
299
300typedef int (*mbtk_ecall_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
301static mbtk_ecall_state_change_cb_reg mbtk_ecall_state_change_cb_reg_ptr = NULL;
302
303typedef int (*mbtk_call_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
304static mbtk_call_state_change_cb_reg mbtk_call_state_change_cb_reg_ptr = NULL;
305
306
307
308static int state_t = -1;
309
310
311
312typedef struct
313{
314 uint8 call_wait;
315 uint8 dir1;
316 uint8 dir;
317 uint8 state;
318 uint8 mode;
319 uint8 mpty;
320 char phone_number[100];
321 uint8 type;
322 uint8 pas;
323 uint8 disconnected_id;
324 uint8 end_reason[128];
325} __attribute__((packed)) mbtk_call_info_t;
326
327
328//static mbtk_info_handle_t* ecall_info_handle = NULL;
329
330
q.huang6e4f4732025-07-22 18:46:32 +0800331
b.liu68a94c92025-05-24 12:53:41 +0800332
333static void *handle = NULL;
q.huang6e4f4732025-07-22 18:46:32 +0800334
b.liu68a94c92025-05-24 12:53:41 +0800335static int ecall_init_flag = 0;
336static mbtk_info_handle_t* ecall_info_handle = NULL;
337
338
339
340static uint8_t fail_redial = 1;
341
342static gsw_eu_ecall_event_cb_f gsw_eu_ecall_event_cb = NULL;
343static bool g_setevent_cb = false;
344
345static void mbtk_send_singnal()
346{
347 pthread_mutex_lock(&g_mutex);
348 pthread_cond_signal(&g_cond);
349 pthread_mutex_unlock(&g_mutex);
350
351}
352
353static void mbtk_wait_signal()
354{
355
356 pthread_mutex_lock(&g_mutex);
357 pthread_cond_wait(&g_cond, &g_mutex);
358 pthread_mutex_unlock(&g_mutex);
359}
360
361static void mbtk_ecall_api_ptr_deinit()
362{
363 dlclose(handle);
364 handle = NULL;
b.liu68a94c92025-05-24 12:53:41 +0800365 mbtk_info_handle_get_ptr=NULL;
366 mbtk_info_handle_free_ptr=NULL;
367 mbtk_ecall_msd_set_ptr=NULL;
368 mbtk_ecall_push_ptr=NULL;
369 mbtk_ecall_only_set_ptr=NULL;
370 mbtk_ecall_reg_set_ptr=NULL;
371 mbtk_ecall_dial_start_ptr=NULL;
372 mbtk_ecall_mode_set_ptr=NULL;
373 mbtk_ecall_cfg_set_ptr=NULL;
374 mbtk_ecall_cfg_get_ptr=NULL;
375 mbtk_ecall_state_change_cb_reg_ptr=NULL;
376 gsw_eu_ecall_status_cb=NULL;
377 gsw_eu_ecall_event_cb=NULL;
378 g_setevent_cb=false;
379 mbtk_ecall_only_set_ptr = NULL;
b.liu68a94c92025-05-24 12:53:41 +0800380
381}
382
383
384static int mbtk_ecall_api_import()
385{
386 handle = dlopen(LIB_PATH, RTLD_NOW);
387 if (handle == NULL)
388 {
l.yang2678d6f2025-05-28 03:58:49 -0700389 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800390 }
391
b.liu68a94c92025-05-24 12:53:41 +0800392 if(mbtk_info_handle_get_ptr == NULL)
393 {
394 mbtk_info_handle_get_ptr = (mbtk_info_handle_get)dlsym(handle, "mbtk_info_handle_get");
395 if(mbtk_info_handle_get_ptr == NULL)
396 {
l.yang2678d6f2025-05-28 03:58:49 -0700397 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800398 }
399 }
400
401 if(mbtk_info_handle_free_ptr == NULL)
402 {
403 mbtk_info_handle_free_ptr = (mbtk_info_handle_free)dlsym(handle, "mbtk_info_handle_free");
404 if(mbtk_info_handle_free_ptr == NULL)
405 {
l.yang2678d6f2025-05-28 03:58:49 -0700406 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800407 }
408 }
409
410
411
412 if(mbtk_ecall_msd_set_ptr == NULL)
413 {
414 mbtk_ecall_msd_set_ptr = (mbtk_ecall_msd_set)dlsym(handle, "mbtk_ecall_msd_set");
415 if(mbtk_ecall_msd_set_ptr == NULL)
416 {
l.yang2678d6f2025-05-28 03:58:49 -0700417 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800418 }
419 }
420
421 if(mbtk_ecall_push_ptr == NULL)
422 {
423 mbtk_ecall_push_ptr = (mbtk_ecall_push)dlsym(handle, "mbtk_ecall_push");
424 if(mbtk_ecall_push_ptr == NULL)
425 {
l.yang2678d6f2025-05-28 03:58:49 -0700426 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800427 }
428 }
429 if(mbtk_ecall_only_set_ptr == NULL)
430 {
431 mbtk_ecall_only_set_ptr = (mbtk_ecall_only_set)dlsym(handle, "mbtk_ecall_only_set");
432 if(mbtk_ecall_only_set_ptr == NULL)
433 {
l.yang2678d6f2025-05-28 03:58:49 -0700434 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800435 }
436 }
437
438 if(mbtk_ecall_reg_set_ptr == NULL)
439 {
440 mbtk_ecall_reg_set_ptr = (mbtk_ecall_reg_set)dlsym(handle, "mbtk_ecall_reg_set");
441 if(mbtk_ecall_reg_set_ptr == NULL)
442 {
l.yang2678d6f2025-05-28 03:58:49 -0700443 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800444 }
445 }
446 if(mbtk_ecall_dial_start_ptr == NULL)
447 {
448 mbtk_ecall_dial_start_ptr = (mbtk_ecall_dial_start)dlsym(handle, "mbtk_ecall_dial_start");
449 if(mbtk_ecall_dial_start_ptr == NULL)
450 {
l.yang2678d6f2025-05-28 03:58:49 -0700451 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800452 }
453 }
454
455 if(mbtk_ecall_mode_set_ptr == NULL)
456 {
457 mbtk_ecall_mode_set_ptr = (mbtk_ecall_mode_set)dlsym(handle, "mbtk_ecall_mode_set");
458 if(mbtk_ecall_mode_set_ptr == NULL)
459 {
l.yang2678d6f2025-05-28 03:58:49 -0700460 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800461 }
462 }
463
464 if(mbtk_ecall_cfg_set_ptr == NULL)
465 {
466 mbtk_ecall_cfg_set_ptr = (mbtk_ecall_cfg_set)dlsym(handle, "mbtk_ecall_cfg_set");
467 if(mbtk_ecall_cfg_set_ptr == NULL)
468 {
l.yang2678d6f2025-05-28 03:58:49 -0700469 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800470 }
471 }
472 if(mbtk_ecall_cfg_get_ptr == NULL)
473 {
474 mbtk_ecall_cfg_get_ptr = (mbtk_ecall_cfg_get)dlsym(handle, "mbtk_ecall_cfg_get");
475 if(mbtk_ecall_cfg_get_ptr == NULL)
476 {
l.yang2678d6f2025-05-28 03:58:49 -0700477 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800478 }
479 }
480 if(mbtk_ecall_state_change_cb_reg_ptr == NULL)
481 {
482 mbtk_ecall_state_change_cb_reg_ptr = (mbtk_ecall_state_change_cb_reg)dlsym(handle, "mbtk_ecall_state_change_cb_reg");
483 if(mbtk_ecall_state_change_cb_reg_ptr == NULL)
484 {
l.yang2678d6f2025-05-28 03:58:49 -0700485 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800486 }
487 }
488
489 if(mbtk_call_state_change_cb_reg_ptr == NULL)
490 {
491 mbtk_call_state_change_cb_reg_ptr = (mbtk_call_state_change_cb_reg)dlsym(handle, "mbtk_call_state_change_cb_reg");
492 if(mbtk_call_state_change_cb_reg_ptr == NULL)
493 {
l.yang2678d6f2025-05-28 03:58:49 -0700494 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800495 }
496 }
497
498 return GSW_HAL_SUCCESS;
499}
500
501
502static void gsw_call_state_change_cb(const void *data, int data_len)
503{
504 mbtk_call_info_t *reg = (mbtk_call_info_t *)data;
505 switch (reg->call_wait)
506 {
507 case MBTK_CLCC:
508 {
q.huang6e4f4732025-07-22 18:46:32 +0800509 LOGD(GSW_ECALL,"RING : %d, %d, %d, %d, %d, %s, %d, %d", reg->dir1, reg->dir, reg->state, reg->mode, reg->mpty, reg->phone_number, reg->type, reg->disconnected_id);
b.liu68a94c92025-05-24 12:53:41 +0800510 switch(reg->state)
511 {
512 case 0:
513 state_t = 0;
q.huang6e4f4732025-07-22 18:46:32 +0800514 LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_CONNECTED ");
b.liu68a94c92025-05-24 12:53:41 +0800515 break;
516 case 1:
517 //state_t = GSW_VOICE_CALL_HOLDING;
q.huang6e4f4732025-07-22 18:46:32 +0800518 LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_HOLDING ");
b.liu68a94c92025-05-24 12:53:41 +0800519 break;
520 case 2:
521 //state_t = GSW_VOICE_CALL_DIALING;
q.huang6e4f4732025-07-22 18:46:32 +0800522 LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_DIALING ");
b.liu68a94c92025-05-24 12:53:41 +0800523 break;
524 case 3:
525 //state_t = GSW_VOICE_CALL_ALERTING;
q.huang6e4f4732025-07-22 18:46:32 +0800526 LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_ALERTING ");
b.liu68a94c92025-05-24 12:53:41 +0800527 break;
528 case 4:
529 //state_t = GSW_VOICE_CALL_INCOMING;
530
q.huang6e4f4732025-07-22 18:46:32 +0800531 LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_INCOMING ");
b.liu68a94c92025-05-24 12:53:41 +0800532 break;
533 case 5:
534 //state_t = GSW_VOICE_CALL_WAITING;
q.huang6e4f4732025-07-22 18:46:32 +0800535 LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_WAITING ");
b.liu68a94c92025-05-24 12:53:41 +0800536 break;
537 case 6:
538 //state_t = GSW_VOICE_CALL_END;
q.huang6e4f4732025-07-22 18:46:32 +0800539 LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_END ");
b.liu68a94c92025-05-24 12:53:41 +0800540 break;
541 }
542
543 g_sta_cb_id = reg->dir1;
544 }
545
546 break;
547 default:
q.huang6e4f4732025-07-22 18:46:32 +0800548 LOGE(GSW_ECALL,"RING : None call_wait = %d", reg->call_wait);
b.liu68a94c92025-05-24 12:53:41 +0800549 break;
550 }
551}
552
553
554/**
555* @brief init the Europe Ecall voice
556* @param [in] None
557* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700558* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800559*/
560
561int32_t gsw_eu_ecall_voice_init(void)
562{
563 int ret =-1;
564 ret = mbtk_ecall_api_import();
565 if(ret <0)
566 {
l.yang2678d6f2025-05-28 03:58:49 -0700567 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800568 }
b.liu68a94c92025-05-24 12:53:41 +0800569
570 ecall_info_handle = mbtk_info_handle_get_ptr();
571 if(ecall_info_handle == NULL)
572 {
q.huang6e4f4732025-07-22 18:46:32 +0800573 LOGE(GSW_ECALL,"mbtk_info_handle_get_ptr fail!!!");
l.yang2678d6f2025-05-28 03:58:49 -0700574 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800575 }
576
577 if(ecall_init_flag == 0)
578 {
579 ecall_init_flag = 1;
580 }
581 ret = mbtk_call_state_change_cb_reg_ptr(ecall_info_handle, gsw_call_state_change_cb);
582 if(ret < 0)
583 {
q.huang6e4f4732025-07-22 18:46:32 +0800584 LOGE(GSW_ECALL,"mbtk_call_state_change_cb_reg_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -0700585 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800586 }
587 return GSW_HAL_SUCCESS;
588
589}
590
591
592/**
593* @brief deinit the Europe Ecall voice
594* @param [in] None
595* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700596* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800597*/
598int32_t gsw_eu_ecall_voice_deinit(void)
599{
600 int ret = -1;
601 if(ecall_info_handle == NULL || ecall_init_flag ==0)
602 {
q.huang6e4f4732025-07-22 18:46:32 +0800603 LOGE(GSW_ECALL,"No init can not deinit");
l.yang2678d6f2025-05-28 03:58:49 -0700604 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800605 }
606
607 g_thread_running = false;
608 mbtk_send_singnal();
609 if (gsw_ecall_status_cb_thread != 0)
610 {
611 pthread_cancel(gsw_ecall_status_cb_thread);
612 pthread_join(gsw_ecall_status_cb_thread, NULL);
613 gsw_ecall_status_cb_thread = 0;
614 }
615
616 ret = mbtk_info_handle_free_ptr(&ecall_info_handle);
617 if(ret < 0 )
618 {
q.huang6e4f4732025-07-22 18:46:32 +0800619 LOGE(GSW_ECALL,"mbtk_info_handle_free handle faile");
b.liu68a94c92025-05-24 12:53:41 +0800620 }
621 ecall_info_handle = NULL;
622 ecall_init_flag = 0;
623
624 mbtk_ecall_api_ptr_deinit();
625 return GSW_HAL_SUCCESS;
626
627}
628
629
630/**
631* @brief start a Europe Ecall
632* @param [in] gsw_eu_ecall_info_t *p_info: ecall info
633* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700634* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800635*/
636int32_t gsw_eu_ecall_start(gsw_eu_ecall_info_t *p_info)
637{
638 int ret = -1;
639 mbtk_ecall_dial_type_enum ecall_type= -1;
640 mbtk_ecall_only_info_t only_info;
641
642
643 char tmp_number[GSW_EU_ECALL_MAX_PHONE_NUMBER] = {0};
644
645 char msd_data[500] = {0};
646
647 memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t));
648
649 if(ecall_init_flag !=1)
650 {
l.yang2678d6f2025-05-28 03:58:49 -0700651 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800652 }
653
654 if(p_info == NULL || p_info->msd_len > GSW_EU_ECALL_MAX_MSD )
655 {
l.yang2678d6f2025-05-28 03:58:49 -0700656 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800657 }
658
659
660 if(p_info->type == GSW_EU_ECALL_TYPE_TEST)
661 {
662 //AT+CECALL =0
663 ecall_type = MBTK_ECALL_DIAL_TYPE_TEST;
664 snprintf(tmp_number,sizeof(tmp_number),"%s",p_info->ecall_number);
hong.liud2417072025-06-27 07:10:37 -0700665 strncpy((char *)only_info.test_num,tmp_number,RIL_MAX_NUMBER_LEN-1);
666 only_info.test_num[RIL_MAX_NUMBER_LEN-1]='\0';
b.liu68a94c92025-05-24 12:53:41 +0800667 //snprintf((char*)only_info.test_num,sizeof(only_info.test_num),"%s",p_info->ecall_number);
668 }
669
670 if(p_info->type == GSW_EU_ECALL_TYPE_RECONFIG )
671 {
672 //AT+CECALL =1
673 ecall_type = MBTK_ECALL_DIAL_TYPE_RECONFIG;
674 snprintf(tmp_number,sizeof(tmp_number),"%s",p_info->ecall_number);
hong.liud2417072025-06-27 07:10:37 -0700675 strncpy((char *)only_info.test_num,tmp_number,RIL_MAX_NUMBER_LEN-1);
676 only_info.test_num[RIL_MAX_NUMBER_LEN-1]='\0';
b.liu68a94c92025-05-24 12:53:41 +0800677 }
678
679 if(p_info->type == GSW_EU_ECALL_TYPE_EMERGENCY )
680 {
681 if(p_info->auto_trigger)
682 {
683 //AT+CECALL =1
684 ecall_type = MBTK_ECALL_DIAL_TYPE_AUTO;
685 }
686 else
687 {
688 //AT+CECALL =1
689 ecall_type = MBTK_ECALL_DIAL_TYPE_MANUALLY;//手动
690 }
691
692 }
693
694 //msd
695 for (int i = 0; i < p_info->msd_len; i++)
696 {
697 sprintf(msd_data + (i * 2), "%02x", p_info->msd[i]);
698 }
699
700 //
701 only_info.active = MBTK_ECALL_ONLY_TYPE_DISABLE ;
702
703 ret=mbtk_ecall_only_set_ptr(ecall_info_handle,&only_info);
704 if (ret != 0)
705 {
q.huang6e4f4732025-07-22 18:46:32 +0800706 LOGE(GSW_ECALL,"mbtk_ecall_only_set_success failed");
l.yang2678d6f2025-05-28 03:58:49 -0700707 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800708 }
709
710 //set msd
711 ret= mbtk_ecall_msd_set_ptr(ecall_info_handle,(const void*)msd_data);
712 if (ret != 0)
713 {
q.huang6e4f4732025-07-22 18:46:32 +0800714 LOGE(GSW_ECALL,"mbtk_ecall_msd_set_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -0700715 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800716 }
717
718 //dial
719 ret= mbtk_ecall_dial_start_ptr(ecall_info_handle,ecall_type);
720 if (ret != 0)
721 {
q.huang6e4f4732025-07-22 18:46:32 +0800722 LOGE(GSW_ECALL,"mbtk_ecall_dial_start_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -0700723 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800724 }
725
726 //push mst
727 ret= mbtk_ecall_push_ptr(ecall_info_handle);
728 if (ret != 0)
729 {
730 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_FAILURE;
731 mbtk_send_singnal();
q.huang6e4f4732025-07-22 18:46:32 +0800732 LOGE(GSW_ECALL,"mbtk_ecall_push_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -0700733 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800734 }
735
736 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_SUCCESS;
737 mbtk_send_singnal();
738 return GSW_HAL_SUCCESS;
739
740}
741
742
743/**
744* @brief hangup a Europe Ecall
745* @param [in] None
746* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700747* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800748*/
749int32_t gsw_eu_ecall_hangup(void)
750{
751 int32_t ret = -1;
752 if(ecall_info_handle == NULL)
753 {
l.yang2678d6f2025-05-28 03:58:49 -0700754 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800755 }
756
757 ret = mbtk_ecall_dial_start_ptr(ecall_info_handle,MBTK_ECALL_DIAL_TYPE_RELEASE);
758 if(ret != 0)
759 {
q.huang6e4f4732025-07-22 18:46:32 +0800760 LOGE(GSW_ECALL,"hangup ecall faile ");
l.yang2678d6f2025-05-28 03:58:49 -0700761 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800762 }
763
764 return GSW_HAL_SUCCESS;
765}
766
767/**
768* @brief using push mode send msd data
769* @param [in] GSW_EU_ECALL_STATE_E state: ecall state
770* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700771* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800772*/
773
774int32_t gsw_eu_ecall_updateMsd(const uint8_t *msd, uint32_t msd_len)
775{
776 int ret = -1;
777 char msd_data[500] = {0};
778
779 if(msd == NULL || msd_len == 0 ||ecall_info_handle == NULL)
780 {
hong.liud2417072025-06-27 07:10:37 -0700781 return GSW_HAL_NO_MEMORY;
b.liu68a94c92025-05-24 12:53:41 +0800782 }
783
784 //msd
785 for (int i = 0; i < msd_len; i++)
786 {
787 sprintf(msd_data + i * 2, "%02x", *(msd + i));
788 }
789 ret = mbtk_ecall_msd_set_ptr(ecall_info_handle,(const void*)msd_data);
790 if (ret != 0)
791 {
q.huang6e4f4732025-07-22 18:46:32 +0800792 LOGE(GSW_ECALL,"mbtk_ecall_msd_get_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -0700793 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800794 }
795 return GSW_HAL_SUCCESS;
796
797}
798
799
800int32_t gsw_eu_ecall_pushMsd(gsw_eu_ecall_state_e state)
801{
802 int ret = -1;
803 if(ecall_info_handle == NULL)
804 {
l.yang2678d6f2025-05-28 03:58:49 -0700805 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800806 }
807
808 ret = mbtk_ecall_push_ptr(ecall_info_handle);
809 if(ret != 0)
810 {
811 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_FAILURE;
812 mbtk_send_singnal();
l.yang2678d6f2025-05-28 03:58:49 -0700813 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800814 }
815 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_SUCCESS;
816 mbtk_send_singnal();
817 return GSW_HAL_SUCCESS;
818
819
820}
821
822/**
823* @brief get ecall config
824* @param [in] None
825* @param [out] gsw_eu_ecall_config_t *p_config: ecall config
hong.liud2417072025-06-27 07:10:37 -0700826* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800827*/
828int32_t gsw_eu_ecall_getConfig(gsw_eu_ecall_config_t *p_config)
829{
830
831 if(ecall_info_handle==NULL || p_config == NULL)
832 {
q.huang6e4f4732025-07-22 18:46:32 +0800833 LOGE(GSW_ECALL,"mbtk_ecall_cfg_get() fail.");
hong.liud2417072025-06-27 07:10:37 -0700834 return GSW_HAL_NO_MEMORY;
b.liu68a94c92025-05-24 12:53:41 +0800835 }
836
837 p_config->fail_redial = fail_redial;
838
839 return GSW_HAL_SUCCESS;
840}
841
842/**
843* @brief set ecall config
844* @param [in] int32_t item: config item
845* @param [in] gsw_eu_ecall_config_t *p_config: config info
846* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700847* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800848*/
849
850int32_t gsw_eu_ecall_setConfig(int32_t item, gsw_eu_ecall_config_t *p_config)
851{
852 if(ecall_info_handle == NULL || p_config == NULL)
853 {
q.huang6e4f4732025-07-22 18:46:32 +0800854 LOGE(GSW_ECALL,"gsw_eu_ecall_setConfig no init");
hong.liud2417072025-06-27 07:10:37 -0700855 return GSW_HAL_NO_MEMORY;
b.liu68a94c92025-05-24 12:53:41 +0800856 }
857
858 mbtk_ecall_cfg_info_t cfg_info = {0};
859
860 int ret =-1;
861 cfg_info.type = 0;
862
863 if(item & GSW_EU_ECALL_CONFIG_FAIL_REDIAL)
864 {
865 fail_redial = p_config->fail_redial;
866 if(p_config->fail_redial)
867 {
868 cfg_info.type |= MBTK_ECALL_CFG_TIMER_DIAL;
869 cfg_info.data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] = 60000;//timer 60s
870
871 }
872 else
873 {
874 cfg_info.type |= MBTK_ECALL_CFG_TIMER_DIAL;
875 cfg_info.data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] = 0;
876 }
877 }
878
879 ret = mbtk_ecall_cfg_set_ptr(ecall_info_handle, &cfg_info);
880 if (ret < 0)
881 {
q.huang6e4f4732025-07-22 18:46:32 +0800882 LOGE(GSW_ECALL,"mbtk_ecall_cfg_set_ptr fail");
l.yang2678d6f2025-05-28 03:58:49 -0700883 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800884 }
885 return GSW_HAL_SUCCESS;
886
887}
888
889
890
891static void mbtk_ecall_state_change_cb(const void* data, int data_len)
892{
893 static gsw_eu_ecall_event_t event;
894 if(data)
895 {
896 mbtk_ril_ecall_state_info_t *ecall_data = (mbtk_ril_ecall_state_info_t*)data;
897 switch(ecall_data->urc_id)
898 {
899 case MBTK_ECALL_URC_ID_MSD_REQ:
900 {
q.huang6e4f4732025-07-22 18:46:32 +0800901 LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_MSD_REQ");
b.liu68a94c92025-05-24 12:53:41 +0800902 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_START_RECEIVED_MSD;
903 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPDATE_PSAP_REQURE_UPDATE_MSD;
904 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
905 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_NONE;
906 break;
907 }
908 case MBTK_ECALL_URC_ID_MSD_SEND_START:
909 {
q.huang6e4f4732025-07-22 18:46:32 +0800910 LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_MSD_SEND_START");
b.liu68a94c92025-05-24 12:53:41 +0800911
912 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_START_RECEIVED_MSD;
913 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPDATE_PSAP_REQURE_UPDATE_MSD;
914 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
915 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_NONE;
916 break;
917 }
918 case MBTK_ECALL_URC_ID_NACK:
919 {
q.huang6e4f4732025-07-22 18:46:32 +0800920 LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_NACK");
b.liu68a94c92025-05-24 12:53:41 +0800921
922 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_NACK_RECEIVED;
923 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPADTE_NONE;
924 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
925 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_NONE;
926 break;
927 }
928 case MBTK_ECALL_URC_ID_LLACK:
929 {
q.huang6e4f4732025-07-22 18:46:32 +0800930 LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_LLACK");
b.liu68a94c92025-05-24 12:53:41 +0800931
932 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_ACK_RECEIVED;
933 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPADTE_NONE;
934 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_IVS_LLACK_RECEIVED;
935 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_SUCCESS;
936 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_SUCCESS;
937 mbtk_send_singnal();
938 break;
939 }
940 case MBTK_ECALL_URC_ID_HLACK:
941 {
q.huang6e4f4732025-07-22 18:46:32 +0800942 LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_HLACK");
b.liu68a94c92025-05-24 12:53:41 +0800943 event.fail = GSW_EU_ECALL_EVENT_FAIL_NONE;
944 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_HLACK_RECEIVED;
945
946 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPADTE_NONE;
947 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
948 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_SUCCESS;
949 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_SUCCESS;
950 mbtk_send_singnal();
951 break;
952 }
953 case MBTK_ECALL_URC_ID_ALACK:
954 {
q.huang6e4f4732025-07-22 18:46:32 +0800955 LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_ALACK");
b.liu68a94c92025-05-24 12:53:41 +0800956 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_IVS_ALACK_RECEIVED;
957 }
958 case MBTK_ECALL_URC_ID_MSD_UPDATE_DONE:
959 {
q.huang6e4f4732025-07-22 18:46:32 +0800960 LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_MSD_UPDATE_DONE");
b.liu68a94c92025-05-24 12:53:41 +0800961 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_NONE;
962 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPADTE_NONE;
963 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
964 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_SUCCESS;
965
966 }
967 case MBTK_ECALL_URC_ID_T5_EXPIRED:
968 case MBTK_ECALL_URC_ID_T6_EXPIRED:
969 case MBTK_ECALL_URC_ID_T7_EXPIRED:
970 {
q.huang6e4f4732025-07-22 18:46:32 +0800971 LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_T5_EXPIRED | MBTK_ECALL_URC_ID_T5_EXPIRED | MBTK_ECALL_URC_ID_T7_EXPIRED");
b.liu68a94c92025-05-24 12:53:41 +0800972 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPDATE_IVS_UPDATE_MSD_TIMEOUT;
973 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
974 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_SUCCESS;
975 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_FAILURE;
976 mbtk_send_singnal();
977 break;
978 }
979 case MBTK_ECALL_URC_ID_3GPP_FATAL:
980 case MBTK_ECALL_URC_ID_GENERIC:
981 {
q.huang6e4f4732025-07-22 18:46:32 +0800982 LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_GENERIC|MBTK_ECALL_URC_ID_3GPP_FATAL");
b.liu68a94c92025-05-24 12:53:41 +0800983 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
984 }
985 case MBTK_ECALL_URC_ID_MSD_UPDATE_ERR:
986 {
q.huang6e4f4732025-07-22 18:46:32 +0800987 LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_MSD_UPDATE_ERR");
b.liu68a94c92025-05-24 12:53:41 +0800988 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPDATE_IVS_UPDATE_MSD_TIMEOUT;
989
990 }
991 default:
992 {
993
q.huang6e4f4732025-07-22 18:46:32 +0800994 LOGE(GSW_ECALL,"No process urc_id : %d", ecall_data->urc_id);
b.liu68a94c92025-05-24 12:53:41 +0800995 break;
996 }
997 }
998
999 }
1000 if(gsw_eu_ecall_event_cb)
1001 {
1002 gsw_eu_ecall_event_cb(&event);
1003 }
1004}
1005
1006
1007/**
1008 * @brief register the ecall status callback
1009* @param [in] gsw_eu_ecall_status_cb_f cb:callback
1010* @param [out] None
hong.liud2417072025-06-27 07:10:37 -07001011* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +08001012*/
1013int32_t gsw_eu_ecall_setEventCB(gsw_eu_ecall_event_cb_f cb)
1014{
1015 int ret = -1;
1016 if(ecall_info_handle==NULL)
1017 {
hong.liud2417072025-06-27 07:10:37 -07001018 return GSW_HAL_NO_MEMORY;
b.liu68a94c92025-05-24 12:53:41 +08001019 }
1020
1021 gsw_eu_ecall_event_cb = cb;
1022 if(!g_setevent_cb)
1023 {
1024 ret = mbtk_ecall_state_change_cb_reg_ptr(ecall_info_handle, mbtk_ecall_state_change_cb);
1025 if(ret < 0)
1026 {
1027
q.huang6e4f4732025-07-22 18:46:32 +08001028 LOGE(GSW_ECALL,"mbtk_ecall_state_change_cb_reg_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -07001029 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +08001030 }
1031 g_setevent_cb = true;
1032 }
1033
1034 return GSW_HAL_SUCCESS;
1035
1036}
1037
1038
1039
1040static void* ecall_msd_status_cb_thread(void* arg)
1041{
1042 while(g_thread_running)
1043 {
1044 mbtk_wait_signal();
1045 if(g_thread_running == false)
1046 {
1047 return NULL;
1048 }
1049 if(gsw_eu_ecall_status_cb)
1050 {
1051 gsw_eu_ecall_status_cb(g_sta_cb_id,g_msd_send_status);
1052 }
1053
1054 }
1055 return NULL;
1056}
1057
1058/**
1059* @brief register the ecall status callback
1060* @param [in] gsw_eu_ecall_status_cb_f cb:callback
1061* @param [out] None
hong.liud2417072025-06-27 07:10:37 -07001062* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +08001063*/
1064int32_t gsw_eu_ecall_setStatusCB(gsw_eu_ecall_status_cb_f cb)
1065{
1066 int ret = -1;
1067 if(ecall_info_handle==NULL)
1068 {
l.yang2678d6f2025-05-28 03:58:49 -07001069 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +08001070 }
1071 gsw_eu_ecall_status_cb = cb;
1072 if (!g_thread_running)
1073 {
1074 ret = pthread_create(&gsw_ecall_status_cb_thread, NULL, ecall_msd_status_cb_thread, NULL);
1075 if(ret < 0)
1076 {
q.huang6e4f4732025-07-22 18:46:32 +08001077 LOGE(GSW_ECALL,"pthread_create failed");
b.liu68a94c92025-05-24 12:53:41 +08001078 g_thread_running = false;
l.yang2678d6f2025-05-28 03:58:49 -07001079 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +08001080 }
1081 g_thread_running = true;
1082 }
1083
1084 return GSW_HAL_SUCCESS;
1085
1086}