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"
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 15 |
|
| 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.yang | 6a42e4d | 2025-05-28 01:04:20 -0700 | [diff] [blame] | 35 | #define GSW_ECALL "[HAL][GSW_ECALL]"
|
| 36 |
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 37 | #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.yang | 6a42e4d | 2025-05-28 01:04:20 -0700 | [diff] [blame] | 48 | fun_ptr_log(LOG_VERBOSE_LEVEL, "%s#%s: "GSW_ECALL"" fmt, ptr_1001 + 1, line_1001, ##args); \
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 49 | } 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.yang | 6a42e4d | 2025-05-28 01:04:20 -0700 | [diff] [blame] | 62 | fun_ptr_log(LOG_INFO_LEVEL, "%s#%s: "GSW_ECALL"" fmt, ptr_1001 + 1, line_1001, ##args); \
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 63 | } 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.yang | 6a42e4d | 2025-05-28 01:04:20 -0700 | [diff] [blame] | 76 | fun_ptr_log(LOG_DEBUG_LEVEL, "%s#%s: "GSW_ECALL"" fmt, ptr_1001 + 1, line_1001, ##args); \
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 77 | } 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.yang | 6a42e4d | 2025-05-28 01:04:20 -0700 | [diff] [blame] | 90 | fun_ptr_log(LOG_WARN_LEVEL, "%s#%s: "GSW_ECALL"" fmt, ptr_1001 + 1, line_1001, ##args); \
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 91 | } 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.yang | 6a42e4d | 2025-05-28 01:04:20 -0700 | [diff] [blame] | 104 | fun_ptr_log(LOG_ERR_LEVEL, "%s#%s: "GSW_ECALL"" fmt, ptr_1001 + 1, line_1001, ##args); \
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 105 | } while(0)
|
| 106 |
|
| 107 | typedef void (*mbtk_log)(int level, const char *format,...);
|
| 108 |
|
| 109 |
|
| 110 | typedef unsigned int uint32;
|
| 111 | typedef unsigned char uint8;
|
| 112 | typedef unsigned short uint16;
|
| 113 |
|
| 114 | typedef 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 |
|
| 155 | typedef enum {
|
| 156 | MBTK_CLCC = 1,
|
| 157 | MBTK_CPAS,
|
| 158 | MBTK_DISCONNECTED,
|
| 159 | } mbtk_call_enum;
|
| 160 |
|
| 161 | typedef 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 |
|
| 187 | typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
|
| 188 |
|
| 189 | typedef 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 |
|
| 219 | typedef 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 |
|
| 239 | typedef 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 |
|
| 259 | typedef 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 |
|
| 268 | typedef struct
|
| 269 | {
|
| 270 | mbtk_ecall_msd_item_enum item_type;
|
| 271 |
|
| 272 | uint8 data[64];
|
| 273 | } mbtk_ecall_msd_cfg_info_t;
|
| 274 |
|
| 275 | typedef 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 |
|
| 282 | typedef 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 |
|
| 289 | typedef enum {
|
| 290 | MBTK_ECALL_MODE_TYPE_EU = 0,
|
| 291 | MBTK_ECALL_MODE_TYPE_ERA
|
| 292 | } mbtk_ecall_mode_type_enum;
|
| 293 |
|
| 294 |
|
| 295 | typedef 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 |
|
| 304 | typedef 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 |
|
| 331 | typedef struct
|
| 332 | {
|
| 333 | uint8 urc_id;
|
| 334 | uint8 urc_data[5];
|
| 335 | } mbtk_ril_ecall_state_info_t;
|
| 336 |
|
| 337 |
|
| 338 | typedef mbtk_info_handle_t* (*mbtk_info_handle_get)(void);
|
| 339 | static mbtk_info_handle_get mbtk_info_handle_get_ptr = NULL;
|
| 340 |
|
| 341 | typedef int (*mbtk_info_handle_free)(mbtk_info_handle_t** handle);
|
| 342 | static mbtk_info_handle_free mbtk_info_handle_free_ptr = NULL;
|
| 343 |
|
| 344 | static gsw_eu_ecall_status_cb_f gsw_eu_ecall_status_cb;
|
| 345 |
|
| 346 | static pthread_t gsw_ecall_status_cb_thread;
|
| 347 | static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 348 | static pthread_cond_t g_cond = PTHREAD_COND_INITIALIZER;
|
| 349 | static bool g_thread_running = false;
|
| 350 |
|
| 351 | static uint32_t g_sta_cb_id = 0;
|
| 352 | static 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 |
|
| 361 | typedef int (*mbtk_ecall_msd_set)(mbtk_info_handle_t* handle, const void* msd);
|
| 362 | static mbtk_ecall_msd_set mbtk_ecall_msd_set_ptr = NULL;
|
| 363 |
|
| 364 | typedef int (*mbtk_ecall_push)(mbtk_info_handle_t* handle);
|
| 365 | static mbtk_ecall_push mbtk_ecall_push_ptr = NULL;
|
| 366 |
|
| 367 | typedef int (*mbtk_ecall_only_set)(mbtk_info_handle_t* handle, const mbtk_ecall_only_info_t* info);
|
| 368 | static mbtk_ecall_only_set mbtk_ecall_only_set_ptr = NULL;
|
| 369 |
|
| 370 |
|
| 371 | typedef int (*mbtk_ecall_reg_set)(mbtk_info_handle_t* handle, int reg);
|
| 372 | static mbtk_ecall_reg_set mbtk_ecall_reg_set_ptr = NULL;
|
| 373 |
|
| 374 | typedef int (*mbtk_ecall_dial_start)(mbtk_info_handle_t* handle, mbtk_ecall_dial_type_enum type);
|
| 375 | static mbtk_ecall_dial_start mbtk_ecall_dial_start_ptr = NULL;
|
| 376 |
|
| 377 | typedef int (*mbtk_ecall_mode_set)(mbtk_info_handle_t* handle, mbtk_ecall_mode_type_enum mode);
|
| 378 | static mbtk_ecall_mode_set mbtk_ecall_mode_set_ptr = NULL;
|
| 379 |
|
| 380 |
|
| 381 | typedef int (*mbtk_ecall_cfg_set)(mbtk_info_handle_t* handle, const mbtk_ecall_cfg_info_t *cfg);
|
| 382 | static mbtk_ecall_cfg_set mbtk_ecall_cfg_set_ptr = NULL;
|
| 383 |
|
| 384 | typedef int (*mbtk_ecall_cfg_get)(mbtk_info_handle_t* handle, mbtk_ecall_cfg_info_t* cfg);
|
| 385 | static mbtk_ecall_cfg_get mbtk_ecall_cfg_get_ptr = NULL;
|
| 386 |
|
| 387 | typedef int (*mbtk_ecall_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
|
| 388 | static mbtk_ecall_state_change_cb_reg mbtk_ecall_state_change_cb_reg_ptr = NULL;
|
| 389 |
|
| 390 | typedef int (*mbtk_call_state_change_cb_reg)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb);
|
| 391 | static mbtk_call_state_change_cb_reg mbtk_call_state_change_cb_reg_ptr = NULL;
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 | static int state_t = -1;
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 | typedef 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 |
|
| 418 | typedef void (*mbtk_log_init)(char *path, char *tag);
|
| 419 | static mbtk_log_init mbtk_log_init_ptr = NULL;
|
| 420 |
|
| 421 | static void *handle = NULL;
|
| 422 | typedef void (*mbtk_log)(int level, const char *format,...);
|
| 423 | static mbtk_log fun_ptr_log = NULL;
|
| 424 | static int ecall_init_flag = 0;
|
| 425 | static mbtk_info_handle_t* ecall_info_handle = NULL;
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 | static uint8_t fail_redial = 1;
|
| 430 |
|
| 431 | static gsw_eu_ecall_event_cb_f gsw_eu_ecall_event_cb = NULL;
|
| 432 | static bool g_setevent_cb = false;
|
| 433 |
|
| 434 | static 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 |
|
| 442 | static 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 |
|
| 450 | static 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 |
|
| 475 | static int mbtk_ecall_api_import()
|
| 476 | {
|
| 477 | handle = dlopen(LIB_PATH, RTLD_NOW);
|
| 478 | if (handle == NULL)
|
| 479 | {
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 480 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 481 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 488 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 489 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 497 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 498 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 506 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 507 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 515 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 516 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 526 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 527 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 535 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 536 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 543 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 544 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 552 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 553 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 560 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 561 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 569 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 570 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 578 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 579 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 586 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 587 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 594 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 595 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 603 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 604 | }
|
| 605 | }
|
| 606 |
|
| 607 | return GSW_HAL_SUCCESS;
|
| 608 | }
|
| 609 |
|
| 610 |
|
| 611 | static 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 667 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 668 | */
|
| 669 |
|
| 670 | int32_t gsw_eu_ecall_voice_init(void)
|
| 671 | {
|
| 672 | int ret =-1;
|
| 673 | ret = mbtk_ecall_api_import();
|
| 674 | if(ret <0)
|
| 675 | {
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 676 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 677 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 685 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 686 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 696 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 697 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 707 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 708 | */
|
| 709 | int32_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.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 | 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 745 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 746 | */
|
| 747 | int32_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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 762 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 763 | }
|
| 764 |
|
| 765 | if(p_info == NULL || p_info->msd_len > GSW_EU_ECALL_MAX_MSD )
|
| 766 | {
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 767 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 768 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 776 | 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.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 778 | //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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 786 | 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.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 788 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 818 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 819 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 826 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 827 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 834 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 835 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 844 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 845 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 858 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 859 | */
|
| 860 | int32_t gsw_eu_ecall_hangup(void)
|
| 861 | {
|
| 862 | int32_t ret = -1;
|
| 863 | if(ecall_info_handle == NULL)
|
| 864 | {
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 865 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 866 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 872 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 873 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 882 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 883 | */
|
| 884 |
|
| 885 | int32_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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 892 | return GSW_HAL_NO_MEMORY;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 893 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 904 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 905 | }
|
| 906 | return GSW_HAL_SUCCESS;
|
| 907 |
|
| 908 | }
|
| 909 |
|
| 910 |
|
| 911 | int32_t gsw_eu_ecall_pushMsd(gsw_eu_ecall_state_e state)
|
| 912 | {
|
| 913 | int ret = -1;
|
| 914 | if(ecall_info_handle == NULL)
|
| 915 | {
|
l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 916 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 917 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 924 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 925 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 937 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 938 | */
|
| 939 | int32_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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 945 | return GSW_HAL_NO_MEMORY;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 946 | }
|
| 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 958 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 959 | */
|
| 960 |
|
| 961 | int32_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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 966 | return GSW_HAL_NO_MEMORY;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 967 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 994 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 995 | }
|
| 996 | return GSW_HAL_SUCCESS;
|
| 997 |
|
| 998 | }
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 | static 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1122 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1123 | */
|
| 1124 | int32_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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1129 | return GSW_HAL_NO_MEMORY;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1130 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 1140 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1141 | }
|
| 1142 | g_setevent_cb = true;
|
| 1143 | }
|
| 1144 |
|
| 1145 | return GSW_HAL_SUCCESS;
|
| 1146 |
|
| 1147 | }
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 | static 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.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 1173 | * @retval GSW_HAL_SUCCESS\GSW_HAL_NORMAL_FAIL
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1174 | */
|
| 1175 | int32_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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 1180 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1181 | }
|
| 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.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 1190 | return GSW_HAL_NORMAL_FAIL;
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1191 | }
|
| 1192 | g_thread_running = true;
|
| 1193 | }
|
| 1194 |
|
| 1195 | return GSW_HAL_SUCCESS;
|
| 1196 |
|
| 1197 | }
|