1 /* 2 * Copyright (C) 2021 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 package com.android.server.uwb.data; 17 18 import static android.hardware.uwb.fira_android.UwbVendorStatusCodes.STATUS_ERROR_CCC_LIFECYCLE; 19 import static android.hardware.uwb.fira_android.UwbVendorStatusCodes.STATUS_ERROR_CCC_SE_BUSY; 20 import static android.hardware.uwb.fira_android.UwbVendorStatusCodes.STATUS_REGULATION_UWB_OFF; 21 22 import android.hardware.uwb.fira_android.UwbVendorReasonCodes; 23 24 import com.google.uwb.support.aliro.AliroParams; 25 import com.google.uwb.support.ccc.CccParams; 26 import com.google.uwb.support.fira.FiraParams; 27 28 public class UwbUciConstants { 29 /** 30 * Table 10:Device State Values 31 */ 32 public static final byte DEVICE_STATE_OFF = 0x00; //NOT defined in the UCI spec 33 public static final byte DEVICE_STATE_READY = 0x01; 34 public static final byte DEVICE_STATE_ACTIVE = 0x02; 35 public static final byte DEVICE_STATE_ERROR = (byte) 0xFF; 36 37 public static final byte UWBS_RESET = 0x00; 38 39 /** 40 * Table 13: Control Messages to Initialize UWB session 41 */ 42 public static final byte SESSION_TYPE_RANGING = FiraParams.SESSION_TYPE_RANGING; 43 public static final byte SESSION_TYPE_DATA_TRANSFER = 44 FiraParams.SESSION_TYPE_RANGING_AND_IN_BAND_DATA; 45 public static final byte SESSION_TYPE_ALIRO = (byte) AliroParams.SESSION_TYPE_ALIRO; 46 public static final byte SESSION_TYPE_CCC = (byte) CccParams.SESSION_TYPE_CCC; 47 public static final byte SESSION_TYPE_DEVICE_TEST_MODE = 48 (byte) FiraParams.SESSION_TYPE_DEVICE_TEST_MODE; 49 50 /** 51 * Table 14: Control Messages to De-Initialize UWB session - SESSION_STATUS_NTF 52 * RangingSession.State 53 */ 54 public static final int UWB_SESSION_STATE_INIT = 0x00; 55 public static final int UWB_SESSION_STATE_DEINIT = 0x01; 56 public static final int UWB_SESSION_STATE_ACTIVE = 0x02; 57 public static final int UWB_SESSION_STATE_IDLE = 0x03; 58 public static final int UWB_SESSION_STATE_ERROR = 0xFF; 59 60 /** 61 * Table 16: state change with reason codes 62 */ 63 public static final int REASON_STATE_CHANGE_WITH_SESSION_MANAGEMENT_COMMANDS = 0x00; 64 /* Below reason codes shall be reported with SESSION_STATE_IDLE state only. */ 65 public static final int REASON_MAX_RANGING_ROUND_RETRY_COUNT_REACHED = 0x01; 66 public static final int REASON_MAX_NUMBER_OF_MEASUREMENTS_REACHED = 0x02; 67 public static final int REASON_SESSION_SUSPENDED_DUE_TO_INBAND_SIGNAL = 0x03; 68 public static final int REASON_SESSION_RESUMED_DUE_TO_INBAND_SIGNAL = 0x04; 69 public static final int REASON_SESSION_STOPPED_DUE_TO_INBAND_SIGNAL = 0X05; 70 public static final int REASON_ERROR_INVALID_UL_TDOA_RANDOM_WINDOW = 0x1D; 71 public static final int REASON_ERROR_SLOT_LENGTH_NOT_SUPPORTED = 0x20; 72 public static final int REASON_ERROR_INSUFFICIENT_SLOTS_PER_RR = 0x21; 73 public static final int REASON_ERROR_MAC_ADDRESS_MODE_NOT_SUPPORTED = 0x22; 74 public static final int REASON_ERROR_INVALID_RANGING_INTERVAL = 0x23; 75 public static final int REASON_ERROR_INVALID_STS_CONFIG = 0x24; 76 public static final int REASON_ERROR_INVALID_RFRAME_CONFIG = 0x25; 77 public static final int REASON_ERROR_HUS_NOT_ENOUGH_SLOTS = 0x26; 78 public static final int REASON_ERROR_HUS_CFP_PHASE_TOO_SHORT = 0x27; 79 public static final int REASON_ERROR_HUS_CAP_PHASE_TOO_SHORT = 0x28; 80 public static final int REASON_ERROR_HUS_OTHERS = 0x29; 81 public static final int REASON_ERROR_SESSION_KEY_NOT_FOUND = 0x2A; 82 public static final int REASON_ERROR_SUB_SESSION_KEY_NOT_FOUND = 0x2B; 83 /* Vendor Specific reason codes */ 84 public static final int REASON_REGULATION_UWB_OFF = 85 UwbVendorReasonCodes.REASON_REGULATION_UWB_OFF; 86 87 /** 88 * Table 27: Multicast list update status codes 89 */ 90 /* Multicast update status codes */ 91 public static final int MULTICAST_LIST_UPDATE_STATUS_OK = 92 FiraParams.MULTICAST_LIST_UPDATE_STATUS_OK; 93 public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_FULL = 94 FiraParams.MULTICAST_LIST_UPDATE_STATUS_ERROR_MULTICAST_LIST_FULL; 95 public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_KEY_FETCH_FAIL = 96 FiraParams.MULTICAST_LIST_UPDATE_STATUS_ERROR_KEY_FETCH_FAIL; 97 public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_ID_NOT_FOUND = 98 FiraParams.MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_ID_NOT_FOUND; 99 public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_KEY_NOT_FOUND = 100 FiraParams.MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_KEY_NOT_FOUND; 101 public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_KEY_NOT_APPLICABLE = 102 FiraParams.MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_KEY_NOT_APPLICABLE; 103 public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_SESSION_KEY_NOT_FOUND = 104 FiraParams.MULTICAST_LIST_UPDATE_STATUS_ERROR_SESSION_KEY_NOT_FOUND; 105 public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_ADDRESS_NOT_FOUND = 106 FiraParams.MULTICAST_LIST_UPDATE_STATUS_ERROR_ADDRESS_NOT_FOUND; 107 public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_ADDRESS_ALREADY_PRESENT = 108 FiraParams.MULTICAST_LIST_UPDATE_STATUS_ERROR_ADDRESS_ALREADY_PRESENT; 109 /** 110 * Table 29:APP Configuration Parameters IDs 111 */ 112 public static final int DEVICE_TYPE_CONTROLEE = FiraParams.RANGING_DEVICE_TYPE_CONTROLEE; 113 public static final int DEVICE_TYPE_CONTROLLER = FiraParams.RANGING_DEVICE_TYPE_CONTROLLER; 114 115 public static final int ROUND_USAGE_SS_TWR_DEFERRED_MODE = 116 FiraParams.RANGING_ROUND_USAGE_SS_TWR_DEFERRED_MODE; 117 public static final int ROUND_USAGE_DS_TWR_DEFERRED_MODE = 118 FiraParams.RANGING_ROUND_USAGE_DS_TWR_DEFERRED_MODE; 119 public static final int ROUND_USAGE_SS_TWR_NON_DEFERRED_MODE = 120 FiraParams.RANGING_ROUND_USAGE_SS_TWR_NON_DEFERRED_MODE; 121 public static final int ROUND_USAGE_DS_TWR_NON_DEFERRED_MODE = 122 FiraParams.RANGING_ROUND_USAGE_DS_TWR_NON_DEFERRED_MODE; 123 public static final int ROUND_USAGE_OWR_AOA_MEASUREMENT = 124 FiraParams.RANGING_ROUND_USAGE_OWR_AOA_MEASUREMENT; 125 126 public static final int MULTI_NODE_MODE_UNICAST = FiraParams.MULTI_NODE_MODE_UNICAST; 127 public static final int MULTI_NODE_MODE_ONE_TO_MANY = FiraParams.MULTI_NODE_MODE_ONE_TO_MANY; 128 public static final int MULTI_NODE_MODE_MANY_TO_MANY = FiraParams.MULTI_NODE_MODE_MANY_TO_MANY; 129 130 public static final int INTERVAL_BASED_SCHEDULING = FiraParams.INTERVAL_BASED_SCHEDULING; 131 public static final int BLOCK_BASED_SCHEDULING = FiraParams.BLOCK_BASED_SCHEDULING; 132 133 public static final int CONTENTION_BASED_RANGING = FiraParams.CONTENTION_BASED_RANGING; 134 public static final int TIME_SCHEDULED_RANGING = FiraParams.TIME_SCHEDULED_RANGING; 135 public static final int HYBRID_SCHEDULED_RANGING = 136 FiraParams.HYBRID_SCHEDULED_RANGING; 137 138 public static final int CONSTRAINT_LENGTH_3 = FiraParams.CONSTRAINT_LENGTH_3; 139 public static final int CONSTRAINT_LENGTH_7 = FiraParams.CONSTRAINT_LENGTH_7; 140 141 public static final int CHANNEL_5 = FiraParams.UWB_CHANNEL_5; 142 public static final int CHANNEL_6 = FiraParams.UWB_CHANNEL_6; 143 public static final int CHANNEL_8 = FiraParams.UWB_CHANNEL_8; 144 public static final int CHANNEL_9 = FiraParams.UWB_CHANNEL_9; 145 public static final int CHANNEL_10 = FiraParams.UWB_CHANNEL_10; 146 public static final int CHANNEL_12 = FiraParams.UWB_CHANNEL_12; 147 public static final int CHANNEL_13 = FiraParams.UWB_CHANNEL_13; 148 public static final int CHANNEL_14 = FiraParams.UWB_CHANNEL_14; 149 150 public static final int MAC_FCS_TYPE_CRC_16 = FiraParams.MAC_FCS_TYPE_CRC_16; 151 public static final int MAC_FCS_TYPE_CRC_32 = FiraParams.MAC_FCS_TYPE_CRC_32; 152 153 public static final int AOA_RESULT_REQ_DISABLE = 0x00; 154 public static final int AOA_RESULT_REQ_ENABLE = 0x01; 155 156 public static final int RANGE_DATA_NTF_CONFIG_DISABLE = 157 FiraParams.RANGE_DATA_NTF_CONFIG_DISABLE; 158 public static final int RANGE_DATA_NTF_CONFIG_ENABLE = FiraParams.RANGE_DATA_NTF_CONFIG_ENABLE; 159 public static final int RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY = 160 FiraParams.RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_LEVEL_TRIG; 161 162 /** 163 * Table 54: APP Configuration Parameter IDs 164 */ 165 public static final int RANGING_DEVICE_ROLE_RESPONDER = 166 FiraParams.RANGING_DEVICE_ROLE_RESPONDER; 167 public static final int RANGING_DEVICE_ROLE_INITIATOR = 168 FiraParams.RANGING_DEVICE_ROLE_INITIATOR; 169 public static final int RANGING_DEVICE_ROLE_ADVERTISER = 170 FiraParams.RANGING_DEVICE_ROLE_ADVERTISER; 171 public static final int RANGING_DEVICE_ROLE_OBSERVER = 172 FiraParams.RANGING_DEVICE_ROLE_OBSERVER; 173 174 /** 175 * Table 37: Ranging Data Notification 176 */ 177 public static final byte RANGING_MEASUREMENT_TYPE_TWO_WAY = 0X01; 178 public static final byte RANGING_MEASUREMENT_TYPE_DL_TDOA = 0x02; 179 public static final byte RANGING_MEASUREMENT_TYPE_OWR_AOA = 0x03; 180 181 public static final byte MAC_ADDRESSING_MODE_SHORT = 0x00; 182 public static final byte MAC_ADDRESSING_MODE_EXTENDED = 0x01; 183 184 /** 185 * Table 32: Status Codes 186 */ 187 /* Generic Status Codes */ 188 public static final int STATUS_CODE_OK = FiraParams.STATUS_CODE_OK; 189 public static final int STATUS_CODE_REJECTED = FiraParams.STATUS_CODE_REJECTED; 190 public static final int STATUS_CODE_FAILED = FiraParams.STATUS_CODE_FAILED; 191 public static final int STATUS_CODE_SYNTAX_ERROR = FiraParams.STATUS_CODE_SYNTAX_ERROR; 192 public static final int STATUS_CODE_INVALID_PARAM = FiraParams.STATUS_CODE_INVALID_PARAM; 193 public static final int STATUS_CODE_INVALID_RANGE = FiraParams.STATUS_CODE_INVALID_RANGE; 194 public static final int STATUS_CODE_INVALID_MESSAGE_SIZE = 195 FiraParams.STATUS_CODE_INVALID_MESSAGE_SIZE; 196 public static final int STATUS_CODE_UNKNOWN_GID = FiraParams.STATUS_CODE_UNKNOWN_GID; 197 public static final int STATUS_CODE_UNKNOWN_OID = FiraParams.STATUS_CODE_UNKNOWN_OID; 198 public static final int STATUS_CODE_READ_ONLY = FiraParams.STATUS_CODE_READ_ONLY; 199 public static final int STATUS_CODE_COMMAND_RETRY = FiraParams.STATUS_CODE_COMMAND_RETRY; 200 public static final int STATUS_CODE_UNKNOWN = FiraParams.STATUS_CODE_UNKNOWN; 201 /* UWB Session Specific Status Codes */ 202 public static final int STATUS_CODE_ERROR_SESSION_NOT_EXIST = 203 FiraParams.STATUS_CODE_ERROR_SESSION_NOT_EXIST; 204 public static final int STATUS_CODE_ERROR_SESSION_DUPLICATE = 205 FiraParams.STATUS_CODE_ERROR_SESSION_DUPLICATE; 206 public static final int STATUS_CODE_ERROR_SESSION_ACTIVE = 207 FiraParams.STATUS_CODE_ERROR_SESSION_ACTIVE; 208 public static final int STATUS_CODE_ERROR_MAX_SESSIONS_EXCEEDED = 209 FiraParams.STATUS_CODE_ERROR_MAX_SESSIONS_EXCEEDED; 210 public static final int STATUS_CODE_ERROR_SESSION_NOT_CONFIGURED = 211 FiraParams.STATUS_CODE_ERROR_SESSION_NOT_CONFIGURED; 212 public static final int STATUS_CODE_ERROR_ACTIVE_SESSIONS_ONGOING = 213 FiraParams.STATUS_CODE_ERROR_ACTIVE_SESSIONS_ONGOING; 214 public static final int STATUS_CODE_ERROR_MULTICAST_LIST_FULL = 215 FiraParams.STATUS_CODE_ERROR_MULTICAST_LIST_FULL; 216 public static final int STATUS_CODE_ERROR_ADDRESS_NOT_FOUND = 217 FiraParams.STATUS_CODE_ERROR_ADDRESS_NOT_FOUND; 218 public static final int STATUS_CODE_ERROR_ADDRESS_ALREADY_PRESENT = 219 FiraParams.STATUS_CODE_ERROR_ADDRESS_ALREADY_PRESENT; 220 public static final int STATUS_CODE_OK_NEGATIVE_DISTANCE_REPORT = 221 FiraParams.STATUS_CODE_OK_NEGATIVE_DISTANCE_REPORT; 222 /* UWB Ranging Session Specific Status Codes */ 223 public static final int STATUS_CODE_RANGING_TX_FAILED = 224 FiraParams.STATUS_CODE_RANGING_TX_FAILED; 225 public static final int STATUS_CODE_RANGING_RX_TIMEOUT = 226 FiraParams.STATUS_CODE_RANGING_RX_TIMEOUT; 227 public static final int STATUS_CODE_RANGING_RX_PHY_DEC_FAILED = 228 FiraParams.STATUS_CODE_RANGING_RX_PHY_DEC_FAILED; 229 public static final int STATUS_CODE_RANGING_RX_PHY_TOA_FAILED = 230 FiraParams.STATUS_CODE_RANGING_RX_PHY_TOA_FAILED; 231 public static final int STATUS_CODE_RANGING_RX_PHY_STS_FAILED = 232 FiraParams.STATUS_CODE_RANGING_RX_PHY_STS_FAILED; 233 public static final int STATUS_CODE_RANGING_RX_MAC_DEC_FAILED = 234 FiraParams.STATUS_CODE_RANGING_RX_MAC_DEC_FAILED; 235 public static final int STATUS_CODE_RANGING_RX_MAC_IE_DEC_FAILED = 236 FiraParams.STATUS_CODE_RANGING_RX_MAC_IE_DEC_FAILED; 237 public static final int STATUS_CODE_RANGING_RX_MAC_IE_MISSING = 238 FiraParams.STATUS_CODE_RANGING_RX_MAC_IE_MISSING; 239 public static final int STATUS_CODE_ERROR_ROUND_INDEX_NOT_ACTIVATED = 240 FiraParams.STATUS_CODE_ERROR_ROUND_INDEX_NOT_ACTIVATED; 241 public static final int STATUS_CODE_ERROR_NUMBER_OF_ACTIVE_RANGING_ROUNDS_EXCEEDED = 242 FiraParams.STATUS_CODE_ERROR_NUMBER_OF_ACTIVE_RANGING_ROUNDS_EXCEEDED; 243 public static final int STATUS_CODE_ERROR_ROUND_INDEX_NOT_SET_AS_INITIATOR = 244 FiraParams.STATUS_CODE_ERROR_ROUND_INDEX_NOT_SET_AS_INITIATOR; 245 public static final int 246 STATUS_CODE_ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST = 247 FiraParams.STATUS_CODE_ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST; 248 249 /* Vendor-dependent UCI status codes */ 250 public static final int STATUS_CODE_CCC_SE_BUSY = STATUS_ERROR_CCC_SE_BUSY; 251 public static final int STATUS_CODE_CCC_LIFECYCLE = STATUS_ERROR_CCC_LIFECYCLE; 252 public static final int STATUS_CODE_ANDROID_REGULATION_UWB_OFF = STATUS_REGULATION_UWB_OFF; 253 254 /** 255 * Table 28: Status codes in the DATA_TRANSFER_STATUS_NTF. 256 */ 257 public static final int STATUS_CODE_DATA_TRANSFER_REPETITION_OK = 258 FiraParams.STATUS_CODE_DATA_TRANSFER_NTF_REPETITION_OK; 259 public static final int STATUS_CODE_DATA_TRANSFER_OK = 260 FiraParams.STATUS_CODE_DATA_TRANSFER_NTF_OK; 261 public static final int STATUS_CODE_DATA_TRANSFER_ERROR_DATA_TRANSFER = 262 FiraParams.STATUS_CODE_DATA_TRANSFER_NTF_ERROR_DATA_TRANSFER; 263 264 /** 265 * Table TBD: Status codes in the DATA_TRANSFER_PHASE_CONFIGURATION_NTF 266 */ 267 public static final int STATUS_CODE_DATA_TRANSFER_PHASE_CONFIG_DTPCM_CONFIG_SUCCESS = 268 FiraParams.STATUS_CODE_DATA_TRANSFER_PHASE_CONFIG_DTPCM_CONFIG_SUCCESS; 269 public static final int STATUS_CODE_DATA_TRANSFER_PHASE_CONFIG_ERROR_DUPLICATE_SLOT_ASSIGNMENT = 270 FiraParams.STATUS_CODE_DATA_TRANSFER_PHASE_CONFIG_ERROR_DUPLICATE_SLOT_ASSIGNMENT; 271 272 /* UWB Device Extended Mac address length */ 273 public static final int UWB_DEVICE_SHORT_MAC_ADDRESS_LEN = 2; 274 public static final int UWB_DEVICE_EXT_MAC_ADDRESS_LEN = 8; 275 276 /* UWB Data Session Specific Status Codes */ 277 public static final int STATUS_CODE_DATA_MAX_TX_APDU_SIZE_EXCEEDED = 0x30; 278 public static final int STATUS_CODE_DATA_RX_CRC_ERROR = 0x31; 279 280 /* UWB STS Mode Codes */ 281 public static final int STS_MODE_STATIC = 0x00; 282 public static final int STS_MODE_DYNAMIC = 0x01; 283 284 /** 285 * FiRa Major versions 286 */ 287 public static final int FIRA_VERSION_MAJOR_1 = 1; 288 public static final int FIRA_VERSION_MAJOR_2 = 2; 289 290 /* Used by DATA_TRANSFER_PHASE_CONFIG and Hybrid config updates */ 291 public static final int SHORT_MAC_ADDRESS = 0; 292 } 293