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" |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 21 | #include "mbtk_ril.h" |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 22 | |
| 23 | #define SOCK_CLIENT_MAX 100 |
| 24 | #define EPOLL_LISTEN_MAX 100 |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 25 | |
b.liu | 10a3410 | 2024-08-20 20:36:24 +0800 | [diff] [blame] | 26 | #if 0 |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 27 | #define MBTK_APN_PROP "persist.mbtk.apn" |
b.liu | 10a3410 | 2024-08-20 20:36:24 +0800 | [diff] [blame] | 28 | #else |
| 29 | #define MBTK_APN_PROP "/etc/mbtk/apn" |
| 30 | #endif |
| 31 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 32 | #define MBTK_DEF_ROUTE_CID "persist.mbtk.def_route_cid" |
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 33 | #define MBTK_DEF_DNS_CID "persist.mbtk.def_dns_cid" |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 34 | |
| 35 | typedef struct |
| 36 | { |
| 37 | int fd; |
b.liu | 7ca612c | 2025-04-25 09:23:36 +0800 | [diff] [blame] | 38 | mbtk_sim_type_enum sim_id; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 39 | ATPortType_enum port; |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 40 | |
| 41 | uint32 ind_num; |
| 42 | uint16 ind_register[IND_REGISTER_MAX]; |
| 43 | } sock_cli_info_t; |
| 44 | |
| 45 | typedef struct |
| 46 | { |
| 47 | sock_cli_info_t *cli_info; |
| 48 | void* pack; // Refro to : ril_msg_pack_info_t |
| 49 | } ril_msg_queue_info_t; |
| 50 | |
| 51 | typedef struct { |
b.liu | 7ca612c | 2025-04-25 09:23:36 +0800 | [diff] [blame] | 52 | mbtk_sim_type_enum cur_sim_id; |
| 53 | mbtk_radio_state_enum radio_state[MBTK_SIM_NUM]; |
| 54 | mbtk_sim_state_enum sim_state[MBTK_SIM_NUM]; |
| 55 | mbtk_sim_card_type_enum sim_type[MBTK_SIM_NUM]; |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 56 | int sock_listen_fd; |
| 57 | int epoll_fd; |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 58 | bool at_process[ATPORTTYPE_NUM]; |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 59 | |
| 60 | list_node_t *sock_client_list; // Refor to : sock_cli_info_t |
b.liu | b171c9a | 2024-11-12 19:23:29 +0800 | [diff] [blame] | 61 | mbtk_queue_node_t msg_queue[ATPORTTYPE_NUM]; // Refor to : ril_msg_queue_info_t |
| 62 | pthread_cond_t msg_cond[ATPORTTYPE_NUM]; |
| 63 | pthread_mutex_t msg_mutex[ATPORTTYPE_NUM]; |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 64 | } ril_info_t; |
| 65 | |
| 66 | typedef struct { |
| 67 | bool band_set_success; |
b.liu | 61ad917 | 2025-01-09 14:33:55 +0800 | [diff] [blame] | 68 | uint32 net_support; // MBTK_NET_SUPPORT_2G / MBTK_NET_SUPPORT_3G / MBTK_NET_SUPPORT_4G / MBTK_NET_SUPPORT_5G |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 69 | mbtk_modem_band_area_enum band_area; |
| 70 | mbtk_band_info_t band_support; |
| 71 | } ril_band_info_t; |
| 72 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 73 | /* |
| 74 | 0: unknown |
| 75 | 1: available |
| 76 | 2: current |
| 77 | 3: forbidden |
| 78 | */ |
| 79 | typedef enum |
| 80 | { |
| 81 | MBTK_NET_AVIL_STATE_UNKNOWN = 0, |
| 82 | MBTK_NET_AVIL_STATE_AVAILABLE, |
| 83 | MBTK_NET_AVIL_STATE_CURRENT, |
| 84 | MBTK_NET_AVIL_STATE_FORBIDDEN |
| 85 | } mbtk_net_avil_state_enum; |
| 86 | |
| 87 | typedef enum { |
| 88 | RIL_DATA_CALL_STATE_STOP, |
| 89 | RIL_DATA_CALL_STATE_STARTED, |
| 90 | RIL_DATA_CALL_STATE_STARTING, // Data dialing in progress |
| 91 | RIL_DATA_CALL_STATE_STOPPING // Ending data dialing |
| 92 | } ril_data_call_state_enum; |
| 93 | |
| 94 | typedef struct { |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 95 | ril_msg_id_enum msg; |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 96 | |
| 97 | void *data; |
| 98 | int data_len; |
| 99 | } ril_urc_msg_info_t; |
| 100 | |
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 101 | typedef struct |
| 102 | { |
| 103 | int cid; |
| 104 | bool act; |
| 105 | bool waitting; |
| 106 | } ril_cgact_wait_t; |
| 107 | |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 108 | typedef enum { |
| 109 | RIL_ACT_STATE_DISCONNECTED = 0, |
| 110 | RIL_ACT_STATE_CONNECTING, |
| 111 | RIL_ACT_STATE_CONNECTED, |
| 112 | RIL_ACT_STATE_CONNECTED_RETRY, // Network disconnection, retry after network recovery. |
| 113 | RIL_ACT_STATE_DISCONNECTING |
| 114 | } ril_act_state_enum; |
| 115 | |
| 116 | typedef struct { |
b.liu | afdf2c6 | 2024-11-12 11:10:44 +0800 | [diff] [blame] | 117 | bool valid; |
| 118 | |
b.liu | b1d9b1c | 2024-12-31 13:38:18 +0800 | [diff] [blame] | 119 | bool manual_call; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame] | 120 | mbtk_apn_info_t apn_info; |
| 121 | ril_act_state_enum act_state; |
| 122 | } ril_data_call_info_t; |
| 123 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 124 | extern ril_info_t ril_info; |
| 125 | |
| 126 | |
b.liu | 7ca612c | 2025-04-25 09:23:36 +0800 | [diff] [blame] | 127 | mbtk_radio_state_enum ril_radio_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port); |
| 128 | mbtk_ril_err_enum ril_radio_state_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_radio_state_enum state, bool reset); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 129 | |
b.liu | 7ca612c | 2025-04-25 09:23:36 +0800 | [diff] [blame] | 130 | mbtk_sim_state_enum ril_sim_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 131 | |
b.liu | 7ca612c | 2025-04-25 09:23:36 +0800 | [diff] [blame] | 132 | void apn_auto_conf_from_prop(mbtk_sim_type_enum sim_id, ATPortType_enum port); |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 133 | |
| 134 | bool is_ipv4(const char *ip); |
| 135 | |
yq.wang | 5682ba9 | 2025-05-15 09:44:18 +0800 | [diff] [blame] | 136 | int net_ifc_config(mbtk_sim_type_enum sim_id, mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info); |
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 137 | |
yq.wang | 5682ba9 | 2025-05-15 09:44:18 +0800 | [diff] [blame] | 138 | int net_ifc_reconfig(mbtk_sim_type_enum sim_id, mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info); |
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 139 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 140 | #endif /* _RIL_INFO_H */ |