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 17 package com.google.uwb.support.fira; 18 19 import android.os.Build.VERSION_CODES; 20 import android.os.PersistableBundle; 21 import android.uwb.UwbAddress; 22 23 import androidx.annotation.IntDef; 24 import androidx.annotation.RequiresApi; 25 26 import com.google.uwb.support.base.FlagEnum; 27 import com.google.uwb.support.base.Params; 28 29 import java.lang.annotation.Retention; 30 import java.lang.annotation.RetentionPolicy; 31 import java.nio.ByteBuffer; 32 import java.util.Arrays; 33 34 /** Defines parameters for FiRa operation */ 35 @RequiresApi(VERSION_CODES.LOLLIPOP) 36 public abstract class FiraParams extends Params { 37 public static final String PROTOCOL_NAME = "fira"; 38 39 @Override getProtocolName()40 public final String getProtocolName() { 41 return PROTOCOL_NAME; 42 } 43 isCorrectProtocol(PersistableBundle bundle)44 public static boolean isCorrectProtocol(PersistableBundle bundle) { 45 return isProtocol(bundle, PROTOCOL_NAME); 46 } 47 48 public static final FiraProtocolVersion PROTOCOL_VERSION_1_1 = new FiraProtocolVersion(1, 1); 49 50 /** Service ID for FiRa profile */ 51 @IntDef( 52 value = { 53 PACS_PROFILE_SERVICE_ID, 54 }) 55 public @interface ServiceID {} 56 57 public static final int PACS_PROFILE_SERVICE_ID = 1; 58 59 /** UWB Channel selections */ 60 @Retention(RetentionPolicy.SOURCE) 61 @IntDef( 62 value = { 63 UWB_CHANNEL_5, 64 UWB_CHANNEL_6, 65 UWB_CHANNEL_8, 66 UWB_CHANNEL_9, 67 UWB_CHANNEL_10, 68 UWB_CHANNEL_12, 69 UWB_CHANNEL_13, 70 UWB_CHANNEL_14, 71 }) 72 public @interface UwbChannel {} 73 74 public static final int UWB_CHANNEL_5 = 5; 75 public static final int UWB_CHANNEL_6 = 6; 76 public static final int UWB_CHANNEL_8 = 8; 77 public static final int UWB_CHANNEL_9 = 9; 78 public static final int UWB_CHANNEL_10 = 10; 79 public static final int UWB_CHANNEL_12 = 12; 80 public static final int UWB_CHANNEL_13 = 13; 81 public static final int UWB_CHANNEL_14 = 14; 82 83 /** UWB Channel selections */ 84 @Retention(RetentionPolicy.SOURCE) 85 @IntDef( 86 value = { 87 UWB_PREAMBLE_CODE_INDEX_9, 88 UWB_PREAMBLE_CODE_INDEX_10, 89 UWB_PREAMBLE_CODE_INDEX_11, 90 UWB_PREAMBLE_CODE_INDEX_12, 91 UWB_PREAMBLE_CODE_INDEX_25, 92 UWB_PREAMBLE_CODE_INDEX_26, 93 UWB_PREAMBLE_CODE_INDEX_27, 94 UWB_PREAMBLE_CODE_INDEX_28, 95 UWB_PREAMBLE_CODE_INDEX_29, 96 UWB_PREAMBLE_CODE_INDEX_30, 97 UWB_PREAMBLE_CODE_INDEX_31, 98 UWB_PREAMBLE_CODE_INDEX_32, 99 }) 100 public @interface UwbPreambleCodeIndex {} 101 102 public static final int UWB_PREAMBLE_CODE_INDEX_9 = 9; 103 public static final int UWB_PREAMBLE_CODE_INDEX_10 = 10; 104 public static final int UWB_PREAMBLE_CODE_INDEX_11 = 11; 105 public static final int UWB_PREAMBLE_CODE_INDEX_12 = 12; 106 public static final int UWB_PREAMBLE_CODE_INDEX_25 = 25; 107 public static final int UWB_PREAMBLE_CODE_INDEX_26 = 26; 108 public static final int UWB_PREAMBLE_CODE_INDEX_27 = 27; 109 public static final int UWB_PREAMBLE_CODE_INDEX_28 = 28; 110 public static final int UWB_PREAMBLE_CODE_INDEX_29 = 29; 111 public static final int UWB_PREAMBLE_CODE_INDEX_30 = 30; 112 public static final int UWB_PREAMBLE_CODE_INDEX_31 = 31; 113 public static final int UWB_PREAMBLE_CODE_INDEX_32 = 32; 114 115 /** Ranging frame type */ 116 @Retention(RetentionPolicy.SOURCE) 117 @IntDef( 118 value = { 119 RFRAME_CONFIG_SP0, 120 RFRAME_CONFIG_SP1, 121 RFRAME_CONFIG_SP3, 122 }) 123 public @interface RframeConfig {} 124 125 /** Ranging frame without STS */ 126 public static final int RFRAME_CONFIG_SP0 = 0; 127 128 /** Ranging frame with STS following SFD */ 129 public static final int RFRAME_CONFIG_SP1 = 1; 130 131 /** Ranging frame with STS following SFD, no data */ 132 public static final int RFRAME_CONFIG_SP3 = 3; 133 134 /** Device type defined in FiRa */ 135 @IntDef( 136 value = { 137 RANGING_DEVICE_TYPE_CONTROLEE, 138 RANGING_DEVICE_TYPE_CONTROLLER, 139 }) 140 public @interface RangingDeviceType {} 141 142 public static final int RANGING_DEVICE_TYPE_CONTROLEE = 0; 143 144 public static final int RANGING_DEVICE_TYPE_CONTROLLER = 1; 145 146 /** Device role defined in FiRa */ 147 @IntDef( 148 value = { 149 RANGING_DEVICE_ROLE_RESPONDER, 150 RANGING_DEVICE_ROLE_INITIATOR, 151 }) 152 public @interface RangingDeviceRole {} 153 154 public static final int RANGING_DEVICE_ROLE_RESPONDER = 0; 155 156 public static final int RANGING_DEVICE_ROLE_INITIATOR = 1; 157 158 /** Ranging Round Usage */ 159 @IntDef( 160 value = { 161 RANGING_ROUND_USAGE_SS_TWR_DEFERRED_MODE, 162 RANGING_ROUND_USAGE_DS_TWR_DEFERRED_MODE, 163 RANGING_ROUND_USAGE_SS_TWR_NON_DEFERRED_MODE, 164 RANGING_ROUND_USAGE_DS_TWR_NON_DEFERRED_MODE, 165 }) 166 public @interface RangingRoundUsage {} 167 168 /** Single-sided two-way ranging, deferred */ 169 public static final int RANGING_ROUND_USAGE_SS_TWR_DEFERRED_MODE = 1; 170 171 /** Double-sided two-way ranging, deferred */ 172 public static final int RANGING_ROUND_USAGE_DS_TWR_DEFERRED_MODE = 2; 173 174 /** Single-sided two-way ranging, non-deferred */ 175 public static final int RANGING_ROUND_USAGE_SS_TWR_NON_DEFERRED_MODE = 3; 176 177 /** Double-sided two-way ranging, non-deferred */ 178 public static final int RANGING_ROUND_USAGE_DS_TWR_NON_DEFERRED_MODE = 4; 179 180 /** Multi-Node mode */ 181 @IntDef( 182 value = { 183 MULTI_NODE_MODE_UNICAST, 184 MULTI_NODE_MODE_ONE_TO_MANY, 185 MULTI_NODE_MODE_MANY_TO_MANY, 186 }) 187 public @interface MultiNodeMode {} 188 189 public static final int MULTI_NODE_MODE_UNICAST = 0; 190 191 public static final int MULTI_NODE_MODE_ONE_TO_MANY = 1; 192 193 /** Unuported in Fira 1.1 */ 194 public static final int MULTI_NODE_MODE_MANY_TO_MANY = 2; 195 196 /** Measurement Report */ 197 @IntDef( 198 value = { 199 MEASUREMENT_REPORT_TYPE_INITIATOR_TO_RESPONDER, 200 MEASUREMENT_REPORT_TYPE_RESPONDER_TO_INITIATOR, 201 }) 202 public @interface MeasurementReportType {} 203 204 public static final int MEASUREMENT_REPORT_TYPE_INITIATOR_TO_RESPONDER = 0; 205 206 public static final int MEASUREMENT_REPORT_TYPE_RESPONDER_TO_INITIATOR = 1; 207 208 /** PRF Mode */ 209 @IntDef( 210 value = { 211 PRF_MODE_BPRF, 212 PRF_MODE_HPRF, 213 }) 214 public @interface PrfMode {} 215 216 public static final int PRF_MODE_BPRF = 0; 217 218 public static final int PRF_MODE_HPRF = 1; 219 220 /** Preamble duration: BPRF always uses 64 symbols */ 221 @IntDef( 222 value = { 223 PREAMBLE_DURATION_T32_SYMBOLS, 224 PREAMBLE_DURATION_T64_SYMBOLS, 225 }) 226 public @interface PreambleDuration {} 227 228 /** HPRF only */ 229 public static final int PREAMBLE_DURATION_T32_SYMBOLS = 0; 230 231 public static final int PREAMBLE_DURATION_T64_SYMBOLS = 1; 232 233 /** PSDU data Rate */ 234 @IntDef( 235 value = { 236 PSDU_DATA_RATE_6M81, 237 PSDU_DATA_RATE_7M80, 238 PSDU_DATA_RATE_27M2, 239 PSDU_DATA_RATE_31M2, 240 }) 241 public @interface PsduDataRate {} 242 243 /** 6.81 Mbps, default BPRF rate */ 244 public static final int PSDU_DATA_RATE_6M81 = 0; 245 246 /** 7.80 Mbps, BPRF rate with convolutional encoding K = 7 */ 247 public static final int PSDU_DATA_RATE_7M80 = 1; 248 249 /** 27.2 Mbps, default HPRF rate */ 250 public static final int PSDU_DATA_RATE_27M2 = 2; 251 252 /** 31.2 Mbps, HPRF rate with convolutional encoding K = 7 */ 253 public static final int PSDU_DATA_RATE_31M2 = 3; 254 255 /** BPRF PHY Header data rate */ 256 @IntDef( 257 value = { 258 BPRF_PHR_DATA_RATE_850K, 259 BPRF_PHR_DATA_RATE_6M81, 260 }) 261 public @interface BprfPhrDataRate {} 262 263 /** 850 kbps */ 264 public static final int BPRF_PHR_DATA_RATE_850K = 0; 265 266 /** 6.81 Mbps */ 267 public static final int BPRF_PHR_DATA_RATE_6M81 = 1; 268 269 /** MAC FCS type */ 270 @IntDef( 271 value = { 272 MAC_FCS_TYPE_CRC_16, 273 MAC_FCS_TYPE_CRC_32, 274 }) 275 public @interface MacFcsType {} 276 277 public static final int MAC_FCS_TYPE_CRC_16 = 0; 278 /** HPRF only */ 279 public static final int MAC_FCS_TYPE_CRC_32 = 1; 280 281 /** STS Config */ 282 @IntDef( 283 value = { 284 STS_CONFIG_STATIC, 285 STS_CONFIG_DYNAMIC, 286 STS_CONFIG_DYNAMIC_FOR_CONTROLEE_INDIVIDUAL_KEY, 287 }) 288 public @interface StsConfig {} 289 290 public static final int STS_CONFIG_STATIC = 0; 291 292 public static final int STS_CONFIG_DYNAMIC = 1; 293 294 public static final int STS_CONFIG_DYNAMIC_FOR_CONTROLEE_INDIVIDUAL_KEY = 2; 295 296 /** AoA request */ 297 @IntDef( 298 value = { 299 AOA_RESULT_REQUEST_MODE_NO_AOA_REPORT, 300 AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS, 301 AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_AZIMUTH_ONLY, 302 AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_ELEVATION_ONLY, 303 AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_INTERLEAVED, 304 }) 305 public @interface AoaResultRequestMode {} 306 307 public static final int AOA_RESULT_REQUEST_MODE_NO_AOA_REPORT = 0; 308 309 public static final int AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS = 1; 310 311 public static final int AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_AZIMUTH_ONLY = 2; 312 313 public static final int AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_ELEVATION_ONLY = 3; 314 315 public static final int AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_INTERLEAVED = 0xF0; 316 317 /** STS Segment count */ 318 @IntDef( 319 value = { 320 STS_SEGMENT_COUNT_VALUE_0, 321 STS_SEGMENT_COUNT_VALUE_1, 322 STS_SEGMENT_COUNT_VALUE_2, 323 }) 324 public @interface StsSegmentCountValue {} 325 326 public static final int STS_SEGMENT_COUNT_VALUE_0 = 0; 327 328 public static final int STS_SEGMENT_COUNT_VALUE_1 = 1; 329 330 public static final int STS_SEGMENT_COUNT_VALUE_2 = 2; 331 332 /** SFD ID */ 333 @IntDef( 334 value = { 335 SFD_ID_VALUE_1, 336 SFD_ID_VALUE_2, 337 SFD_ID_VALUE_3, 338 SFD_ID_VALUE_4, 339 }) 340 public @interface SfdIdValue {} 341 342 public static final int SFD_ID_VALUE_1 = 1; 343 public static final int SFD_ID_VALUE_2 = 2; 344 public static final int SFD_ID_VALUE_3 = 3; 345 public static final int SFD_ID_VALUE_4 = 4; 346 347 /** 348 * Hopping mode (Since FiRa supports vendor-specific values. This annotation is not enforced.) 349 */ 350 @IntDef( 351 value = { 352 HOPPING_MODE_DISABLE, 353 HOPPING_MODE_FIRA_HOPPING_ENABLE, 354 }) 355 public @interface HoppingMode {} 356 357 public static final int HOPPING_MODE_DISABLE = 0; 358 public static final int HOPPING_MODE_FIRA_HOPPING_ENABLE = 1; 359 360 /** STS Length */ 361 @IntDef( 362 value = { 363 STS_LENGTH_32_SYMBOLS, 364 STS_LENGTH_64_SYMBOLS, 365 STS_LENGTH_128_SYMBOLS, 366 }) 367 public @interface StsLength {} 368 369 public static final int STS_LENGTH_32_SYMBOLS = 0; 370 public static final int STS_LENGTH_64_SYMBOLS = 1; 371 public static final int STS_LENGTH_128_SYMBOLS = 2; 372 373 /** Range Data Notification Config */ 374 @IntDef( 375 value = { 376 RANGE_DATA_NTF_CONFIG_DISABLE, 377 RANGE_DATA_NTF_CONFIG_ENABLE, 378 RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY, 379 }) 380 public @interface RangeDataNtfConfig {} 381 382 public static final int RANGE_DATA_NTF_CONFIG_DISABLE = 0; 383 public static final int RANGE_DATA_NTF_CONFIG_ENABLE = 1; 384 public static final int RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY = 2; 385 386 /** MAC address mode: short (2 bytes) or extended (8 bytes) */ 387 @IntDef( 388 value = { 389 MAC_ADDRESS_MODE_2_BYTES, 390 MAC_ADDRESS_MODE_8_BYTES_2_BYTES_HEADER, 391 MAC_ADDRESS_MODE_8_BYTES, 392 }) 393 public @interface MacAddressMode {} 394 395 public static final int MAC_ADDRESS_MODE_2_BYTES = 0; 396 397 /** Not supported by UCI 1.0 */ 398 public static final int MAC_ADDRESS_MODE_8_BYTES_2_BYTES_HEADER = 1; 399 400 public static final int MAC_ADDRESS_MODE_8_BYTES = 2; 401 402 /** AoA type is not defined in UCI. This decides what AoA result we want to get */ 403 @IntDef( 404 value = { 405 AOA_TYPE_AZIMUTH, 406 AOA_TYPE_ELEVATION, 407 AOA_TYPE_AZIMUTH_AND_ELEVATION, 408 }) 409 public @interface AoaType {} 410 411 public static final int AOA_TYPE_AZIMUTH = 0; 412 public static final int AOA_TYPE_ELEVATION = 1; 413 414 /** 415 * How to get both angles is hardware dependent. Some hardware can get both angle in one round, 416 * some needs two rounds. 417 */ 418 public static final int AOA_TYPE_AZIMUTH_AND_ELEVATION = 2; 419 420 /** Status codes defined in UCI */ 421 @IntDef( 422 value = { 423 STATUS_CODE_OK, 424 STATUS_CODE_REJECTED, 425 STATUS_CODE_FAILED, 426 STATUS_CODE_SYNTAX_ERROR, 427 STATUS_CODE_INVALID_PARAM, 428 STATUS_CODE_INVALID_RANGE, 429 STATUS_CODE_INVALID_MESSAGE_SIZE, 430 STATUS_CODE_UNKNOWN_GID, 431 STATUS_CODE_UNKNOWN_OID, 432 STATUS_CODE_READ_ONLY, 433 STATUS_CODE_COMMAND_RETRY, 434 STATUS_CODE_ERROR_SESSION_NOT_EXIST, 435 STATUS_CODE_ERROR_SESSION_DUPLICATE, 436 STATUS_CODE_ERROR_SESSION_ACTIVE, 437 STATUS_CODE_ERROR_MAX_SESSIONS_EXCEEDED, 438 STATUS_CODE_ERROR_SESSION_NOT_CONFIGURED, 439 STATUS_CODE_ERROR_ACTIVE_SESSIONS_ONGOING, 440 STATUS_CODE_ERROR_MULTICAST_LIST_FULL, 441 STATUS_CODE_ERROR_ADDRESS_NOT_FOUND, 442 STATUS_CODE_ERROR_ADDRESS_ALREADY_PRESENT, 443 STATUS_CODE_RANGING_TX_FAILED, 444 STATUS_CODE_RANGING_RX_TIMEOUT, 445 STATUS_CODE_RANGING_RX_PHY_DEC_FAILED, 446 STATUS_CODE_RANGING_RX_PHY_TOA_FAILED, 447 STATUS_CODE_RANGING_RX_PHY_STS_FAILED, 448 STATUS_CODE_RANGING_RX_MAC_DEC_FAILED, 449 STATUS_CODE_RANGING_RX_MAC_IE_DEC_FAILED, 450 STATUS_CODE_RANGING_RX_MAC_IE_MISSING, 451 }) 452 public @interface StatusCode {} 453 454 public static final int STATUS_CODE_OK = 0x00; 455 public static final int STATUS_CODE_REJECTED = 0x01; 456 public static final int STATUS_CODE_FAILED = 0x02; 457 public static final int STATUS_CODE_SYNTAX_ERROR = 0x03; 458 public static final int STATUS_CODE_INVALID_PARAM = 0x04; 459 public static final int STATUS_CODE_INVALID_RANGE = 0x05; 460 public static final int STATUS_CODE_INVALID_MESSAGE_SIZE = 0x06; 461 public static final int STATUS_CODE_UNKNOWN_GID = 0x07; 462 public static final int STATUS_CODE_UNKNOWN_OID = 0x08; 463 public static final int STATUS_CODE_READ_ONLY = 0x09; 464 public static final int STATUS_CODE_COMMAND_RETRY = 0x0A; 465 public static final int STATUS_CODE_ERROR_SESSION_NOT_EXIST = 0x11; 466 public static final int STATUS_CODE_ERROR_SESSION_DUPLICATE = 0x12; 467 public static final int STATUS_CODE_ERROR_SESSION_ACTIVE = 0x13; 468 public static final int STATUS_CODE_ERROR_MAX_SESSIONS_EXCEEDED = 0x14; 469 public static final int STATUS_CODE_ERROR_SESSION_NOT_CONFIGURED = 0x15; 470 public static final int STATUS_CODE_ERROR_ACTIVE_SESSIONS_ONGOING = 0x16; 471 public static final int STATUS_CODE_ERROR_MULTICAST_LIST_FULL = 0x17; 472 public static final int STATUS_CODE_ERROR_ADDRESS_NOT_FOUND = 0x18; 473 public static final int STATUS_CODE_ERROR_ADDRESS_ALREADY_PRESENT = 0x19; 474 public static final int STATUS_CODE_RANGING_TX_FAILED = 0x20; 475 public static final int STATUS_CODE_RANGING_RX_TIMEOUT = 0x21; 476 public static final int STATUS_CODE_RANGING_RX_PHY_DEC_FAILED = 0x22; 477 public static final int STATUS_CODE_RANGING_RX_PHY_TOA_FAILED = 0x23; 478 public static final int STATUS_CODE_RANGING_RX_PHY_STS_FAILED = 0x24; 479 public static final int STATUS_CODE_RANGING_RX_MAC_DEC_FAILED = 0x25; 480 public static final int STATUS_CODE_RANGING_RX_MAC_IE_DEC_FAILED = 0x26; 481 public static final int STATUS_CODE_RANGING_RX_MAC_IE_MISSING = 0x27; 482 483 /** State change reason codes defined in UCI table-15 */ 484 @IntDef( 485 value = { 486 STATE_CHANGE_REASON_CODE_BY_COMMANDS, 487 STATE_CHANGE_REASON_CODE_MAX_RR_RETRY_REACHED, 488 STATE_CHANGE_REASON_CODE_ERROR_SLOT_LENGTH_NOT_SUPPORTED, 489 STATE_CHANGE_REASON_CODE_ERROR_INSUFFICIENT_SLOTS_PER_RR, 490 STATE_CHANGE_REASON_CODE_ERROR_MAC_ADDRESS_MODE_NOT_SUPPORTED, 491 STATE_CHANGE_REASON_CODE_ERROR_INVALID_RANGING_INTERVAL, 492 STATE_CHANGE_REASON_CODE_ERROR_INVALID_STS_CONFIG, 493 STATE_CHANGE_REASON_CODE_ERROR_INVALID_RFRAME_CONFIG, 494 }) 495 public @interface StateChangeReasonCode {} 496 497 public static final int STATE_CHANGE_REASON_CODE_BY_COMMANDS = 0; 498 public static final int STATE_CHANGE_REASON_CODE_MAX_RR_RETRY_REACHED = 1; 499 public static final int STATE_CHANGE_REASON_CODE_ERROR_SLOT_LENGTH_NOT_SUPPORTED = 0x20; 500 public static final int STATE_CHANGE_REASON_CODE_ERROR_INSUFFICIENT_SLOTS_PER_RR = 0x21; 501 public static final int STATE_CHANGE_REASON_CODE_ERROR_MAC_ADDRESS_MODE_NOT_SUPPORTED = 0x22; 502 public static final int STATE_CHANGE_REASON_CODE_ERROR_INVALID_RANGING_INTERVAL = 0x23; 503 public static final int STATE_CHANGE_REASON_CODE_ERROR_INVALID_STS_CONFIG = 0x24; 504 public static final int STATE_CHANGE_REASON_CODE_ERROR_INVALID_RFRAME_CONFIG = 0x25; 505 506 /** Multicast controlee add/delete actions defined in UCI */ 507 @IntDef( 508 value = { 509 MULTICAST_LIST_UPDATE_ACTION_ADD, 510 MULTICAST_LIST_UPDATE_ACTION_DELETE, 511 }) 512 public @interface MulticastListUpdateAction {} 513 514 public static final int MULTICAST_LIST_UPDATE_ACTION_ADD = 0; 515 public static final int MULTICAST_LIST_UPDATE_ACTION_DELETE = 1; 516 517 @IntDef( 518 value = { 519 MULTICAST_LIST_UPDATE_STATUS_OK, 520 MULTICAST_LIST_UPDATE_STATUS_ERROR_MULTICAST_LIST_FULL, 521 MULTICAST_LIST_UPDATE_STATUS_ERROR_KEY_FETCH_FAIL, 522 MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_ID_NOT_FOUND, 523 }) 524 public @interface MulticastListUpdateStatus {} 525 526 public static final int MULTICAST_LIST_UPDATE_STATUS_OK = 0; 527 public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_MULTICAST_LIST_FULL = 1; 528 public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_KEY_FETCH_FAIL = 2; 529 public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_ID_NOT_FOUND = 3; 530 531 /** Capability related definitions starts from here */ 532 @IntDef( 533 value = { 534 DEVICE_CLASS_1, 535 DEVICE_CLASS_2, 536 DEVICE_CLASS_3, 537 }) 538 public @interface DeviceClass {} 539 540 public static final int DEVICE_CLASS_1 = 1; // Controller & controlee 541 public static final int DEVICE_CLASS_2 = 2; // Controller 542 public static final int DEVICE_CLASS_3 = 3; // Controlee 543 544 public enum AoaCapabilityFlag implements FlagEnum { 545 HAS_AZIMUTH_SUPPORT(1), 546 HAS_ELEVATION_SUPPORT(1 << 1), 547 HAS_FOM_SUPPORT(1 << 2), 548 HAS_FULL_AZIMUTH_SUPPORT(1 << 3), 549 HAS_INTERLEAVING_SUPPORT(1 << 4); 550 551 private final long mValue; 552 AoaCapabilityFlag(long value)553 private AoaCapabilityFlag(long value) { 554 mValue = value; 555 } 556 557 @Override getValue()558 public long getValue() { 559 return mValue; 560 } 561 } 562 563 public enum DeviceRoleCapabilityFlag implements FlagEnum { 564 HAS_CONTROLEE_INITIATOR_SUPPORT(1), 565 HAS_CONTROLEE_RESPONDER_SUPPORT(1 << 1), 566 HAS_CONTROLLER_INITIATOR_SUPPORT(1 << 2), 567 HAS_CONTROLLER_RESPONDER_SUPPORT(1 << 3); 568 569 private final long mValue; 570 DeviceRoleCapabilityFlag(long value)571 private DeviceRoleCapabilityFlag(long value) { 572 mValue = value; 573 } 574 575 @Override getValue()576 public long getValue() { 577 return mValue; 578 } 579 } 580 581 public enum MultiNodeCapabilityFlag implements FlagEnum { 582 HAS_UNICAST_SUPPORT(1), 583 HAS_ONE_TO_MANY_SUPPORT(1 << 1), 584 HAS_MANY_TO_MANY_SUPPORT(1 << 2); 585 586 private final long mValue; 587 MultiNodeCapabilityFlag(long value)588 private MultiNodeCapabilityFlag(long value) { 589 mValue = value; 590 } 591 592 @Override getValue()593 public long getValue() { 594 return mValue; 595 } 596 } 597 598 public enum PrfCapabilityFlag implements FlagEnum { 599 HAS_BPRF_SUPPORT(1), 600 HAS_HPRF_SUPPORT(1 << 1); 601 602 private final long mValue; 603 PrfCapabilityFlag(long value)604 private PrfCapabilityFlag(long value) { 605 mValue = value; 606 } 607 608 @Override getValue()609 public long getValue() { 610 return mValue; 611 } 612 } 613 614 public enum RangingRoundCapabilityFlag implements FlagEnum { 615 HAS_DS_TWR_SUPPORT(1), 616 HAS_SS_TWR_SUPPORT(1 << 1); 617 618 private final long mValue; 619 RangingRoundCapabilityFlag(long value)620 private RangingRoundCapabilityFlag(long value) { 621 mValue = value; 622 } 623 624 @Override getValue()625 public long getValue() { 626 return mValue; 627 } 628 } 629 630 public enum RframeCapabilityFlag implements FlagEnum { 631 HAS_SP0_RFRAME_SUPPORT(1), 632 HAS_SP1_RFRAME_SUPPORT(1 << 1), 633 HAS_SP3_RFRAME_SUPPORT(1 << 3); 634 635 private final long mValue; 636 RframeCapabilityFlag(long value)637 private RframeCapabilityFlag(long value) { 638 mValue = value; 639 } 640 641 @Override getValue()642 public long getValue() { 643 return mValue; 644 } 645 } 646 647 public enum StsCapabilityFlag implements FlagEnum { 648 HAS_STATIC_STS_SUPPORT(1), 649 HAS_DYNAMIC_STS_SUPPORT(1 << 1), 650 HAS_DYNAMIC_STS_INDIVIDUAL_CONTROLEE_KEY_SUPPORT(1 << 2); 651 652 private final long mValue; 653 StsCapabilityFlag(long value)654 private StsCapabilityFlag(long value) { 655 mValue = value; 656 } 657 658 @Override getValue()659 public long getValue() { 660 return mValue; 661 } 662 } 663 664 public enum PsduDataRateCapabilityFlag implements FlagEnum { 665 HAS_6M81_SUPPORT(1), 666 HAS_7M80_SUPPORT(1 << 1), 667 HAS_27M2_SUPPORT(1 << 2), 668 HAS_31M2_SUPPORT(1 << 3); 669 670 private final long mValue; 671 PsduDataRateCapabilityFlag(long value)672 private PsduDataRateCapabilityFlag(long value) { 673 mValue = value; 674 } 675 676 @Override getValue()677 public long getValue() { 678 return mValue; 679 } 680 } 681 682 public enum BprfParameterSetCapabilityFlag implements FlagEnum { 683 HAS_SET_1_SUPPORT(1), 684 HAS_SET_2_SUPPORT(1 << 1), 685 HAS_SET_3_SUPPORT(1 << 2), 686 HAS_SET_4_SUPPORT(1 << 3), 687 HAS_SET_5_SUPPORT(1 << 4), 688 HAS_SET_6_SUPPORT(1 << 5); 689 690 private final long mValue; 691 BprfParameterSetCapabilityFlag(long value)692 private BprfParameterSetCapabilityFlag(long value) { 693 mValue = value; 694 } 695 696 @Override getValue()697 public long getValue() { 698 return mValue; 699 } 700 } 701 702 public enum HprfParameterSetCapabilityFlag implements FlagEnum { 703 HAS_SET_1_SUPPORT(1L), 704 HAS_SET_2_SUPPORT(1L << 1), 705 HAS_SET_3_SUPPORT(1L << 2), 706 HAS_SET_4_SUPPORT(1L << 3), 707 HAS_SET_5_SUPPORT(1L << 4), 708 HAS_SET_6_SUPPORT(1L << 5), 709 HAS_SET_7_SUPPORT(1L << 6), 710 HAS_SET_8_SUPPORT(1L << 7), 711 HAS_SET_9_SUPPORT(1L << 8), 712 HAS_SET_10_SUPPORT(1L << 9), 713 HAS_SET_11_SUPPORT(1L << 10), 714 HAS_SET_12_SUPPORT(1L << 11), 715 HAS_SET_13_SUPPORT(1L << 12), 716 HAS_SET_14_SUPPORT(1L << 13), 717 HAS_SET_15_SUPPORT(1L << 14), 718 HAS_SET_16_SUPPORT(1L << 15), 719 HAS_SET_17_SUPPORT(1L << 16), 720 HAS_SET_18_SUPPORT(1L << 17), 721 HAS_SET_19_SUPPORT(1L << 18), 722 HAS_SET_20_SUPPORT(1L << 19), 723 HAS_SET_21_SUPPORT(1L << 20), 724 HAS_SET_22_SUPPORT(1L << 21), 725 HAS_SET_23_SUPPORT(1L << 22), 726 HAS_SET_24_SUPPORT(1L << 23), 727 HAS_SET_25_SUPPORT(1L << 24), 728 HAS_SET_26_SUPPORT(1L << 25), 729 HAS_SET_27_SUPPORT(1L << 26), 730 HAS_SET_28_SUPPORT(1L << 27), 731 HAS_SET_29_SUPPORT(1L << 28), 732 HAS_SET_30_SUPPORT(1L << 29), 733 HAS_SET_31_SUPPORT(1L << 30), 734 HAS_SET_32_SUPPORT(1L << 31), 735 HAS_SET_33_SUPPORT(1L << 32), 736 HAS_SET_34_SUPPORT(1L << 33), 737 HAS_SET_35_SUPPORT(1L << 34); 738 739 private final long mValue; 740 HprfParameterSetCapabilityFlag(long value)741 private HprfParameterSetCapabilityFlag(long value) { 742 mValue = value; 743 } 744 745 @Override getValue()746 public long getValue() { 747 return mValue; 748 } 749 } 750 751 // Helper functions longToUwbAddress(long value, int length)752 protected static UwbAddress longToUwbAddress(long value, int length) { 753 ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES); 754 buffer.putLong(value); 755 return UwbAddress.fromBytes(Arrays.copyOf(buffer.array(), length)); 756 } 757 uwbAddressToLong(UwbAddress address)758 protected static long uwbAddressToLong(UwbAddress address) { 759 ByteBuffer buffer = ByteBuffer.wrap(Arrays.copyOf(address.toBytes(), Long.BYTES)); 760 return buffer.getLong(); 761 } 762 } 763