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 <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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 14 | #include "gsw_eu_ecall_interface.h"
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 15 | #include "gsw_log_interface.h"
|
| 16 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 17 |
|
| 18 | #define RIL_MAX_NUMBER_LEN 40
|
| 19 | #define MBTK_ECALL_MSD_LEN_MAX 600
|
| 20 |
|
l.yang | 6a42e4d | 2025-05-28 01:04:20 -0700 | [diff] [blame] | 21 | #define GSW_ECALL "[HAL][GSW_ECALL]"
|
| 22 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 23 | typedef unsigned int uint32;
|
| 24 | typedef unsigned char uint8;
|
| 25 | typedef unsigned short uint16;
|
| 26 |
|
| 27 | typedef 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 |
|
| 68 | typedef enum {
|
| 69 | MBTK_CLCC = 1,
|
| 70 | MBTK_CPAS,
|
| 71 | MBTK_DISCONNECTED,
|
| 72 | } mbtk_call_enum;
|
| 73 |
|
| 74 | typedef 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 |
|
| 100 | typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
|
| 101 |
|
| 102 | typedef 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 |
|
| 132 | typedef 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 |
|
| 152 | typedef 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 |
|
| 172 | typedef 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 |
|
| 181 | typedef struct
|
| 182 | {
|
| 183 | mbtk_ecall_msd_item_enum item_type;
|
| 184 |
|
| 185 | uint8 data[64];
|
| 186 | } mbtk_ecall_msd_cfg_info_t;
|
| 187 |
|
| 188 | typedef 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 |
|
| 195 | typedef 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 |
|
| 202 | typedef enum {
|
| 203 | MBTK_ECALL_MODE_TYPE_EU = 0,
|
| 204 | MBTK_ECALL_MODE_TYPE_ERA
|
| 205 | } mbtk_ecall_mode_type_enum;
|
| 206 |
|
| 207 |
|
| 208 | typedef 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 |
|
| 217 | typedef 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 |
|
| 244 | typedef struct
|
| 245 | {
|
| 246 | uint8 urc_id;
|
| 247 | uint8 urc_data[5];
|
| 248 | } mbtk_ril_ecall_state_info_t;
|
| 249 |
|
| 250 |
|
| 251 | typedef mbtk_info_handle_t* (*mbtk_info_handle_get)(void);
|
| 252 | static mbtk_info_handle_get mbtk_info_handle_get_ptr = NULL;
|
| 253 |
|
| 254 | typedef int (*mbtk_info_handle_free)(mbtk_info_handle_t** handle);
|
| 255 | static mbtk_info_handle_free mbtk_info_handle_free_ptr = NULL;
|
| 256 |
|
| 257 | static gsw_eu_ecall_status_cb_f gsw_eu_ecall_status_cb;
|
| 258 |
|
| 259 | static pthread_t gsw_ecall_status_cb_thread;
|
| 260 | static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 261 | static pthread_cond_t g_cond = PTHREAD_COND_INITIALIZER;
|
| 262 | static bool g_thread_running = false;
|
| 263 |
|
| 264 | static uint32_t g_sta_cb_id = 0;
|
| 265 | static 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 |
|
| 274 | typedef int (*mbtk_ecall_msd_set)(mbtk_info_handle_t* handle, const void* msd);
|
| 275 | static mbtk_ecall_msd_set mbtk_ecall_msd_set_ptr = NULL;
|
| 276 |
|
| 277 | typedef int (*mbtk_ecall_push)(mbtk_info_handle_t* handle);
|
| 278 | static mbtk_ecall_push mbtk_ecall_push_ptr = NULL;
|
| 279 |
|
| 280 | typedef int (*mbtk_ecall_only_set)(mbtk_info_handle_t* handle, const mbtk_ecall_only_info_t* info);
|
| 281 | static mbtk_ecall_only_set mbtk_ecall_only_set_ptr = NULL;
|
| 282 |
|
| 283 |
|
| 284 | typedef int (*mbtk_ecall_reg_set)(mbtk_info_handle_t* handle, int reg);
|
| 285 | static mbtk_ecall_reg_set mbtk_ecall_reg_set_ptr = NULL;
|
| 286 |
|
| 287 | typedef int (*mbtk_ecall_dial_start)(mbtk_info_handle_t* handle, mbtk_ecall_dial_type_enum type);
|
| 288 | static mbtk_ecall_dial_start mbtk_ecall_dial_start_ptr = NULL;
|
| 289 |
|
| 290 | typedef int (*mbtk_ecall_mode_set)(mbtk_info_handle_t* handle, mbtk_ecall_mode_type_enum mode);
|
| 291 | static mbtk_ecall_mode_set mbtk_ecall_mode_set_ptr = NULL;
|
| 292 |
|
| 293 |
|
| 294 | typedef int (*mbtk_ecall_cfg_set)(mbtk_info_handle_t* handle, const mbtk_ecall_cfg_info_t *cfg);
|
| 295 | static mbtk_ecall_cfg_set mbtk_ecall_cfg_set_ptr = NULL;
|
| 296 |
|
| 297 | typedef int (*mbtk_ecall_cfg_get)(mbtk_info_handle_t* handle, mbtk_ecall_cfg_info_t* cfg);
|
| 298 | static mbtk_ecall_cfg_get mbtk_ecall_cfg_get_ptr = NULL;
|
| 299 |
|
| 300 | typedef int (*mbtk_ecall_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
|
| 301 | static mbtk_ecall_state_change_cb_reg mbtk_ecall_state_change_cb_reg_ptr = NULL;
|
| 302 |
|
| 303 | typedef int (*mbtk_call_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
|
| 304 | static mbtk_call_state_change_cb_reg mbtk_call_state_change_cb_reg_ptr = NULL;
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 | static int state_t = -1;
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 | typedef 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 331 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 332 |
|
| 333 | static void *handle = NULL;
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 334 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 335 | static int ecall_init_flag = 0;
|
| 336 | static mbtk_info_handle_t* ecall_info_handle = NULL;
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 | static uint8_t fail_redial = 1;
|
| 341 |
|
| 342 | static gsw_eu_ecall_event_cb_f gsw_eu_ecall_event_cb = NULL;
|
| 343 | static bool g_setevent_cb = false;
|
| 344 |
|
| 345 | static 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 |
|
| 353 | static 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 |
|
| 361 | static void mbtk_ecall_api_ptr_deinit()
|
| 362 | {
|
| 363 | dlclose(handle);
|
| 364 | handle = NULL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 365 | 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.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 380 |
|
| 381 | }
|
| 382 |
|
| 383 |
|
| 384 | static int mbtk_ecall_api_import()
|
| 385 | {
|
| 386 | handle = dlopen(LIB_PATH, RTLD_NOW);
|
| 387 | if (handle == NULL)
|
| 388 | {
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 389 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 390 | }
|
| 391 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 392 | 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 397 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 398 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 406 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 407 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 417 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 418 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 426 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 427 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 434 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 435 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 443 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 444 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 451 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 452 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 460 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 461 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 469 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 470 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 477 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 478 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 485 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 486 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 494 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 495 | }
|
| 496 | }
|
| 497 |
|
| 498 | return GSW_HAL_SUCCESS;
|
| 499 | }
|
| 500 |
|
| 501 |
|
| 502 | static 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 509 | 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.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 510 | switch(reg->state)
|
| 511 | {
|
| 512 | case 0:
|
| 513 | state_t = 0;
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 514 | LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_CONNECTED ");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 515 | break;
|
| 516 | case 1:
|
| 517 | //state_t = GSW_VOICE_CALL_HOLDING;
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 518 | LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_HOLDING ");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 519 | break;
|
| 520 | case 2:
|
| 521 | //state_t = GSW_VOICE_CALL_DIALING;
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 522 | LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_DIALING ");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 523 | break;
|
| 524 | case 3:
|
| 525 | //state_t = GSW_VOICE_CALL_ALERTING;
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 526 | LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_ALERTING ");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 527 | break;
|
| 528 | case 4:
|
| 529 | //state_t = GSW_VOICE_CALL_INCOMING;
|
| 530 |
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 531 | LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_INCOMING ");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 532 | break;
|
| 533 | case 5:
|
| 534 | //state_t = GSW_VOICE_CALL_WAITING;
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 535 | LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_WAITING ");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 536 | break;
|
| 537 | case 6:
|
| 538 | //state_t = GSW_VOICE_CALL_END;
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 539 | LOGD(GSW_ECALL,"reg->state = GSW_VOICE_CALL_END ");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 540 | break;
|
| 541 | }
|
| 542 |
|
| 543 | g_sta_cb_id = reg->dir1;
|
| 544 | }
|
| 545 |
|
| 546 | break;
|
| 547 | default:
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 548 | LOGE(GSW_ECALL,"RING : None call_wait = %d", reg->call_wait);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 549 | break;
|
| 550 | }
|
| 551 | }
|
| 552 |
|
| 553 |
|
| 554 | /**
|
| 555 | * @brief init the Europe Ecall voice
|
| 556 | * @param [in] None
|
| 557 | * @param [out] None
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 558 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 559 | */
|
| 560 |
|
| 561 | int32_t gsw_eu_ecall_voice_init(void)
|
| 562 | {
|
| 563 | int ret =-1;
|
| 564 | ret = mbtk_ecall_api_import();
|
| 565 | if(ret <0)
|
| 566 | {
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 567 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 568 | }
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 569 |
|
| 570 | ecall_info_handle = mbtk_info_handle_get_ptr();
|
| 571 | if(ecall_info_handle == NULL)
|
| 572 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 573 | LOGE(GSW_ECALL,"mbtk_info_handle_get_ptr fail!!!");
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 574 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 575 | }
|
| 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 584 | LOGE(GSW_ECALL,"mbtk_call_state_change_cb_reg_ptr failed");
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 585 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 586 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 596 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 597 | */
|
| 598 | int32_t gsw_eu_ecall_voice_deinit(void)
|
| 599 | {
|
| 600 | int ret = -1;
|
| 601 | if(ecall_info_handle == NULL || ecall_init_flag ==0)
|
| 602 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 603 | LOGE(GSW_ECALL,"No init can not deinit");
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 604 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 605 | }
|
| 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 619 | LOGE(GSW_ECALL,"mbtk_info_handle_free handle faile");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 620 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 634 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 635 | */
|
| 636 | int32_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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 651 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 652 | }
|
| 653 |
|
| 654 | if(p_info == NULL || p_info->msd_len > GSW_EU_ECALL_MAX_MSD )
|
| 655 | {
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 656 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 657 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 665 | 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.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 667 | //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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 675 | 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.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 677 | }
|
| 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 706 | LOGE(GSW_ECALL,"mbtk_ecall_only_set_success failed");
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 707 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 708 | }
|
| 709 |
|
| 710 | //set msd
|
| 711 | ret= mbtk_ecall_msd_set_ptr(ecall_info_handle,(const void*)msd_data);
|
| 712 | if (ret != 0)
|
| 713 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 714 | LOGE(GSW_ECALL,"mbtk_ecall_msd_set_ptr failed");
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 715 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 716 | }
|
| 717 |
|
| 718 | //dial
|
| 719 | ret= mbtk_ecall_dial_start_ptr(ecall_info_handle,ecall_type);
|
| 720 | if (ret != 0)
|
| 721 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 722 | LOGE(GSW_ECALL,"mbtk_ecall_dial_start_ptr failed");
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 723 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 724 | }
|
| 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 732 | LOGE(GSW_ECALL,"mbtk_ecall_push_ptr failed");
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 733 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 734 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 747 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 748 | */
|
| 749 | int32_t gsw_eu_ecall_hangup(void)
|
| 750 | {
|
| 751 | int32_t ret = -1;
|
| 752 | if(ecall_info_handle == NULL)
|
| 753 | {
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 754 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 755 | }
|
| 756 |
|
| 757 | ret = mbtk_ecall_dial_start_ptr(ecall_info_handle,MBTK_ECALL_DIAL_TYPE_RELEASE);
|
| 758 | if(ret != 0)
|
| 759 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 760 | LOGE(GSW_ECALL,"hangup ecall faile ");
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 761 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 762 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 771 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 772 | */
|
| 773 |
|
| 774 | int32_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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 781 | return GSW_HAL_NO_MEMORY;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 782 | }
|
| 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 792 | LOGE(GSW_ECALL,"mbtk_ecall_msd_get_ptr failed");
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 793 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 794 | }
|
| 795 | return GSW_HAL_SUCCESS;
|
| 796 |
|
| 797 | }
|
| 798 |
|
| 799 |
|
| 800 | int32_t gsw_eu_ecall_pushMsd(gsw_eu_ecall_state_e state)
|
| 801 | {
|
| 802 | int ret = -1;
|
| 803 | if(ecall_info_handle == NULL)
|
| 804 | {
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 805 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 806 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 813 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 814 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 826 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 827 | */
|
| 828 | int32_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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 833 | LOGE(GSW_ECALL,"mbtk_ecall_cfg_get() fail.");
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 834 | return GSW_HAL_NO_MEMORY;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 835 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 847 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 848 | */
|
| 849 |
|
| 850 | int32_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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 854 | LOGE(GSW_ECALL,"gsw_eu_ecall_setConfig no init");
|
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 855 | return GSW_HAL_NO_MEMORY;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 856 | }
|
| 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 882 | LOGE(GSW_ECALL,"mbtk_ecall_cfg_set_ptr fail");
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 883 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 884 | }
|
| 885 | return GSW_HAL_SUCCESS;
|
| 886 |
|
| 887 | }
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 | static 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 901 | LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_MSD_REQ");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 902 | 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 910 | LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_MSD_SEND_START");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 911 |
|
| 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 920 | LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_NACK");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 921 |
|
| 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 930 | LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_LLACK");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 931 |
|
| 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 942 | LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_HLACK");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 943 | 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 955 | LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_ALACK");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 956 | event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_IVS_ALACK_RECEIVED;
|
| 957 | }
|
| 958 | case MBTK_ECALL_URC_ID_MSD_UPDATE_DONE:
|
| 959 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 960 | LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_MSD_UPDATE_DONE");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 961 | 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 971 | LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_T5_EXPIRED | MBTK_ECALL_URC_ID_T5_EXPIRED | MBTK_ECALL_URC_ID_T7_EXPIRED");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 972 | 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 982 | LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_GENERIC|MBTK_ECALL_URC_ID_3GPP_FATAL");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 983 | event.extend_state = GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE;
|
| 984 | }
|
| 985 | case MBTK_ECALL_URC_ID_MSD_UPDATE_ERR:
|
| 986 | {
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 987 | LOGD(GSW_ECALL,"MBTK_ECALL_URC_ID_MSD_UPDATE_ERR");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 988 | event.msdupdate = GSW_EU_ECALL_EVENT_MSDUPDATE_IVS_UPDATE_MSD_TIMEOUT;
|
| 989 |
|
| 990 | }
|
| 991 | default:
|
| 992 | {
|
| 993 |
|
q.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 994 | LOGE(GSW_ECALL,"No process urc_id : %d", ecall_data->urc_id);
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 995 | 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1011 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1012 | */
|
| 1013 | int32_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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1018 | return GSW_HAL_NO_MEMORY;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1019 | }
|
| 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 1028 | LOGE(GSW_ECALL,"mbtk_ecall_state_change_cb_reg_ptr failed");
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 1029 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1030 | }
|
| 1031 | g_setevent_cb = true;
|
| 1032 | }
|
| 1033 |
|
| 1034 | return GSW_HAL_SUCCESS;
|
| 1035 |
|
| 1036 | }
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 | static 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1062 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1063 | */
|
| 1064 | int32_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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 1069 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1070 | }
|
| 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.huang | 6e4f473 | 2025-07-22 18:46:32 +0800 | [diff] [blame^] | 1077 | LOGE(GSW_ECALL,"pthread_create failed");
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1078 | g_thread_running = false;
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 1079 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1080 | }
|
| 1081 | g_thread_running = true;
|
| 1082 | }
|
| 1083 |
|
| 1084 | return GSW_HAL_SUCCESS;
|
| 1085 |
|
| 1086 | }
|