1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef NATIVE_TELEPHONY_RADIO_TYPE_H
17 #define NATIVE_TELEPHONY_RADIO_TYPE_H
18 
19 /**
20  * @file telephony_radio_type.h
21  *
22  * @brief Provides the data structures for the C APIs of the the telephony radio.
23  *
24  * @kit TelephonyKit
25  * @syscap SystemCapability.Telephony.CoreService
26  * @library libtelephony_radio.so
27  * @since 13
28  */
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define TELEPHONY_MAX_OPERATOR_LEN 64
35 #define TELEPHONY_MAX_PLMN_NUMERIC_LEN 6
36 
37 /**
38  * @brief Result code.
39  *
40  * @since 13
41  */
42 typedef enum Telephony_RadioResult {
43     /* @error success */
44     TEL_RADIO_SUCCESS = 0,
45     /* @error permission denied */
46     TEL_RADIO_PERMISSION_DENIED = 201,
47     /* @error invalid parameter */
48     TEL_RADIO_ERR_INVALID_PARAM = 401,
49     /* @error marshalling failed, this is a low probability error, try again later when get this error */
50     TEL_RADIO_ERR_MARSHALLING_FAILED = 8300001,
51     /* @error unable to connect to telephony service, try again later when get this error */
52     TEL_RADIO_ERR_SERVICE_CONNECTION_FAILED = 8300002,
53     /* @error operation failed in telephony service, try again later when get this error */
54     TEL_RADIO_ERR_OPERATION_FAILED = 8300003,
55 } Telephony_RadioResult;
56 
57 /**
58  * @brief network registration status.
59  *
60  * @since 13
61  */
62 typedef enum Telephony_RegState {
63     /* can not use any services */
64     TEL_REG_STATE_NO_SERVICE = 0,
65     /* can use services properly */
66     TEL_REG_STATE_IN_SERVICE = 1,
67     /* can use emergency call only */
68     TEL_REG_STATE_EMERGENCY_CALL_ONLY = 2,
69     /* radio power off */
70     TEL_REG_STATE_POWER_OFF = 3,
71 } Telephony_RegState;
72 
73 /**
74  * @brief radio access technologies.
75  *
76  * @since 13
77  */
78 typedef enum Telephony_RadioTechnology {
79     /* Unknown radio technology */
80     TEL_RADIO_TECHNOLOGY_UNKNOWN = 0,
81     /* Global System for Mobile Communication (GSM) */
82     TEL_RADIO_TECHNOLOGY_GSM = 1,
83     /* Single-Carrier Radio Transmission Technology (1XRTT) */
84     TEL_RADIO_TECHNOLOGY_1XRTT = 2,
85     /* Wideband Code Division Multiple Access (WCDMA) */
86     TEL_RADIO_TECHNOLOGY_WCDMA = 3,
87     /* High Speed Packet Access (HSPA) */
88     TEL_RADIO_TECHNOLOGY_HSPA = 4,
89     /* Evolved High Speed Packet Access (HSPA+) */
90     TEL_RADIO_TECHNOLOGY_HSPAP = 5,
91     /* Time Division-Synchronous Code Division Multiple Access(TD-SCDMA) */
92     TEL_RADIO_TECHNOLOGY_TD_SCDMA = 6,
93     /* Evolution-Data Optimized (EVDO) */
94     TEL_RADIO_TECHNOLOGY_EVDO = 7,
95     /* Evolved High Rate Package Data (EHRPD) */
96     TEL_RADIO_TECHNOLOGY_EHRPD = 8,
97     /* Long Term Evolution (LTE) */
98     TEL_RADIO_TECHNOLOGY_LTE = 9,
99     /* Long Term Evolution_Carrier Aggregation (LTE_CA) */
100     TEL_RADIO_TECHNOLOGY_LTE_CA = 10,
101     /* Industrial Wireless LAN (IWLAN) */
102     TEL_RADIO_TECHNOLOGY_IWLAN = 11,
103     /* New Radio (NR) */
104     TEL_RADIO_TECHNOLOGY_NR = 12,
105 } Telephony_RadioTechnology;
106 
107 /**
108  * @brief NSA network state.
109  *
110  * @since 13
111  */
112 typedef enum Telephony_NsaState {
113     /* The device is in idle or connected state in an LTE cell that does not support NSA */
114     TEL_NSA_STATE_NOT_SUPPORTED = 1,
115     /* The device is in the idle state in an LTE cell that supports NSA but not NR coverage detection */
116     TEL_NSA_STATE_NO_DETECTED = 2,
117     /* The device is connected to the LTE network in an LTE cell that supports NSA and NR coverage detection */
118     TEL_NSA_STATE_CONNECTED_DETECTED = 3,
119     /* The device is in the idle state in an LTE cell that supports NSA and NR coverage detection */
120     TEL_NSA_STATE_IDLE_DETECTED = 4,
121     /* The device is connected to the LTE/NR network in an LTE cell that supports NSA */
122     TEL_NSA_STATE_DUAL_CONNECTED = 5,
123     /* The device is idle or connected to the NG-RAN cell when being attached to the 5G Core */
124     TEL_NSA_STATE_SA_ATTACHED = 6,
125 } Telephony_NsaState;
126 
127 /**
128  * @brief Network status.
129  *
130  * @since 13
131  */
132 typedef struct Telephony_NetworkState {
133     /* Long carrier name of the registered network */
134     char longOperatorName_[TELEPHONY_MAX_OPERATOR_LEN];
135     /* Short carrier name of the registered network */
136     char shortOperatorName_[TELEPHONY_MAX_OPERATOR_LEN];
137     /* PLMN code of the registered network */
138     char plmnNumeric_[TELEPHONY_MAX_PLMN_NUMERIC_LEN];
139     /* Whether in roaming */
140     bool isRoaming_;
141     /* Network registration status */
142     Telephony_RegState regState_;
143     /* Radio technology. */
144     Telephony_RadioTechnology cfgTech_;
145     /* NSA state */
146     Telephony_NsaState nsaState_;
147     /* Whether Carrier Aggregation(CA) is active */
148     bool isCaActive_;
149     /* Whether in emergency call only */
150     bool isEmergency_;
151 } Telephony_NetworkState;
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 #endif // NATIVE_TELEPHONY_RADIO_TYPE_H
158