b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 1 | /* |
| 2 | * ril_info.h |
| 3 | * |
| 4 | * MBTK Ril information header. |
| 5 | * |
| 6 | * Author : lb |
| 7 | * Date : 2024/8/6 10:53:08 |
| 8 | */ |
| 9 | #ifndef _RIL_INFO_H |
| 10 | #define _RIL_INFO_H |
| 11 | #include <stdio.h> |
| 12 | |
| 13 | #include "mbtk_type.h" |
| 14 | #include "mbtk_ril_api.h" |
| 15 | #include "mbtk_log.h" |
| 16 | #include "atchannel.h" |
| 17 | #include "at_tok.h" |
| 18 | #include "mbtk_list.h" |
| 19 | #include "mbtk_device.h" |
| 20 | #include "mbtk_queue.h" |
| 21 | |
| 22 | #define SOCK_CLIENT_MAX 100 |
| 23 | #define EPOLL_LISTEN_MAX 100 |
| 24 | #define IND_REGISTER_MAX 10 |
| 25 | #define PACK_PROCESS_QUEUE_MAX 20 |
| 26 | |
| 27 | #define MBTK_APN_PROP "persist.mbtk.apn" |
| 28 | #define MBTK_DEF_ROUTE_CID "persist.mbtk.def_route_cid" |
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame^] | 29 | #define MBTK_DEF_DNS_CID "persist.mbtk.def_dns_cid" |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 30 | |
| 31 | typedef struct |
| 32 | { |
| 33 | int fd; |
| 34 | |
| 35 | uint32 ind_num; |
| 36 | uint16 ind_register[IND_REGISTER_MAX]; |
| 37 | } sock_cli_info_t; |
| 38 | |
| 39 | typedef struct |
| 40 | { |
| 41 | sock_cli_info_t *cli_info; |
| 42 | void* pack; // Refro to : ril_msg_pack_info_t |
| 43 | } ril_msg_queue_info_t; |
| 44 | |
| 45 | typedef struct { |
| 46 | mbtk_radio_state_enum radio_state; |
| 47 | mbtk_sim_state_enum sim_state; |
| 48 | int sock_listen_fd; |
| 49 | int epoll_fd; |
| 50 | bool at_process; |
| 51 | |
| 52 | list_node_t *sock_client_list; // Refor to : sock_cli_info_t |
| 53 | mbtk_queue_node_t msg_queue; // Refor to : ril_msg_queue_info_t |
| 54 | pthread_cond_t msg_cond; |
| 55 | pthread_mutex_t msg_mutex; |
| 56 | } ril_info_t; |
| 57 | |
| 58 | typedef struct { |
| 59 | bool band_set_success; |
| 60 | mbtk_modem_band_area_enum band_area; |
| 61 | mbtk_band_info_t band_support; |
| 62 | } ril_band_info_t; |
| 63 | |
| 64 | typedef enum { |
| 65 | RIL_URC_MSG_RADIO_STATE, |
| 66 | RIL_URC_MSG_CGEV, |
| 67 | RIL_URC_MSG_NET_CS_REG_STATE, |
| 68 | RIL_URC_MSG_NET_PS_REG_STATE, |
| 69 | RIL_URC_MSG_CALL_STATE, |
| 70 | RIL_URC_MSG_SIM_STATE, |
| 71 | RIL_URC_MSG_PDP_STATE, |
| 72 | RIL_URC_MSG_SMS_STATE, |
| 73 | RIL_URC_MSG_SET_BAND, |
| 74 | RIL_URC_MSG_GET_SIM_STATE, //check sim status |
| 75 | RIL_URC_MSG_NET_STATE_LOG // Save Network state into file. |
| 76 | } ril_urc_msg_id_enum; |
| 77 | |
| 78 | /* |
| 79 | 0: unknown |
| 80 | 1: available |
| 81 | 2: current |
| 82 | 3: forbidden |
| 83 | */ |
| 84 | typedef enum |
| 85 | { |
| 86 | MBTK_NET_AVIL_STATE_UNKNOWN = 0, |
| 87 | MBTK_NET_AVIL_STATE_AVAILABLE, |
| 88 | MBTK_NET_AVIL_STATE_CURRENT, |
| 89 | MBTK_NET_AVIL_STATE_FORBIDDEN |
| 90 | } mbtk_net_avil_state_enum; |
| 91 | |
| 92 | typedef enum { |
| 93 | RIL_DATA_CALL_STATE_STOP, |
| 94 | RIL_DATA_CALL_STATE_STARTED, |
| 95 | RIL_DATA_CALL_STATE_STARTING, // Data dialing in progress |
| 96 | RIL_DATA_CALL_STATE_STOPPING // Ending data dialing |
| 97 | } ril_data_call_state_enum; |
| 98 | |
| 99 | typedef struct { |
| 100 | ril_urc_msg_id_enum msg; |
| 101 | |
| 102 | void *data; |
| 103 | int data_len; |
| 104 | } ril_urc_msg_info_t; |
| 105 | |
| 106 | typedef struct { |
| 107 | mbtk_ril_cid_enum cid_for_def_route; |
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame^] | 108 | mbtk_ril_cid_enum cid_for_dns; |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 109 | |
| 110 | int num; |
| 111 | mbtk_apn_info_t apns[MBTK_APN_CID_MAX]; |
| 112 | } ril_apn_info_array_t; |
| 113 | |
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame^] | 114 | typedef struct |
| 115 | { |
| 116 | int cid; |
| 117 | bool act; |
| 118 | bool waitting; |
| 119 | } ril_cgact_wait_t; |
| 120 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 121 | extern ril_info_t ril_info; |
| 122 | |
| 123 | |
| 124 | mbtk_radio_state_enum ril_radio_state_get(); |
| 125 | mbtk_ril_err_enum ril_radio_state_set(mbtk_radio_state_enum state, bool reset); |
| 126 | |
| 127 | mbtk_sim_state_enum ril_sim_state_get(); |
| 128 | |
| 129 | void apn_auto_conf_from_prop(); |
| 130 | |
| 131 | bool is_ipv4(const char *ip); |
| 132 | |
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame^] | 133 | int net_ifc_config(mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info); |
| 134 | |
| 135 | int net_ifc_reconfig(mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info); |
| 136 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 137 | #endif /* _RIL_INFO_H */ |