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