l.yang | 2678d6f | 2025-05-28 03:58:49 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @file : gsw_eu_ecall_interface.h |
| 3 | * @brief : Europe Ecall |
| 4 | * @date : 2023-10-23 |
| 5 | * @author : |
| 6 | * @version : v1.0 |
| 7 | * @copyright Copyright(C) 2023,Gosuncnwelink |
| 8 | */ |
| 9 | #ifndef __GSW_EU_ECALL_INTERFACE_H__ |
| 10 | #define __GSW_EU_ECALL_INTERFACE_H__ |
| 11 | |
| 12 | #include <stdint.h> |
| 13 | #include <stdbool.h> |
| 14 | #include "gsw_hal_errcode.h" |
| 15 | |
| 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif |
| 19 | |
| 20 | /*********************************************************************************************/ |
| 21 | |
| 22 | |
| 23 | #define GSW_EU_ECALL_MAX_MSD 140 |
| 24 | #define GSW_EU_ECALL_MAX_PHONE_NUMBER 82 |
| 25 | |
| 26 | typedef enum { |
| 27 | GSW_EU_ECALL_TYPE_TEST = 1, |
| 28 | GSW_EU_ECALL_TYPE_EMERGENCY = 2, |
| 29 | GSW_EU_ECALL_TYPE_RECONFIG = 3, |
| 30 | } gsw_eu_ecall_type_e; |
| 31 | |
| 32 | typedef enum { |
| 33 | GSW_EU_ECALL_STATE_NONE = -1, |
| 34 | GSW_EU_ECALL_STATE_INACTIVE = 0, |
| 35 | GSW_EU_ECALL_STATE_ORIGINATING_CALL = 1, |
| 36 | GSW_EU_ECALL_STATE_IN_CALL_TRANSMITTING = 2, |
| 37 | GSW_EU_ECALL_STATE_WAITING_FOR_AL_ACK = 3, |
| 38 | GSW_EU_ECALL_STATE_IN_CALL = 4, |
| 39 | GSW_EU_ECALL_STATE_IDLE_ALLOW_MT_ECALL = 5, |
| 40 | } gsw_eu_ecall_state_e; |
| 41 | |
| 42 | typedef enum { |
| 43 | GSW_EU_ECALL_MODE_NORMAL = 0, |
| 44 | GSW_EU_ECALL_MODE_ONLY = 1, |
| 45 | GSW_EU_ECALL_MODE_DEFAULT = 2, |
| 46 | } gsw_eu_ecall_mode_e; |
| 47 | |
| 48 | typedef enum { |
| 49 | GSW_EU_ECALL_CONFIG_ENABLE = (1 << 0), |
| 50 | GSW_EU_ECALL_CONFIG_VOICE_MUTE = (1 << 1), |
| 51 | GSW_EU_ECALL_CONFIG_MODE = (1 << 2), |
| 52 | GSW_EU_ECALL_CONFIG_REPORT_EVENT = (1 << 3), |
| 53 | GSW_EU_ECALL_CONFIG_START_TIMER = (1 << 4), |
| 54 | GSW_EU_ECALL_CONFIG_HACK_TIMER = (1 << 5), |
| 55 | GSW_EU_ECALL_CONFIG_TRANS_TIMER = (1 << 6), |
| 56 | GSW_EU_ECALL_CONFIG_FAIL_REDIAL = (1 << 7), |
| 57 | GSW_EU_ECALL_CONFIG_DROP_REDIAL = (1 << 8), |
| 58 | GSW_EU_ECALL_CONFIG_CLEARDOWN_TIMER = (1 << 9), |
| 59 | GSW_EU_ECALL_CONFIG_INIT_TIMER = (1 << 10), |
| 60 | GSW_EU_ECALL_CONFIG_NAD_REG_TIMER = (1 << 11), |
| 61 | GSW_EU_ECALL_CONFIG_NAD_DEREG_TIMER = (1 << 12), |
| 62 | GSW_EU_ECALL_CONFIG_STANDARD = (1 << 13), |
| 63 | GSW_EU_ECALL_CONFIG_ERA_GLONASS_REDIAL = (1 << 14), |
| 64 | GSW_EU_ECALL_CONFIG_AUTO_ANSWER = (1 << 15), |
| 65 | } gsw_eu_ecall_config_e; |
| 66 | |
| 67 | typedef enum { |
| 68 | GSW_EU_ECALL_EVENT_FAIL_NONE = 0, |
| 69 | GSW_EU_ECALL_EVENT_FAIL_TIMEOUT = 1, |
| 70 | GSW_EU_ECALL_EVENT_FAIL_HACK_TIMEOUT = 2, |
| 71 | GSW_EU_ECALL_EVENT_FAIL_MSD_TRANS_TIMEOUT = 3, |
| 72 | GSW_EU_ECALL_EVENT_FAIL_IVS_RESET_TIMEOUT = 4, |
| 73 | GSW_EU_ECALL_EVENT_FAIL_CLEAR_DOWN_FALLBACK_TIMEOUT = 5, |
| 74 | GSW_EU_ECALL_EVENT_FAIL_IVS_INITIATION_TIMEOUT = 6, |
| 75 | } gsw_eu_ecall_event_fail_e; |
| 76 | |
| 77 | typedef enum { |
| 78 | GSW_EU_ECALL_EVENT_PROCESS_IVS_NONE = 0, |
| 79 | GSW_EU_ECALL_EVENT_PROCESS_IVS_START_RECEIVED_MSD = 1, |
| 80 | GSW_EU_ECALL_EVENT_PROCESS_IVS_NACK_RECEIVED = 2, |
| 81 | GSW_EU_ECALL_EVENT_PROCESS_IVS_ACK_RECEIVED = 3, |
| 82 | GSW_EU_ECALL_EVENT_PROCESS_IVS_TX_COMPLETED = 4, |
| 83 | GSW_EU_ECALL_EVENT_PROCESS_IVS_HLACK_RECEIVED = 5, |
| 84 | } gsw_eu_ecall_event_process_e; |
| 85 | |
| 86 | typedef enum { |
| 87 | GSW_EU_ECALL_EVENT_MSDUPADTE_NONE = -1, |
| 88 | GSW_EU_ECALL_EVENT_MSDUPDATE_IVS_UPDATING_MSD = 0, |
| 89 | GSW_EU_ECALL_EVENT_MSDUPDATE_PSAP_REQURE_UPDATE_MSD = 1, |
| 90 | GSW_EU_ECALL_EVENT_MSDUPDATE_IVS_UPDATE_MSD_TIMEOUT = 2, |
| 91 | } gsw_eu_ecall_event_msdupdate_e; |
| 92 | |
| 93 | typedef enum { |
| 94 | GSW_EU_ECALL_EVENT_ESTABLISH_NONE = -1, |
| 95 | GSW_EU_ECALL_EVENT_ESTABLISH_SUCCESS = 0, |
| 96 | GSW_EU_ECALL_EVENT_ESTABLISH_FAIL = 1, |
| 97 | } gsw_eu_ecall_event_establish_e; |
| 98 | |
| 99 | typedef enum { |
| 100 | GSW_EU_ECALL_EVENT_EXTEND_STATE_NONE = -1, |
| 101 | GSW_EU_ECALL_EVENT_EXTEND_STATE_START_RECV_SYN = 0, |
| 102 | GSW_EU_ECALL_EVENT_EXTEND_STATE_T9_TIMEOUT = 1, |
| 103 | GSW_EU_ECALL_EVENT_EXTEND_STATE_T10_TIMEOUT = 2, |
| 104 | GSW_EU_ECALL_EVENT_EXTEND_STATE_IVS_ALACK_RECEIVED = 3, |
| 105 | GSW_EU_ECALL_EVENT_EXTEND_STATE_IVS_LLACK_RECEIVED = 4, |
| 106 | GSW_EU_ECALL_EVENT_EXTEND_STATE_STOPPED = 5, |
| 107 | GSW_EU_ECALL_EVENT_EXTEND_STATE_ANSWERING_INCOMING_PSAP_ECALL = 6, |
| 108 | GSW_EU_ECALL_EVENT_EXTEND_STATE_CLEARDOWN_RECEIVED = 7, |
| 109 | GSW_EU_ECALL_EVENT_EXTEND_STATE_CALLBACK_TIMEOUT = 8, |
| 110 | GSW_EU_ECALL_EVENT_IVS_NORMAL_CLEARING = 9, |
| 111 | GSW_EU_ECALL_EVENT_IVS_ABNORMAL_CLEARING = 10, |
| 112 | } gsw_eu_ecall_event_extend_state_e; |
| 113 | |
| 114 | typedef enum { |
| 115 | GSW_EU_ECALL_MSD_TRANS_STATUS_NONE = -1, |
| 116 | GSW_EU_ECALL_MSD_TRANS_STATUS_SUCCESS = 0, |
| 117 | GSW_EU_ECALL_MSD_TRANS_STATUS_FAILURE = 1, |
| 118 | } gsw_eu_ecall_msd_trans_status_e; |
| 119 | |
| 120 | typedef struct |
| 121 | { |
| 122 | uint32_t msd_len; |
| 123 | uint8_t msd[GSW_EU_ECALL_MAX_MSD]; |
| 124 | gsw_eu_ecall_type_e type; |
| 125 | int32_t auto_trigger; |
| 126 | char ecall_number[GSW_EU_ECALL_MAX_PHONE_NUMBER]; |
| 127 | } gsw_eu_ecall_info_t; |
| 128 | |
| 129 | typedef struct |
| 130 | { |
| 131 | uint8_t enable; |
| 132 | uint8_t voice_mute; |
| 133 | gsw_eu_ecall_mode_e mode; |
| 134 | uint8_t report_event; |
| 135 | uint16_t start_timer; |
| 136 | uint16_t hack_timer; |
| 137 | uint16_t trans_timer; |
| 138 | uint8_t fail_redial; |
| 139 | uint8_t drop_redial; |
| 140 | uint16_t cleardown_timer; |
| 141 | uint16_t init_timer; |
| 142 | uint16_t nad_reg_timer; |
| 143 | uint16_t nad_dereg_timer; |
| 144 | uint8_t standard; |
| 145 | uint16_t era_glonass_redial; |
| 146 | uint16_t auto_answer; |
| 147 | } gsw_eu_ecall_config_t; |
| 148 | |
| 149 | typedef struct |
| 150 | { |
| 151 | uint8_t ori_remainder_times; |
| 152 | uint16_t time; |
| 153 | } gsw_eu_ecall_event_originate_fail_redial_t; |
| 154 | |
| 155 | typedef struct |
| 156 | { |
| 157 | uint8_t drop_remainder_times; |
| 158 | uint16_t time; /* The minimum time duration between the previous call attempt */ |
| 159 | } gsw_eu_ecall_event_drop_redial_t; |
| 160 | |
| 161 | typedef struct |
| 162 | { |
| 163 | gsw_eu_ecall_event_fail_e fail; |
| 164 | gsw_eu_ecall_event_process_e process; |
| 165 | gsw_eu_ecall_event_msdupdate_e msdupdate; |
| 166 | gsw_eu_ecall_event_establish_e establish; |
| 167 | uint16_t hack_code; |
| 168 | gsw_eu_ecall_event_originate_fail_redial_t ori_redial; |
| 169 | gsw_eu_ecall_event_drop_redial_t drop_redial; |
| 170 | gsw_eu_ecall_event_extend_state_e extend_state; |
| 171 | } gsw_eu_ecall_event_t; |
| 172 | |
| 173 | typedef void (*gsw_eu_ecall_event_cb_f)(gsw_eu_ecall_event_t *p_event); |
| 174 | |
| 175 | typedef void (*gsw_eu_ecall_status_cb_f)(uint32_t id, gsw_eu_ecall_msd_trans_status_e status); |
| 176 | |
| 177 | /** |
| 178 | * @brief init the Europe Ecall voice |
| 179 | * @param [in] None |
| 180 | * @param [out] None |
| 181 | * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL |
| 182 | */ |
| 183 | int32_t gsw_eu_ecall_voice_init(void); |
| 184 | |
| 185 | /** |
| 186 | * @brief deinit the Europe Ecall voice |
| 187 | * @param [in] None |
| 188 | * @param [out] None |
| 189 | * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL |
| 190 | */ |
| 191 | int32_t gsw_eu_ecall_voice_deinit(void); |
| 192 | |
| 193 | /** |
| 194 | * @brief start a Europe Ecall |
| 195 | * @param [in] gsw_eu_ecall_info_t *p_info: ecall info |
| 196 | * @param [out] None |
| 197 | * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL |
| 198 | */ |
| 199 | int32_t gsw_eu_ecall_start(gsw_eu_ecall_info_t *p_info); |
| 200 | |
| 201 | /** |
| 202 | * @brief hangup a Europe Ecall |
| 203 | * @param [in] None |
| 204 | * @param [out] None |
| 205 | * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL |
| 206 | */ |
| 207 | int32_t gsw_eu_ecall_hangup(void); |
| 208 | |
| 209 | /** |
| 210 | * @brief update msd data |
| 211 | * @param [in] uint8_t *msd: msd data |
| 212 | * @param [in] uint32_t msd_len: msd data length |
| 213 | * @param [out] None |
| 214 | * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL |
| 215 | */ |
| 216 | int32_t gsw_eu_ecall_updateMsd(const uint8_t *msd, uint32_t msd_len); |
| 217 | |
| 218 | /** |
| 219 | * @brief using push mode send msd data |
| 220 | * @param [in] None |
| 221 | * @param [out] GSW_EU_ECALL_STATE_E state: ecall state |
| 222 | * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL |
| 223 | */ |
| 224 | int32_t gsw_eu_ecall_pushMsd(gsw_eu_ecall_state_e state); |
| 225 | |
| 226 | /** |
| 227 | * @brief get ecall config |
| 228 | * @param [in] None |
| 229 | * @param [out] gsw_eu_ecall_config_t *p_config: ecall config |
| 230 | * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL |
| 231 | */ |
| 232 | int32_t gsw_eu_ecall_getConfig(gsw_eu_ecall_config_t *p_config); |
| 233 | |
| 234 | /** |
| 235 | * @brief set ecall config |
| 236 | * @param [in] int32_t item: config item |
| 237 | * @param [in] gsw_eu_ecall_config_t *p_config: config info |
| 238 | * @param [out] None |
| 239 | * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL |
| 240 | */ |
| 241 | int32_t gsw_eu_ecall_setConfig(int32_t item, gsw_eu_ecall_config_t *p_config); |
| 242 | |
| 243 | /** |
| 244 | * @brief register the ecall event callback |
| 245 | * @param [in] gsw_eu_ecall_event_cb_f cb: callback |
| 246 | * @param [out] None |
| 247 | * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL |
| 248 | */ |
| 249 | int32_t gsw_eu_ecall_setEventCB(gsw_eu_ecall_event_cb_f cb); |
| 250 | |
| 251 | /** |
| 252 | * @brief register the ecall status callback |
| 253 | * @param [in] gsw_eu_ecall_status_cb_f cb:callback |
| 254 | * @param [out] None |
| 255 | * @retval GSW_HAL_SUCCESS\GSW_HAL_FAIL |
| 256 | */ |
| 257 | int32_t gsw_eu_ecall_setStatusCB(gsw_eu_ecall_status_cb_f cb); |
| 258 | |
| 259 | #ifdef __cplusplus |
| 260 | } |
| 261 | #endif |
| 262 | #endif //__GSW_EU_ECALL_INTERFACE_H__ |