blob: 599d2408cddfa85db1292a6304ac3fb5824ae3c7 [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"
b.liu68a94c92025-05-24 12:53:41 +080015
16#define RIL_MAX_NUMBER_LEN 40
17#define MBTK_ECALL_MSD_LEN_MAX 600
18
19#ifndef LOG_ERR_LEVEL
20#define LOG_ERR_LEVEL 3 /* error conditions */
21#endif
22#ifndef LOG_WARN_LEVEL
23#define LOG_WARN_LEVEL 4 /* warning conditions */
24#endif
25#ifndef LOG_INFO_LEVEL
26#define LOG_INFO_LEVEL 6 /* informational */
27#endif
28#ifndef LOG_DEBUG_LEVEL
29#define LOG_DEBUG_LEVEL 7 /* debug-level messages */
30#endif
31#ifndef LOG_VERBOSE_LEVEL
32#define LOG_VERBOSE_LEVEL 8
33#endif
34
l.yang6a42e4d2025-05-28 01:04:20 -070035#define GSW_ECALL "[HAL][GSW_ECALL]"
36
b.liu68a94c92025-05-24 12:53:41 +080037#define LOGV(fmt, args ...) \
38 do{ \
39 char *file_ptr_1001 = __FILE__; \
40 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
41 char line_1001[10] = {0}; \
42 sprintf(line_1001, "%d", __LINE__); \
43 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
44 if(*ptr_1001 == '/') \
45 break; \
46 ptr_1001--; \
47 } \
l.yang6a42e4d2025-05-28 01:04:20 -070048 fun_ptr_log(LOG_VERBOSE_LEVEL, "%s#%s: "GSW_ECALL"" fmt, ptr_1001 + 1, line_1001, ##args); \
b.liu68a94c92025-05-24 12:53:41 +080049 } while(0)
50
51#define LOGI(fmt, args...) \
52 do{ \
53 char *file_ptr_1001 = __FILE__; \
54 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
55 char line_1001[10] = {0}; \
56 sprintf(line_1001, "%d", __LINE__); \
57 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
58 if(*ptr_1001 == '/') \
59 break; \
60 ptr_1001--; \
61 } \
l.yang6a42e4d2025-05-28 01:04:20 -070062 fun_ptr_log(LOG_INFO_LEVEL, "%s#%s: "GSW_ECALL"" fmt, ptr_1001 + 1, line_1001, ##args); \
b.liu68a94c92025-05-24 12:53:41 +080063 } while(0)
64
65#define LOGD(fmt, args...) \
66 do{ \
67 char *file_ptr_1001 = __FILE__; \
68 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
69 char line_1001[10] = {0}; \
70 sprintf(line_1001, "%d", __LINE__); \
71 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
72 if(*ptr_1001 == '/') \
73 break; \
74 ptr_1001--; \
75 } \
l.yang6a42e4d2025-05-28 01:04:20 -070076 fun_ptr_log(LOG_DEBUG_LEVEL, "%s#%s: "GSW_ECALL"" fmt, ptr_1001 + 1, line_1001, ##args); \
b.liu68a94c92025-05-24 12:53:41 +080077 } while(0)
78
79#define LOGW(fmt, args...) \
80 do{ \
81 char *file_ptr_1001 = __FILE__; \
82 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
83 char line_1001[10] = {0}; \
84 sprintf(line_1001, "%d", __LINE__); \
85 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
86 if(*ptr_1001 == '/') \
87 break; \
88 ptr_1001--; \
89 } \
l.yang6a42e4d2025-05-28 01:04:20 -070090 fun_ptr_log(LOG_WARN_LEVEL, "%s#%s: "GSW_ECALL"" fmt, ptr_1001 + 1, line_1001, ##args); \
b.liu68a94c92025-05-24 12:53:41 +080091 } while(0)
92
93#define LOGE(fmt, args...) \
94 do{ \
95 char *file_ptr_1001 = __FILE__; \
96 char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
97 char line_1001[10] = {0}; \
98 sprintf(line_1001, "%d", __LINE__); \
99 while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
100 if(*ptr_1001 == '/') \
101 break; \
102 ptr_1001--; \
103 } \
l.yang6a42e4d2025-05-28 01:04:20 -0700104 fun_ptr_log(LOG_ERR_LEVEL, "%s#%s: "GSW_ECALL"" fmt, ptr_1001 + 1, line_1001, ##args); \
b.liu68a94c92025-05-24 12:53:41 +0800105 } while(0)
106
107typedef void (*mbtk_log)(int level, const char *format,...);
108
109
110typedef unsigned int uint32;
111typedef unsigned char uint8;
112typedef unsigned short uint16;
113
114typedef enum {
115 MBTK_ECALL_URC_ID_ALACK = 0, // AL-ACK signal received (refer to : urc_data)
116 MBTK_ECALL_URC_ID_SYNC_LOST, // eIM lost synchronization with PSAP
117 // (A resynch occurs after the synchronization is lost.)
118 MBTK_ECALL_URC_ID_NACK, // NACK signal received
119 MBTK_ECALL_URC_ID_RESERVED_3,
120 MBTK_ECALL_URC_ID_RESERVED_4,
121 MBTK_ECALL_URC_ID_RESERVED_5, // 5
122 MBTK_ECALL_URC_ID_3GPP_FATAL, // eIM is terminated: fatal error (3GPP Abort function)
123 MBTK_ECALL_URC_ID_CALL_DROP, // eIM is terminated: call drop
124 MBTK_ECALL_URC_ID_GENERIC, // Generic error
125 MBTK_ECALL_URC_ID_MSD_REQ, // PSAP request MSD (Only for PULL modem)
126 MBTK_ECALL_URC_ID_MSD_SEND_START, // 10 : eIM starts sending MSD
127 MBTK_ECALL_URC_ID_INITIATION, // The eIM starts sending the Initiation signal (Only for PUSH modem).
128 // It also indicates that the call setup is completed.
129 MBTK_ECALL_URC_ID_SEND_MSD, // PUSH: SEND_MSD -> MSD_SEND_START
130 // PULL: SEND_MSD -> MSD_REQ -> MSD_SEND_START
131 MBTK_ECALL_URC_ID_SEND_MSD_FULL,// SEND MSD signal received too often, PSAP sync failure assumed
132 MBTK_ECALL_URC_ID_SYNCED_PSAP, // IVS eIM is synced with PSAP
133 MBTK_ECALL_URC_ID_SYNCED_PSAP_EIM, // 15: IVS eIM is synced with PSAP eIM
134 MBTK_ECALL_URC_ID_LLACK, // Link layer ACK received
135 MBTK_ECALL_URC_ID_HLACK, // Higher Layer ACK received (similar to AL-ACK (#0) but without data)
136 MBTK_ECALL_URC_ID_EIM_RESET, // The eIM transmitter idles after a full reset. The eIM transmitter is reset after sync loss
137 // (for example, because of the end of PSAP transmission).
138 MBTK_ECALL_URC_ID_EIM_IDLES, // The eIM transmitter idles after the transmission of the Initiation signal (push mode)
139 MBTK_ECALL_URC_ID_MSD_UPDATE, // 20 : MSD update request is received.
140 MBTK_ECALL_URC_ID_MSD_UPDATE_DONE, // MSD update is done.
141 MBTK_ECALL_URC_ID_MSD_UPDATE_ERR, // MSD update request cannot be processed.
142 MBTK_ECALL_URC_ID_T3_EXPIRED, // T3 expired
143 MBTK_ECALL_URC_ID_T5_EXPIRED, // T5 expired
144 MBTK_ECALL_URC_ID_T6_EXPIRED, // 25 : T6 expired
145 MBTK_ECALL_URC_ID_T7_EXPIRED, // T7 expired
146 MBTK_ECALL_URC_ID_TH_EXPIRED, // TH expired
147 MBTK_ECALL_URC_ID_RESERVED_28,
148 MBTK_ECALL_URC_ID_RESERVED_29,
149 MBTK_ECALL_URC_ID_RESERVED_30, // 30
150 MBTK_ECALL_URC_ID_IVS_EVENT_TIMEOUT,
151 MBTK_ECALL_URC_ID_PSAP_REQ, // Only for ERA
152 MBTK_ECALL_URC_ID_MSD_SEND_FAIL_FOR_NG // NG-eCall fail to transfer MSD
153} mbtk_ecall_urc_id_enum;
154
155typedef enum {
156 MBTK_CLCC = 1,
157 MBTK_CPAS,
158 MBTK_DISCONNECTED,
159} mbtk_call_enum;
160
161typedef enum {
162 MBTK_CALL_RADY, //MT allows commands from TA/TE
163 MBTK_CALL_UNAVAILABLE, //MT does not allow commands from TA/TE
164 MBTK_CALL_UNKNOWN, //MT is not guaranteed to respond to instructions
165 MBTK_CALL_RINGING, //MT is ready for commands from TA/TE, but the ringer is active
166 MBTK_CALL_PROGRESS, //MT is ready for commands from TA/TE, but a call is in progress
167 MBTK_CALL_ASLEEP, //MT is unable to process commands from TA/TE because it is in a low functionality state
168 MBTK_CALL_ACTIVE,
169} mbtk_call_pas_enum;
170
171#define MBTK_ECALL_CFG_T3 (1 << MBTK_ECALL_CFG_ITEM_T3) // ms
172#define MBTK_ECALL_CFG_T5 (1 << MBTK_ECALL_CFG_ITEM_T5) // ms
173#define MBTK_ECALL_CFG_T6 (1 << MBTK_ECALL_CFG_ITEM_T6) // ms
174#define MBTK_ECALL_CFG_T7 (1 << MBTK_ECALL_CFG_ITEM_T7) // ms
175#define MBTK_ECALL_CFG_TH (1 << MBTK_ECALL_CFG_ITEM_TH) // ms
176#define MBTK_ECALL_CFG_TIMER_CALLBACK (1 << MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK) // T9
177#define MBTK_ECALL_CFG_TIMER_CLEARDOWN (1 << MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN) // T2
178#define MBTK_ECALL_CFG_TIMER_DEREG (1 << MBTK_ECALL_CFG_ITEM_TIMER_DEREG) // T10
179#define MBTK_ECALL_CFG_TIMER_DIAL (1 << MBTK_ECALL_CFG_ITEM_TIMER_DIAL) // "dial"
180#define MBTK_ECALL_CFG_TIMER_REDIAL (1 << MBTK_ECALL_CFG_ITEM_TIMER_REDIAL) // "redialtmr"
181#define MBTK_ECALL_CFG_TIMER_SMS (1 << MBTK_ECALL_CFG_ITEM_TIMER_SMS) // "sms" // 10
182#define MBTK_ECALL_CFG_REDIALCNT (1 << MBTK_ECALL_CFG_ITEM_REDIALCNT) // "redialcnt"
183#define MBTK_ECALL_CFG_SMSPROCESS (1 << MBTK_ECALL_CFG_ITEM_SMSPROCESS) // "smsprocess"
184#define MBTK_ECALL_CFG_SMSMSDCNT (1 << MBTK_ECALL_CFG_ITEM_SMSMSDCNT) // "smsmsdcnt"
185
186
187typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
188
189typedef struct
190{
191 int client_fd;
192 pthread_t read_thread_id;
193 int exit_fd[2];
194 bool is_waitting;
195 pthread_cond_t cond;
196 pthread_mutex_t mutex;
197
198 pthread_mutex_t send_mutex;
199
200 // Temp response data.
201 uint16 info_err;
202 uint16 data_len;
203 void *data;
204
205 //mbtk wyq for server_ready_status add start
206 char server_ready_status;
207 //mbtk wyq for server_ready_status add end
208
209 mbtk_info_callback_func net_state_cb;
210 mbtk_info_callback_func call_state_cb;
211 mbtk_info_callback_func sms_state_cb;
212 mbtk_info_callback_func radio_state_cb;
213 mbtk_info_callback_func sim_state_cb;
214 mbtk_info_callback_func pdp_state_cb;
215 //add signal by xr
216 mbtk_info_callback_func signal_state_cb;
217} mbtk_info_handle_t;
218
219typedef enum {
220 MBTK_ECALL_CFG_ITEM_T3 = 0, // ms
221 MBTK_ECALL_CFG_ITEM_T5, // ms
222 MBTK_ECALL_CFG_ITEM_T6, // ms
223 MBTK_ECALL_CFG_ITEM_T7, // ms
224 MBTK_ECALL_CFG_ITEM_TH, // ms
225 MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK, // T9 // 5
226 MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN, // T2
227 MBTK_ECALL_CFG_ITEM_TIMER_DEREG, // T10
228 MBTK_ECALL_CFG_ITEM_TIMER_DIAL, // "dial"
229 MBTK_ECALL_CFG_ITEM_TIMER_REDIAL, // "redialtmr"
230 MBTK_ECALL_CFG_ITEM_TIMER_SMS, // "sms" // 10
231 MBTK_ECALL_CFG_ITEM_REDIALCNT, // "redialcnt"
232 MBTK_ECALL_CFG_ITEM_SMSPROCESS, // "smsprocess"
233 MBTK_ECALL_CFG_ITEM_SMSMSDCNT, // "smsmsdcnt"
234
235 MBTK_ECALL_CFG_ITEM_MAX
236} mbtk_ecall_cfg_item_enum;
237
238
239typedef enum {
240 MBTK_ECALL_MSD_ITEM_VERSION = 0,
241 MBTK_ECALL_MSD_ITEM_MSG_ID,
242 MBTK_ECALL_MSD_ITEM_CONTROLTYPE,
243 MBTK_ECALL_MSD_ITEM_VIN,
244 MBTK_ECALL_MSD_ITEM_STORAGETYPE,
245 MBTK_ECALL_MSD_ITEM_TIMESTAMP,
246 MBTK_ECALL_MSD_ITEM_LOCATION,
247 MBTK_ECALL_MSD_ITEM_DIRECTION,
248 MBTK_ECALL_MSD_ITEM_LOCATIONN1,
249 MBTK_ECALL_MSD_ITEM_LOCATIONN2,
250 MBTK_ECALL_MSD_ITEM_NUMBEROFOCCUPANTS,
251 MBTK_ECALL_MSD_ITEM_ADDITIONALDATA,
252 MBTK_ECALL_MSD_ITEM_ALL_IN_ONE,
253 MBTK_ECALL_MSD_ITEM_ASI,
254 MBTK_ECALL_MSD_ITEM_VEHICLE_DIAGNOSTIC,
255 MBTK_ECALL_MSD_ITEM_CRASH_INFO,
256 MBTK_ECALL_MSD_ITEM_GNSS_TYPE
257} mbtk_ecall_msd_item_enum;
258
259typedef enum {
260 MBTK_ECALL_ONLY_TYPE_DISABLE = 0,
261 MBTK_ECALL_ONLY_TYPE_ENABLE_ECALL,
262 MBTK_ECALL_ONLY_TYPE_ENABLE_NG_ECALL,
263 MBTK_ECALL_ONLY_TYPE_ENABLE_ALL,
264 MBTK_ECALL_ONLY_TYPE_CONF_NUM,
265 MBTK_ECALL_ONLY_TYPE_NORMAL
266} mbtk_ecall_only_type_enum;
267
268typedef struct
269{
270 mbtk_ecall_msd_item_enum item_type;
271
272 uint8 data[64];
273} mbtk_ecall_msd_cfg_info_t;
274
275typedef enum {
276 MBTK_ECALL_SIM_TYPE_NO_SUPPORT = 0,
277 MBTK_ECALL_SIM_TYPE_SUPPORT_ECALL,
278 MBTK_ECALL_SIM_TYPE_SUPPORT_ECALL_ONLY
279} mbtk_ecall_sim_type_enum;
280
281
282typedef struct {
283 mbtk_ecall_only_type_enum active : 8;
284 mbtk_ecall_sim_type_enum sim_type : 8; // Only for GET.
285 uint8 test_num[RIL_MAX_NUMBER_LEN];
286 uint8 reconfig_num[RIL_MAX_NUMBER_LEN];
287} mbtk_ecall_only_info_t;
288
289typedef enum {
290 MBTK_ECALL_MODE_TYPE_EU = 0,
291 MBTK_ECALL_MODE_TYPE_ERA
292} mbtk_ecall_mode_type_enum;
293
294
295typedef enum {
296 MBTK_ECALL_DIAL_TYPE_TEST = 0,
297 MBTK_ECALL_DIAL_TYPE_RECONFIG,
298 MBTK_ECALL_DIAL_TYPE_MANUALLY,
299 MBTK_ECALL_DIAL_TYPE_AUTO,
300 MBTK_ECALL_DIAL_TYPE_NOT_ACTIVATED,
301 MBTK_ECALL_DIAL_TYPE_RELEASE
302} mbtk_ecall_dial_type_enum;
303
304typedef struct {
305 uint32 type; // mbtk_ecall_cfg_item_enum
306
307#if 0
308 uint32 timer_t3; // ms
309 uint32 timer_t5; // ms
310 uint32 timer_t6; // ms
311 uint32 timer_t7; // ms
312 uint32 timer_th; // ms
313
314 uint32 timer_callback; // s (T9)
315 uint32 timer_cleardown; // s (T2)
316 uint32 timer_dereg; // s (T10)
317 uint32 timer_dial; // s
318 uint32 timer_redialtmr; // s
319 uint32 timer_sms; // s
320
321 uint32 redialcnt;
322 uint32 smsprocess;
323 uint32 smsmsdcnt;
324#else
325 uint8 data_valid[MBTK_ECALL_CFG_ITEM_MAX];
326 uint32 data[MBTK_ECALL_CFG_ITEM_MAX];
327#endif
328} mbtk_ecall_cfg_info_t;
329
330
331typedef struct
332{
333 uint8 urc_id;
334 uint8 urc_data[5];
335} mbtk_ril_ecall_state_info_t;
336
337
338typedef mbtk_info_handle_t* (*mbtk_info_handle_get)(void);
339static mbtk_info_handle_get mbtk_info_handle_get_ptr = NULL;
340
341typedef int (*mbtk_info_handle_free)(mbtk_info_handle_t** handle);
342static mbtk_info_handle_free mbtk_info_handle_free_ptr = NULL;
343
344static gsw_eu_ecall_status_cb_f gsw_eu_ecall_status_cb;
345
346static pthread_t gsw_ecall_status_cb_thread;
347static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
348static pthread_cond_t g_cond = PTHREAD_COND_INITIALIZER;
349static bool g_thread_running = false;
350
351static uint32_t g_sta_cb_id = 0;
352static gsw_eu_ecall_msd_trans_status_e g_msd_send_status = 0;
353
354#define LIB_PATH "/lib/libmbtk_lib.so"
355
356
357
358
359
360
361typedef int (*mbtk_ecall_msd_set)(mbtk_info_handle_t* handle, const void* msd);
362static mbtk_ecall_msd_set mbtk_ecall_msd_set_ptr = NULL;
363
364typedef int (*mbtk_ecall_push)(mbtk_info_handle_t* handle);
365static mbtk_ecall_push mbtk_ecall_push_ptr = NULL;
366
367typedef int (*mbtk_ecall_only_set)(mbtk_info_handle_t* handle, const mbtk_ecall_only_info_t* info);
368static mbtk_ecall_only_set mbtk_ecall_only_set_ptr = NULL;
369
370
371typedef int (*mbtk_ecall_reg_set)(mbtk_info_handle_t* handle, int reg);
372static mbtk_ecall_reg_set mbtk_ecall_reg_set_ptr = NULL;
373
374typedef int (*mbtk_ecall_dial_start)(mbtk_info_handle_t* handle, mbtk_ecall_dial_type_enum type);
375static mbtk_ecall_dial_start mbtk_ecall_dial_start_ptr = NULL;
376
377typedef int (*mbtk_ecall_mode_set)(mbtk_info_handle_t* handle, mbtk_ecall_mode_type_enum mode);
378static mbtk_ecall_mode_set mbtk_ecall_mode_set_ptr = NULL;
379
380
381typedef int (*mbtk_ecall_cfg_set)(mbtk_info_handle_t* handle, const mbtk_ecall_cfg_info_t *cfg);
382static mbtk_ecall_cfg_set mbtk_ecall_cfg_set_ptr = NULL;
383
384typedef int (*mbtk_ecall_cfg_get)(mbtk_info_handle_t* handle, mbtk_ecall_cfg_info_t* cfg);
385static mbtk_ecall_cfg_get mbtk_ecall_cfg_get_ptr = NULL;
386
387typedef int (*mbtk_ecall_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
388static mbtk_ecall_state_change_cb_reg mbtk_ecall_state_change_cb_reg_ptr = NULL;
389
390typedef int (*mbtk_call_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
391static mbtk_call_state_change_cb_reg mbtk_call_state_change_cb_reg_ptr = NULL;
392
393
394
395static int state_t = -1;
396
397
398
399typedef struct
400{
401 uint8 call_wait;
402 uint8 dir1;
403 uint8 dir;
404 uint8 state;
405 uint8 mode;
406 uint8 mpty;
407 char phone_number[100];
408 uint8 type;
409 uint8 pas;
410 uint8 disconnected_id;
411 uint8 end_reason[128];
412} __attribute__((packed)) mbtk_call_info_t;
413
414
415//static mbtk_info_handle_t* ecall_info_handle = NULL;
416
417
418typedef void (*mbtk_log_init)(char *path, char *tag);
419static mbtk_log_init mbtk_log_init_ptr = NULL;
420
421static void *handle = NULL;
422typedef void (*mbtk_log)(int level, const char *format,...);
423static mbtk_log fun_ptr_log = NULL;
424static int ecall_init_flag = 0;
425static mbtk_info_handle_t* ecall_info_handle = NULL;
426
427
428
429static uint8_t fail_redial = 1;
430
431static gsw_eu_ecall_event_cb_f gsw_eu_ecall_event_cb = NULL;
432static bool g_setevent_cb = false;
433
434static void mbtk_send_singnal()
435{
436 pthread_mutex_lock(&g_mutex);
437 pthread_cond_signal(&g_cond);
438 pthread_mutex_unlock(&g_mutex);
439
440}
441
442static void mbtk_wait_signal()
443{
444
445 pthread_mutex_lock(&g_mutex);
446 pthread_cond_wait(&g_cond, &g_mutex);
447 pthread_mutex_unlock(&g_mutex);
448}
449
450static void mbtk_ecall_api_ptr_deinit()
451{
452 dlclose(handle);
453 handle = NULL;
454 mbtk_log_init_ptr = NULL;
455 mbtk_info_handle_get_ptr=NULL;
456 mbtk_info_handle_free_ptr=NULL;
457 mbtk_ecall_msd_set_ptr=NULL;
458 mbtk_ecall_push_ptr=NULL;
459 mbtk_ecall_only_set_ptr=NULL;
460 mbtk_ecall_reg_set_ptr=NULL;
461 mbtk_ecall_dial_start_ptr=NULL;
462 mbtk_ecall_mode_set_ptr=NULL;
463 mbtk_ecall_cfg_set_ptr=NULL;
464 mbtk_ecall_cfg_get_ptr=NULL;
465 mbtk_ecall_state_change_cb_reg_ptr=NULL;
466 gsw_eu_ecall_status_cb=NULL;
467 gsw_eu_ecall_event_cb=NULL;
468 g_setevent_cb=false;
469 mbtk_ecall_only_set_ptr = NULL;
470 fun_ptr_log=NULL;
471
472}
473
474
475static int mbtk_ecall_api_import()
476{
477 handle = dlopen(LIB_PATH, RTLD_NOW);
478 if (handle == NULL)
479 {
l.yang2678d6f2025-05-28 03:58:49 -0700480 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800481 }
482
483 if(fun_ptr_log == NULL)
484 {
485 fun_ptr_log = (mbtk_log)dlsym(handle, "mbtk_log");
486 if(fun_ptr_log == NULL)
487 {
l.yang2678d6f2025-05-28 03:58:49 -0700488 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800489 }
490 }
491
492 if(mbtk_log_init_ptr == NULL)
493 {
494 mbtk_log_init_ptr = (mbtk_log_init)dlsym(handle, "mbtk_log_init");
495 if(mbtk_log_init_ptr == NULL)
496 {
l.yang2678d6f2025-05-28 03:58:49 -0700497 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800498 }
499 }
500
501 if(mbtk_info_handle_get_ptr == NULL)
502 {
503 mbtk_info_handle_get_ptr = (mbtk_info_handle_get)dlsym(handle, "mbtk_info_handle_get");
504 if(mbtk_info_handle_get_ptr == NULL)
505 {
l.yang2678d6f2025-05-28 03:58:49 -0700506 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800507 }
508 }
509
510 if(mbtk_info_handle_free_ptr == NULL)
511 {
512 mbtk_info_handle_free_ptr = (mbtk_info_handle_free)dlsym(handle, "mbtk_info_handle_free");
513 if(mbtk_info_handle_free_ptr == NULL)
514 {
l.yang2678d6f2025-05-28 03:58:49 -0700515 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800516 }
517 }
518
519
520
521 if(mbtk_ecall_msd_set_ptr == NULL)
522 {
523 mbtk_ecall_msd_set_ptr = (mbtk_ecall_msd_set)dlsym(handle, "mbtk_ecall_msd_set");
524 if(mbtk_ecall_msd_set_ptr == NULL)
525 {
l.yang2678d6f2025-05-28 03:58:49 -0700526 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800527 }
528 }
529
530 if(mbtk_ecall_push_ptr == NULL)
531 {
532 mbtk_ecall_push_ptr = (mbtk_ecall_push)dlsym(handle, "mbtk_ecall_push");
533 if(mbtk_ecall_push_ptr == NULL)
534 {
l.yang2678d6f2025-05-28 03:58:49 -0700535 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800536 }
537 }
538 if(mbtk_ecall_only_set_ptr == NULL)
539 {
540 mbtk_ecall_only_set_ptr = (mbtk_ecall_only_set)dlsym(handle, "mbtk_ecall_only_set");
541 if(mbtk_ecall_only_set_ptr == NULL)
542 {
l.yang2678d6f2025-05-28 03:58:49 -0700543 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800544 }
545 }
546
547 if(mbtk_ecall_reg_set_ptr == NULL)
548 {
549 mbtk_ecall_reg_set_ptr = (mbtk_ecall_reg_set)dlsym(handle, "mbtk_ecall_reg_set");
550 if(mbtk_ecall_reg_set_ptr == NULL)
551 {
l.yang2678d6f2025-05-28 03:58:49 -0700552 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800553 }
554 }
555 if(mbtk_ecall_dial_start_ptr == NULL)
556 {
557 mbtk_ecall_dial_start_ptr = (mbtk_ecall_dial_start)dlsym(handle, "mbtk_ecall_dial_start");
558 if(mbtk_ecall_dial_start_ptr == NULL)
559 {
l.yang2678d6f2025-05-28 03:58:49 -0700560 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800561 }
562 }
563
564 if(mbtk_ecall_mode_set_ptr == NULL)
565 {
566 mbtk_ecall_mode_set_ptr = (mbtk_ecall_mode_set)dlsym(handle, "mbtk_ecall_mode_set");
567 if(mbtk_ecall_mode_set_ptr == NULL)
568 {
l.yang2678d6f2025-05-28 03:58:49 -0700569 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800570 }
571 }
572
573 if(mbtk_ecall_cfg_set_ptr == NULL)
574 {
575 mbtk_ecall_cfg_set_ptr = (mbtk_ecall_cfg_set)dlsym(handle, "mbtk_ecall_cfg_set");
576 if(mbtk_ecall_cfg_set_ptr == NULL)
577 {
l.yang2678d6f2025-05-28 03:58:49 -0700578 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800579 }
580 }
581 if(mbtk_ecall_cfg_get_ptr == NULL)
582 {
583 mbtk_ecall_cfg_get_ptr = (mbtk_ecall_cfg_get)dlsym(handle, "mbtk_ecall_cfg_get");
584 if(mbtk_ecall_cfg_get_ptr == NULL)
585 {
l.yang2678d6f2025-05-28 03:58:49 -0700586 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800587 }
588 }
589 if(mbtk_ecall_state_change_cb_reg_ptr == NULL)
590 {
591 mbtk_ecall_state_change_cb_reg_ptr = (mbtk_ecall_state_change_cb_reg)dlsym(handle, "mbtk_ecall_state_change_cb_reg");
592 if(mbtk_ecall_state_change_cb_reg_ptr == NULL)
593 {
l.yang2678d6f2025-05-28 03:58:49 -0700594 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800595 }
596 }
597
598 if(mbtk_call_state_change_cb_reg_ptr == NULL)
599 {
600 mbtk_call_state_change_cb_reg_ptr = (mbtk_call_state_change_cb_reg)dlsym(handle, "mbtk_call_state_change_cb_reg");
601 if(mbtk_call_state_change_cb_reg_ptr == NULL)
602 {
l.yang2678d6f2025-05-28 03:58:49 -0700603 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800604 }
605 }
606
607 return GSW_HAL_SUCCESS;
608}
609
610
611static void gsw_call_state_change_cb(const void *data, int data_len)
612{
613 mbtk_call_info_t *reg = (mbtk_call_info_t *)data;
614 switch (reg->call_wait)
615 {
616 case MBTK_CLCC:
617 {
618 LOGD("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);
619 switch(reg->state)
620 {
621 case 0:
622 state_t = 0;
623 LOGD("reg->state = GSW_VOICE_CALL_CONNECTED ");
624 break;
625 case 1:
626 //state_t = GSW_VOICE_CALL_HOLDING;
627 LOGD("reg->state = GSW_VOICE_CALL_HOLDING ");
628 break;
629 case 2:
630 //state_t = GSW_VOICE_CALL_DIALING;
631 LOGD("reg->state = GSW_VOICE_CALL_DIALING ");
632 break;
633 case 3:
634 //state_t = GSW_VOICE_CALL_ALERTING;
635 LOGD("reg->state = GSW_VOICE_CALL_ALERTING ");
636 break;
637 case 4:
638 //state_t = GSW_VOICE_CALL_INCOMING;
639
640 LOGD("reg->state = GSW_VOICE_CALL_INCOMING ");
641 break;
642 case 5:
643 //state_t = GSW_VOICE_CALL_WAITING;
644 LOGD("reg->state = GSW_VOICE_CALL_WAITING ");
645 break;
646 case 6:
647 //state_t = GSW_VOICE_CALL_END;
648 LOGD("reg->state = GSW_VOICE_CALL_END ");
649 break;
650 }
651
652 g_sta_cb_id = reg->dir1;
653 }
654
655 break;
656 default:
657 LOGE("RING : None call_wait = %d", reg->call_wait);
658 break;
659 }
660}
661
662
663/**
664* @brief init the Europe Ecall voice
665* @param [in] None
666* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700667* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800668*/
669
670int32_t gsw_eu_ecall_voice_init(void)
671{
672 int ret =-1;
673 ret = mbtk_ecall_api_import();
674 if(ret <0)
675 {
l.yang2678d6f2025-05-28 03:58:49 -0700676 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800677 }
678
679 mbtk_log_init_ptr("syslog", "GSW_ECALL");
680
681 ecall_info_handle = mbtk_info_handle_get_ptr();
682 if(ecall_info_handle == NULL)
683 {
684 LOGE("mbtk_info_handle_get_ptr fail!!!");
l.yang2678d6f2025-05-28 03:58:49 -0700685 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800686 }
687
688 if(ecall_init_flag == 0)
689 {
690 ecall_init_flag = 1;
691 }
692 ret = mbtk_call_state_change_cb_reg_ptr(ecall_info_handle, gsw_call_state_change_cb);
693 if(ret < 0)
694 {
695 LOGE("mbtk_call_state_change_cb_reg_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -0700696 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800697 }
698 return GSW_HAL_SUCCESS;
699
700}
701
702
703/**
704* @brief deinit the Europe Ecall voice
705* @param [in] None
706* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700707* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800708*/
709int32_t gsw_eu_ecall_voice_deinit(void)
710{
711 int ret = -1;
712 if(ecall_info_handle == NULL || ecall_init_flag ==0)
713 {
714 LOGE("No init can not deinit");
l.yang2678d6f2025-05-28 03:58:49 -0700715 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800716 }
717
718 g_thread_running = false;
719 mbtk_send_singnal();
720 if (gsw_ecall_status_cb_thread != 0)
721 {
722 pthread_cancel(gsw_ecall_status_cb_thread);
723 pthread_join(gsw_ecall_status_cb_thread, NULL);
724 gsw_ecall_status_cb_thread = 0;
725 }
726
727 ret = mbtk_info_handle_free_ptr(&ecall_info_handle);
728 if(ret < 0 )
729 {
730 LOGE("mbtk_info_handle_free handle faile");
731 }
732 ecall_info_handle = NULL;
733 ecall_init_flag = 0;
734
735 mbtk_ecall_api_ptr_deinit();
736 return GSW_HAL_SUCCESS;
737
738}
739
740
741/**
742* @brief start a Europe Ecall
743* @param [in] gsw_eu_ecall_info_t *p_info: ecall info
744* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700745* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800746*/
747int32_t gsw_eu_ecall_start(gsw_eu_ecall_info_t *p_info)
748{
749 int ret = -1;
750 mbtk_ecall_dial_type_enum ecall_type= -1;
751 mbtk_ecall_only_info_t only_info;
752
753
754 char tmp_number[GSW_EU_ECALL_MAX_PHONE_NUMBER] = {0};
755
756 char msd_data[500] = {0};
757
758 memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t));
759
760 if(ecall_init_flag !=1)
761 {
l.yang2678d6f2025-05-28 03:58:49 -0700762 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800763 }
764
765 if(p_info == NULL || p_info->msd_len > GSW_EU_ECALL_MAX_MSD )
766 {
l.yang2678d6f2025-05-28 03:58:49 -0700767 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800768 }
769
770
771 if(p_info->type == GSW_EU_ECALL_TYPE_TEST)
772 {
773 //AT+CECALL =0
774 ecall_type = MBTK_ECALL_DIAL_TYPE_TEST;
775 snprintf(tmp_number,sizeof(tmp_number),"%s",p_info->ecall_number);
hong.liud2417072025-06-27 07:10:37 -0700776 strncpy((char *)only_info.test_num,tmp_number,RIL_MAX_NUMBER_LEN-1);
777 only_info.test_num[RIL_MAX_NUMBER_LEN-1]='\0';
b.liu68a94c92025-05-24 12:53:41 +0800778 //snprintf((char*)only_info.test_num,sizeof(only_info.test_num),"%s",p_info->ecall_number);
779 }
780
781 if(p_info->type == GSW_EU_ECALL_TYPE_RECONFIG )
782 {
783 //AT+CECALL =1
784 ecall_type = MBTK_ECALL_DIAL_TYPE_RECONFIG;
785 snprintf(tmp_number,sizeof(tmp_number),"%s",p_info->ecall_number);
hong.liud2417072025-06-27 07:10:37 -0700786 strncpy((char *)only_info.test_num,tmp_number,RIL_MAX_NUMBER_LEN-1);
787 only_info.test_num[RIL_MAX_NUMBER_LEN-1]='\0';
b.liu68a94c92025-05-24 12:53:41 +0800788 }
789
790 if(p_info->type == GSW_EU_ECALL_TYPE_EMERGENCY )
791 {
792 if(p_info->auto_trigger)
793 {
794 //AT+CECALL =1
795 ecall_type = MBTK_ECALL_DIAL_TYPE_AUTO;
796 }
797 else
798 {
799 //AT+CECALL =1
800 ecall_type = MBTK_ECALL_DIAL_TYPE_MANUALLY;//手动
801 }
802
803 }
804
805 //msd
806 for (int i = 0; i < p_info->msd_len; i++)
807 {
808 sprintf(msd_data + (i * 2), "%02x", p_info->msd[i]);
809 }
810
811 //
812 only_info.active = MBTK_ECALL_ONLY_TYPE_DISABLE ;
813
814 ret=mbtk_ecall_only_set_ptr(ecall_info_handle,&only_info);
815 if (ret != 0)
816 {
817 LOGE("mbtk_ecall_only_set_success failed");
l.yang2678d6f2025-05-28 03:58:49 -0700818 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800819 }
820
821 //set msd
822 ret= mbtk_ecall_msd_set_ptr(ecall_info_handle,(const void*)msd_data);
823 if (ret != 0)
824 {
825 LOGE("mbtk_ecall_msd_set_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -0700826 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800827 }
828
829 //dial
830 ret= mbtk_ecall_dial_start_ptr(ecall_info_handle,ecall_type);
831 if (ret != 0)
832 {
833 LOGE("mbtk_ecall_dial_start_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -0700834 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800835 }
836
837 //push mst
838 ret= mbtk_ecall_push_ptr(ecall_info_handle);
839 if (ret != 0)
840 {
841 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_FAILURE;
842 mbtk_send_singnal();
843 LOGE("mbtk_ecall_push_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -0700844 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800845 }
846
847 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_SUCCESS;
848 mbtk_send_singnal();
849 return GSW_HAL_SUCCESS;
850
851}
852
853
854/**
855* @brief hangup a Europe Ecall
856* @param [in] None
857* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700858* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800859*/
860int32_t gsw_eu_ecall_hangup(void)
861{
862 int32_t ret = -1;
863 if(ecall_info_handle == NULL)
864 {
l.yang2678d6f2025-05-28 03:58:49 -0700865 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800866 }
867
868 ret = mbtk_ecall_dial_start_ptr(ecall_info_handle,MBTK_ECALL_DIAL_TYPE_RELEASE);
869 if(ret != 0)
870 {
871 LOGE("hangup ecall faile ");
l.yang2678d6f2025-05-28 03:58:49 -0700872 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800873 }
874
875 return GSW_HAL_SUCCESS;
876}
877
878/**
879* @brief using push mode send msd data
880* @param [in] GSW_EU_ECALL_STATE_E state: ecall state
881* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700882* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800883*/
884
885int32_t gsw_eu_ecall_updateMsd(const uint8_t *msd, uint32_t msd_len)
886{
887 int ret = -1;
888 char msd_data[500] = {0};
889
890 if(msd == NULL || msd_len == 0 ||ecall_info_handle == NULL)
891 {
hong.liud2417072025-06-27 07:10:37 -0700892 return GSW_HAL_NO_MEMORY;
b.liu68a94c92025-05-24 12:53:41 +0800893 }
894
895 //msd
896 for (int i = 0; i < msd_len; i++)
897 {
898 sprintf(msd_data + i * 2, "%02x", *(msd + i));
899 }
900 ret = mbtk_ecall_msd_set_ptr(ecall_info_handle,(const void*)msd_data);
901 if (ret != 0)
902 {
903 LOGE("mbtk_ecall_msd_get_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -0700904 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800905 }
906 return GSW_HAL_SUCCESS;
907
908}
909
910
911int32_t gsw_eu_ecall_pushMsd(gsw_eu_ecall_state_e state)
912{
913 int ret = -1;
914 if(ecall_info_handle == NULL)
915 {
l.yang2678d6f2025-05-28 03:58:49 -0700916 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800917 }
918
919 ret = mbtk_ecall_push_ptr(ecall_info_handle);
920 if(ret != 0)
921 {
922 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_FAILURE;
923 mbtk_send_singnal();
l.yang2678d6f2025-05-28 03:58:49 -0700924 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800925 }
926 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_SUCCESS;
927 mbtk_send_singnal();
928 return GSW_HAL_SUCCESS;
929
930
931}
932
933/**
934* @brief get ecall config
935* @param [in] None
936* @param [out] gsw_eu_ecall_config_t *p_config: ecall config
hong.liud2417072025-06-27 07:10:37 -0700937* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800938*/
939int32_t gsw_eu_ecall_getConfig(gsw_eu_ecall_config_t *p_config)
940{
941
942 if(ecall_info_handle==NULL || p_config == NULL)
943 {
944 LOGE("mbtk_ecall_cfg_get() fail.");
hong.liud2417072025-06-27 07:10:37 -0700945 return GSW_HAL_NO_MEMORY;
b.liu68a94c92025-05-24 12:53:41 +0800946 }
947
948 p_config->fail_redial = fail_redial;
949
950 return GSW_HAL_SUCCESS;
951}
952
953/**
954* @brief set ecall config
955* @param [in] int32_t item: config item
956* @param [in] gsw_eu_ecall_config_t *p_config: config info
957* @param [out] None
hong.liud2417072025-06-27 07:10:37 -0700958* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +0800959*/
960
961int32_t gsw_eu_ecall_setConfig(int32_t item, gsw_eu_ecall_config_t *p_config)
962{
963 if(ecall_info_handle == NULL || p_config == NULL)
964 {
965 LOGE("gsw_eu_ecall_setConfig no init");
hong.liud2417072025-06-27 07:10:37 -0700966 return GSW_HAL_NO_MEMORY;
b.liu68a94c92025-05-24 12:53:41 +0800967 }
968
969 mbtk_ecall_cfg_info_t cfg_info = {0};
970
971 int ret =-1;
972 cfg_info.type = 0;
973
974 if(item & GSW_EU_ECALL_CONFIG_FAIL_REDIAL)
975 {
976 fail_redial = p_config->fail_redial;
977 if(p_config->fail_redial)
978 {
979 cfg_info.type |= MBTK_ECALL_CFG_TIMER_DIAL;
980 cfg_info.data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] = 60000;//timer 60s
981
982 }
983 else
984 {
985 cfg_info.type |= MBTK_ECALL_CFG_TIMER_DIAL;
986 cfg_info.data[MBTK_ECALL_CFG_ITEM_TIMER_DIAL] = 0;
987 }
988 }
989
990 ret = mbtk_ecall_cfg_set_ptr(ecall_info_handle, &cfg_info);
991 if (ret < 0)
992 {
993 LOGE("mbtk_ecall_cfg_set_ptr fail");
l.yang2678d6f2025-05-28 03:58:49 -0700994 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +0800995 }
996 return GSW_HAL_SUCCESS;
997
998}
999
1000
1001
1002static void mbtk_ecall_state_change_cb(const void* data, int data_len)
1003{
1004 static gsw_eu_ecall_event_t event;
1005 if(data)
1006 {
1007 mbtk_ril_ecall_state_info_t *ecall_data = (mbtk_ril_ecall_state_info_t*)data;
1008 switch(ecall_data->urc_id)
1009 {
1010 case MBTK_ECALL_URC_ID_MSD_REQ:
1011 {
1012 LOGD("MBTK_ECALL_URC_ID_MSD_REQ");
1013 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_START_RECEIVED_MSD;
1014 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPDATE_PSAP_REQURE_UPDATE_MSD;
1015 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
1016 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_NONE;
1017 break;
1018 }
1019 case MBTK_ECALL_URC_ID_MSD_SEND_START:
1020 {
1021 LOGD("MBTK_ECALL_URC_ID_MSD_SEND_START");
1022
1023 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_START_RECEIVED_MSD;
1024 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPDATE_PSAP_REQURE_UPDATE_MSD;
1025 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
1026 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_NONE;
1027 break;
1028 }
1029 case MBTK_ECALL_URC_ID_NACK:
1030 {
1031 LOGD("MBTK_ECALL_URC_ID_NACK");
1032
1033 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_NACK_RECEIVED;
1034 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPADTE_NONE;
1035 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
1036 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_NONE;
1037 break;
1038 }
1039 case MBTK_ECALL_URC_ID_LLACK:
1040 {
1041 LOGD("MBTK_ECALL_URC_ID_LLACK");
1042
1043 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_ACK_RECEIVED;
1044 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPADTE_NONE;
1045 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_IVS_LLACK_RECEIVED;
1046 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_SUCCESS;
1047 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_SUCCESS;
1048 mbtk_send_singnal();
1049 break;
1050 }
1051 case MBTK_ECALL_URC_ID_HLACK:
1052 {
1053 LOGD("MBTK_ECALL_URC_ID_HLACK");
1054 event.fail = GSW_EU_ECALL_EVENT_FAIL_NONE;
1055 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_HLACK_RECEIVED;
1056
1057 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPADTE_NONE;
1058 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
1059 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_SUCCESS;
1060 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_SUCCESS;
1061 mbtk_send_singnal();
1062 break;
1063 }
1064 case MBTK_ECALL_URC_ID_ALACK:
1065 {
1066 LOGD("MBTK_ECALL_URC_ID_ALACK");
1067 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_IVS_ALACK_RECEIVED;
1068 }
1069 case MBTK_ECALL_URC_ID_MSD_UPDATE_DONE:
1070 {
1071 LOGD("MBTK_ECALL_URC_ID_MSD_UPDATE_DONE");
1072 event.process = GSW_EU_ECALL_EVENT_PROCESS_IVS_NONE;
1073 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPADTE_NONE;
1074 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
1075 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_SUCCESS;
1076
1077 }
1078 case MBTK_ECALL_URC_ID_T5_EXPIRED:
1079 case MBTK_ECALL_URC_ID_T6_EXPIRED:
1080 case MBTK_ECALL_URC_ID_T7_EXPIRED:
1081 {
1082 LOGD("MBTK_ECALL_URC_ID_T5_EXPIRED | MBTK_ECALL_URC_ID_T5_EXPIRED | MBTK_ECALL_URC_ID_T7_EXPIRED");
1083 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPDATE_IVS_UPDATE_MSD_TIMEOUT;
1084 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
1085 event.establish = GSW_EU_ECALL_EVENT_ESTABLISH_SUCCESS;
1086 g_msd_send_status = GSW_EU_ECALL_MSD_TRANS_STATUS_FAILURE;
1087 mbtk_send_singnal();
1088 break;
1089 }
1090 case MBTK_ECALL_URC_ID_3GPP_FATAL:
1091 case MBTK_ECALL_URC_ID_GENERIC:
1092 {
1093 LOGD("MBTK_ECALL_URC_ID_GENERIC|MBTK_ECALL_URC_ID_3GPP_FATAL");
1094 event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
1095 }
1096 case MBTK_ECALL_URC_ID_MSD_UPDATE_ERR:
1097 {
1098 LOGD("MBTK_ECALL_URC_ID_MSD_UPDATE_ERR");
1099 event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPDATE_IVS_UPDATE_MSD_TIMEOUT;
1100
1101 }
1102 default:
1103 {
1104
1105 LOGE("No process urc_id : %d", ecall_data->urc_id);
1106 break;
1107 }
1108 }
1109
1110 }
1111 if(gsw_eu_ecall_event_cb)
1112 {
1113 gsw_eu_ecall_event_cb(&event);
1114 }
1115}
1116
1117
1118/**
1119 * @brief register the ecall status callback
1120* @param [in] gsw_eu_ecall_status_cb_f cb:callback
1121* @param [out] None
hong.liud2417072025-06-27 07:10:37 -07001122* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +08001123*/
1124int32_t gsw_eu_ecall_setEventCB(gsw_eu_ecall_event_cb_f cb)
1125{
1126 int ret = -1;
1127 if(ecall_info_handle==NULL)
1128 {
hong.liud2417072025-06-27 07:10:37 -07001129 return GSW_HAL_NO_MEMORY;
b.liu68a94c92025-05-24 12:53:41 +08001130 }
1131
1132 gsw_eu_ecall_event_cb = cb;
1133 if(!g_setevent_cb)
1134 {
1135 ret = mbtk_ecall_state_change_cb_reg_ptr(ecall_info_handle, mbtk_ecall_state_change_cb);
1136 if(ret < 0)
1137 {
1138
1139 LOGE("mbtk_ecall_state_change_cb_reg_ptr failed");
l.yang2678d6f2025-05-28 03:58:49 -07001140 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +08001141 }
1142 g_setevent_cb = true;
1143 }
1144
1145 return GSW_HAL_SUCCESS;
1146
1147}
1148
1149
1150
1151static void* ecall_msd_status_cb_thread(void* arg)
1152{
1153 while(g_thread_running)
1154 {
1155 mbtk_wait_signal();
1156 if(g_thread_running == false)
1157 {
1158 return NULL;
1159 }
1160 if(gsw_eu_ecall_status_cb)
1161 {
1162 gsw_eu_ecall_status_cb(g_sta_cb_id,g_msd_send_status);
1163 }
1164
1165 }
1166 return NULL;
1167}
1168
1169/**
1170* @brief register the ecall status callback
1171* @param [in] gsw_eu_ecall_status_cb_f cb:callback
1172* @param [out] None
hong.liud2417072025-06-27 07:10:37 -07001173* @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
b.liu68a94c92025-05-24 12:53:41 +08001174*/
1175int32_t gsw_eu_ecall_setStatusCB(gsw_eu_ecall_status_cb_f cb)
1176{
1177 int ret = -1;
1178 if(ecall_info_handle==NULL)
1179 {
l.yang2678d6f2025-05-28 03:58:49 -07001180 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +08001181 }
1182 gsw_eu_ecall_status_cb = cb;
1183 if (!g_thread_running)
1184 {
1185 ret = pthread_create(&gsw_ecall_status_cb_thread, NULL, ecall_msd_status_cb_thread, NULL);
1186 if(ret < 0)
1187 {
1188 LOGE("pthread_create failed");
1189 g_thread_running = false;
l.yang2678d6f2025-05-28 03:58:49 -07001190 return GSW_HAL_NORMAL_FAIL;
b.liu68a94c92025-05-24 12:53:41 +08001191 }
1192 g_thread_running = true;
1193 }
1194
1195 return GSW_HAL_SUCCESS;
1196
1197}