1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef CHPP_WWAN_TYPES_H_ 17 #define CHPP_WWAN_TYPES_H_ 18 19 // This file was automatically generated by chre_api_to_chpp.py 20 // Date: 2021-05-24 15:46:25 UTC 21 // Source: chre_api/include/chre_api/chre/wwan.h @ commit 833a6241 22 23 // DO NOT modify this file directly, as those changes will be lost the next 24 // time the script is executed 25 26 #include <stdbool.h> 27 #include <stddef.h> 28 #include <stdint.h> 29 30 #include "chpp/app.h" 31 #include "chpp/common/common_types.h" 32 #include "chpp/macros.h" 33 #include "chre_api/chre/version.h" 34 #include "chre_api/chre/wwan.h" 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 CHPP_PACKED_START 41 42 //! See {@link chreWwanCellIdentityCdma} for details 43 struct ChppWwanCellIdentityCdma { 44 int32_t networkId; 45 int32_t systemId; 46 int32_t basestationId; 47 int32_t longitude; 48 int32_t latitude; 49 } CHPP_PACKED_ATTR; 50 51 //! See {@link chreWwanSignalStrengthCdma} for details 52 struct ChppWwanSignalStrengthCdma { 53 int32_t dbm; 54 int32_t ecio; 55 } CHPP_PACKED_ATTR; 56 57 //! See {@link chreWwanSignalStrengthEvdo} for details 58 struct ChppWwanSignalStrengthEvdo { 59 int32_t dbm; 60 int32_t ecio; 61 int32_t signalNoiseRatio; 62 } CHPP_PACKED_ATTR; 63 64 //! See {@link chreWwanCellInfoCdma} for details 65 struct ChppWwanCellInfoCdma { 66 struct ChppWwanCellIdentityCdma cellIdentityCdma; 67 struct ChppWwanSignalStrengthCdma signalStrengthCdma; 68 struct ChppWwanSignalStrengthEvdo signalStrengthEvdo; 69 } CHPP_PACKED_ATTR; 70 71 //! See {@link chreWwanCellIdentityGsm} for details 72 struct ChppWwanCellIdentityGsm { 73 int32_t mcc; 74 int32_t mnc; 75 int32_t lac; 76 int32_t cid; 77 int32_t arfcn; 78 uint8_t bsic; 79 uint8_t reserved[3]; // Input ignored; always set to 0 80 } CHPP_PACKED_ATTR; 81 82 //! See {@link chreWwanSignalStrengthGsm} for details 83 struct ChppWwanSignalStrengthGsm { 84 int32_t signalStrength; 85 int32_t bitErrorRate; 86 int32_t timingAdvance; 87 } CHPP_PACKED_ATTR; 88 89 //! See {@link chreWwanCellInfoGsm} for details 90 struct ChppWwanCellInfoGsm { 91 struct ChppWwanCellIdentityGsm cellIdentityGsm; 92 struct ChppWwanSignalStrengthGsm signalStrengthGsm; 93 } CHPP_PACKED_ATTR; 94 95 //! See {@link chreWwanCellIdentityLte} for details 96 struct ChppWwanCellIdentityLte { 97 int32_t mcc; 98 int32_t mnc; 99 int32_t ci; 100 int32_t pci; 101 int32_t tac; 102 int32_t earfcn; 103 } CHPP_PACKED_ATTR; 104 105 //! See {@link chreWwanSignalStrengthLte} for details 106 struct ChppWwanSignalStrengthLte { 107 int32_t signalStrength; 108 int32_t rsrp; 109 int32_t rsrq; 110 int32_t rssnr; 111 int32_t cqi; 112 int32_t timingAdvance; 113 } CHPP_PACKED_ATTR; 114 115 //! See {@link chreWwanCellInfoLte} for details 116 struct ChppWwanCellInfoLte { 117 struct ChppWwanCellIdentityLte cellIdentityLte; 118 struct ChppWwanSignalStrengthLte signalStrengthLte; 119 } CHPP_PACKED_ATTR; 120 121 //! See {@link chreWwanCellIdentityNr} for details 122 struct ChppWwanCellIdentityNr { 123 int32_t mcc; 124 int32_t mnc; 125 uint32_t nci0; 126 uint32_t nci1; 127 int32_t pci; 128 int32_t tac; 129 int32_t nrarfcn; 130 } CHPP_PACKED_ATTR; 131 132 //! See {@link chreWwanSignalStrengthNr} for details 133 struct ChppWwanSignalStrengthNr { 134 int32_t ssRsrp; 135 int32_t ssRsrq; 136 int32_t ssSinr; 137 int32_t csiRsrp; 138 int32_t csiRsrq; 139 int32_t csiSinr; 140 } CHPP_PACKED_ATTR; 141 142 //! See {@link chreWwanCellInfoNr} for details 143 struct ChppWwanCellInfoNr { 144 struct ChppWwanCellIdentityNr cellIdentityNr; 145 struct ChppWwanSignalStrengthNr signalStrengthNr; 146 } CHPP_PACKED_ATTR; 147 148 //! See {@link chreWwanCellIdentityTdscdma} for details 149 struct ChppWwanCellIdentityTdscdma { 150 int32_t mcc; 151 int32_t mnc; 152 int32_t lac; 153 int32_t cid; 154 int32_t cpid; 155 } CHPP_PACKED_ATTR; 156 157 //! See {@link chreWwanSignalStrengthTdscdma} for details 158 struct ChppWwanSignalStrengthTdscdma { 159 int32_t rscp; 160 } CHPP_PACKED_ATTR; 161 162 //! See {@link chreWwanCellInfoTdscdma} for details 163 struct ChppWwanCellInfoTdscdma { 164 struct ChppWwanCellIdentityTdscdma cellIdentityTdscdma; 165 struct ChppWwanSignalStrengthTdscdma signalStrengthTdscdma; 166 } CHPP_PACKED_ATTR; 167 168 //! See {@link chreWwanCellIdentityWcdma} for details 169 struct ChppWwanCellIdentityWcdma { 170 int32_t mcc; 171 int32_t mnc; 172 int32_t lac; 173 int32_t cid; 174 int32_t psc; 175 int32_t uarfcn; 176 } CHPP_PACKED_ATTR; 177 178 //! See {@link chreWwanSignalStrengthWcdma} for details 179 struct ChppWwanSignalStrengthWcdma { 180 int32_t signalStrength; 181 int32_t bitErrorRate; 182 } CHPP_PACKED_ATTR; 183 184 //! See {@link chreWwanCellInfoWcdma} for details 185 struct ChppWwanCellInfoWcdma { 186 struct ChppWwanCellIdentityWcdma cellIdentityWcdma; 187 struct ChppWwanSignalStrengthWcdma signalStrengthWcdma; 188 } CHPP_PACKED_ATTR; 189 190 //! See {@link chreWwanCellInfoPerRat} for details 191 union ChppWwanCellInfoPerRat { 192 struct ChppWwanCellInfoGsm gsm; 193 struct ChppWwanCellInfoCdma cdma; 194 struct ChppWwanCellInfoLte lte; 195 struct ChppWwanCellInfoWcdma wcdma; 196 struct ChppWwanCellInfoTdscdma tdscdma; 197 struct ChppWwanCellInfoNr nr; 198 } CHPP_PACKED_ATTR; 199 200 //! See {@link chreWwanCellInfo} for details 201 struct ChppWwanCellInfo { 202 uint64_t timeStamp; 203 uint8_t cellInfoType; 204 uint8_t timeStampType; 205 uint8_t registered; 206 uint8_t reserved; // Input ignored; always set to 0 207 union ChppWwanCellInfoPerRat CellInfo; 208 } CHPP_PACKED_ATTR; 209 210 //! See {@link chreWwanCellInfoResult} for details 211 struct ChppWwanCellInfoResult { 212 uint8_t version; // Input ignored; always set to 213 // CHRE_WWAN_CELL_INFO_RESULT_VERSION 214 uint8_t errorCode; 215 uint8_t cellInfoCount; 216 uint8_t reserved; // Input ignored; always set to 0 217 uint32_t cookie; // Input ignored; always set to 0 218 struct ChppOffset 219 cells; // References cellInfoCount instances of struct ChppOffset 220 } CHPP_PACKED_ATTR; 221 222 //! CHPP app header plus struct ChppWwanCellInfoResultWithHeader 223 struct ChppWwanCellInfoResultWithHeader { 224 struct ChppAppHeader header; 225 struct ChppWwanCellInfoResult payload; 226 } CHPP_PACKED_ATTR; 227 228 CHPP_PACKED_END 229 230 // Encoding functions (CHRE --> CHPP) 231 232 /** 233 * Converts from given CHRE structure to serialized CHPP type. 234 * 235 * @param in Fully-formed CHRE structure. 236 * @param out Upon success, will point to a buffer allocated with chppMalloc(). 237 * It is the responsibility of the caller to set the values of the CHPP app 238 * layer header, and to free the buffer when it is no longer needed via 239 * chppFree() or CHPP_FREE_AND_NULLIFY(). 240 * @param outSize Upon success, will be set to the size of the output buffer, in 241 * bytes. 242 * 243 * @return true on success, false if memory allocation failed. 244 */ 245 bool chppWwanCellInfoResultFromChre( 246 const struct chreWwanCellInfoResult *in, 247 struct ChppWwanCellInfoResultWithHeader **out, size_t *outSize); 248 249 // Decoding functions (CHPP --> CHRE) 250 251 /** 252 * Converts from serialized CHPP structure to a CHRE type. 253 * 254 * @param in Fully-formed CHPP structure. 255 * @param in Size of the CHPP structure in bytes. 256 * 257 * @return If successful, a pointer to a CHRE structure allocated with 258 * chppMalloc(). If unsuccessful, null. It is the responsibility of the caller 259 * to free the buffer when it is no longer needed via chppFree() or 260 * CHPP_FREE_AND_NULLIFY(). 261 */ 262 struct chreWwanCellInfoResult *chppWwanCellInfoResultToChre( 263 const struct ChppWwanCellInfoResult *in, size_t inSize); 264 265 #ifdef __cplusplus 266 } 267 #endif 268 269 #endif // CHPP_WWAN_TYPES_H_ 270