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; |
| 38 | |
| 39 | uint32 ind_num; |
| 40 | uint16 ind_register[IND_REGISTER_MAX]; |
| 41 | } sock_cli_info_t; |
| 42 | |
| 43 | typedef struct |
| 44 | { |
| 45 | sock_cli_info_t *cli_info; |
| 46 | void* pack; // Refro to : ril_msg_pack_info_t |
| 47 | } ril_msg_queue_info_t; |
| 48 | |
| 49 | typedef struct { |
| 50 | mbtk_radio_state_enum radio_state; |
| 51 | mbtk_sim_state_enum sim_state; |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame^] | 52 | mbtk_sim_card_type_enum sim_type; |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 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 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 69 | /* |
| 70 | 0: unknown |
| 71 | 1: available |
| 72 | 2: current |
| 73 | 3: forbidden |
| 74 | */ |
| 75 | typedef enum |
| 76 | { |
| 77 | MBTK_NET_AVIL_STATE_UNKNOWN = 0, |
| 78 | MBTK_NET_AVIL_STATE_AVAILABLE, |
| 79 | MBTK_NET_AVIL_STATE_CURRENT, |
| 80 | MBTK_NET_AVIL_STATE_FORBIDDEN |
| 81 | } mbtk_net_avil_state_enum; |
| 82 | |
| 83 | typedef enum { |
| 84 | RIL_DATA_CALL_STATE_STOP, |
| 85 | RIL_DATA_CALL_STATE_STARTED, |
| 86 | RIL_DATA_CALL_STATE_STARTING, // Data dialing in progress |
| 87 | RIL_DATA_CALL_STATE_STOPPING // Ending data dialing |
| 88 | } ril_data_call_state_enum; |
| 89 | |
| 90 | typedef struct { |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame^] | 91 | ril_msg_id_enum msg; |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 92 | |
| 93 | void *data; |
| 94 | int data_len; |
| 95 | } ril_urc_msg_info_t; |
| 96 | |
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 97 | typedef struct |
| 98 | { |
| 99 | int cid; |
| 100 | bool act; |
| 101 | bool waitting; |
| 102 | } ril_cgact_wait_t; |
| 103 | |
b.liu | 15f456b | 2024-10-31 20:16:06 +0800 | [diff] [blame^] | 104 | typedef enum { |
| 105 | RIL_ACT_STATE_DISCONNECTED = 0, |
| 106 | RIL_ACT_STATE_CONNECTING, |
| 107 | RIL_ACT_STATE_CONNECTED, |
| 108 | RIL_ACT_STATE_CONNECTED_RETRY, // Network disconnection, retry after network recovery. |
| 109 | RIL_ACT_STATE_DISCONNECTING |
| 110 | } ril_act_state_enum; |
| 111 | |
| 112 | typedef struct { |
| 113 | mbtk_apn_info_t apn_info; |
| 114 | ril_act_state_enum act_state; |
| 115 | } ril_data_call_info_t; |
| 116 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 117 | extern ril_info_t ril_info; |
| 118 | |
| 119 | |
| 120 | mbtk_radio_state_enum ril_radio_state_get(); |
| 121 | mbtk_ril_err_enum ril_radio_state_set(mbtk_radio_state_enum state, bool reset); |
| 122 | |
| 123 | mbtk_sim_state_enum ril_sim_state_get(); |
| 124 | |
| 125 | void apn_auto_conf_from_prop(); |
| 126 | |
| 127 | bool is_ipv4(const char *ip); |
| 128 | |
b.liu | bcf86c9 | 2024-08-19 19:48:28 +0800 | [diff] [blame] | 129 | int net_ifc_config(mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info); |
| 130 | |
| 131 | int net_ifc_reconfig(mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info); |
| 132 | |
b.liu | 87afc4c | 2024-08-14 17:33:45 +0800 | [diff] [blame] | 133 | #endif /* _RIL_INFO_H */ |