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.android.server.uwb.config; 18 19 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.BITS_PER_SAMPLE; 20 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.NUMBER_OF_BURSTS; 21 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.RADAR_CHANNEL_NUMBER; 22 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.RADAR_DATA_TYPE; 23 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.RADAR_PREAMBLE_CODE_INDEX; 24 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.RADAR_PREAMBLE_DURATION; 25 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.RADAR_PRF_MODE; 26 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.RADAR_RFRAME_CONFIG; 27 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.RADAR_SESSION_PRIORITY; 28 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.RADAR_TIMING_PARAMS; 29 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.SAMPLES_PER_SWEEP; 30 import static android.hardware.uwb.fira_android.UwbVendorRadarAppConfigTlvTypes.SWEEP_OFFSET; 31 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.CCC_HOP_MODE_KEY; 32 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.CCC_LAST_INDEX_USED; 33 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.CCC_PULSESHAPE_COMBO; 34 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.CCC_RANGING_PROTOCOL_VER; 35 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.CCC_URSK_TTL; 36 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.CCC_UWB_CONFIG_ID; 37 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.CCC_UWB_TIME0; 38 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.DIAGRAMS_FRAME_REPORTS_FIELDS; 39 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.ENABLE_DIAGNOSTICS; 40 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.NB_OF_AZIMUTH_MEASUREMENTS; 41 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.NB_OF_ELEVATION_MEASUREMENTS; 42 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvTypes.NB_OF_RANGE_MEASUREMENTS; 43 import static android.hardware.uwb.fira_android.UwbVendorSessionAppConfigTlvValues.AOA_RESULT_REQ_ANTENNA_INTERLEAVING; 44 45 import java.nio.ByteBuffer; 46 import java.util.Arrays; 47 48 public class ConfigParam { 49 50 /** 51 * App Config Parameter ID's 52 **/ 53 public static final int DEVICE_TYPE = 0x00; 54 public static final int RANGING_ROUND_USAGE = 0X01; 55 public static final int STS_CONFIG = 0X02; 56 public static final int MULTI_NODE_MODE = 0X03; 57 public static final int CHANNEL_NUMBER = 0x04; 58 public static final int NUMBER_OF_CONTROLEES = 0x05; 59 public static final int DEVICE_MAC_ADDRESS = 0x06; 60 public static final int DST_MAC_ADDRESS = 0x07; 61 public static final int SLOT_DURATION = 0x08; 62 public static final int RANGING_INTERVAL = 0x09; 63 public static final int STS_INDEX = 0x0A; 64 public static final int MAC_FCS_TYPE = 0x0B; 65 public static final int RANGING_ROUND_CONTROL = 0x0C; 66 public static final int AOA_RESULT_REQ = 0x0D; 67 public static final int RANGE_DATA_NTF_CONFIG = 0x0E; 68 public static final int RANGE_DATA_NTF_PROXIMITY_NEAR = 0x0F; 69 public static final int RANGE_DATA_NTF_PROXIMITY_FAR = 0x10; 70 public static final int DEVICE_ROLE = 0x11; 71 public static final int RFRAME_CONFIG = 0x12; 72 public static final int RSSI_REPORTING = 0x13; 73 public static final int PREAMBLE_CODE_INDEX = 0x14; 74 public static final int SFD_ID = 0x15; 75 public static final int PSDU_DATA_RATE = 0x16; 76 public static final int PREAMBLE_DURATION = 0x17; 77 public static final int LINK_LAYER_MODE = 0x18; 78 public static final int DATA_REPETITION_COUNT = 0x19; 79 public static final int RANGING_TIME_STRUCT = 0x1A; 80 public static final int SLOTS_PER_RR = 0x1B; 81 public static final int TX_ADAPTIVE_PAYLOAD_POWER = 0x1C; 82 // TODO: Ensure this value is correct in the final 2.0 specification. 83 public static final int RANGE_DATA_NTF_AOA_BOUND = 0x1D; 84 public static final int PRF_MODE = 0x1F; 85 public static final int CAP_SIZE_RANGE = 0x20; 86 public static final int SCHEDULED_MODE = 0x22; 87 public static final int KEY_ROTATION = 0x23; 88 public static final int KEY_ROTATION_RATE = 0x24; 89 public static final int SESSION_PRIORITY = 0x25; 90 public static final int MAC_ADDRESS_MODE = 0x26; 91 public static final int VENDOR_ID = 0x27; 92 public static final int STATIC_STS_IV = 0x28; 93 public static final int NUMBER_OF_STS_SEGMENTS = 0x29; 94 public static final int MAX_RR_RETRY = 0x2A; 95 public static final int UWB_INITIATION_TIME = 0x2B; 96 public static final int HOPPING_MODE = 0x2C; 97 public static final int BLOCK_STRIDE_LENGTH = 0x2D; 98 public static final int RESULT_REPORT_CONFIG = 0x2E; 99 public static final int IN_BAND_TERMINATION_ATTEMPT_COUNT = 0x2F; 100 public static final int SUB_SESSION_ID = 0x30; 101 public static final int BPRF_PHR_DATA_RATE = 0x31; 102 public static final int MAX_NUMBER_OF_MEASUREMENTS = 0x32; 103 public static final int UL_TDOA_TX_INTERVAL = 0x33; 104 public static final int UL_TDOA_RANDOM_WINDOW = 0x34; 105 public static final int STS_LENGTH = 0x35; 106 public static final int SUSPEND_RANGING_ROUNDS = 0x36; 107 public static final int UL_TDOA_DEVICE_ID = 0x38; 108 public static final int UL_TDOA_TX_TIMESTAMP = 0x39; 109 public static final int MIN_FRAMES_PER_RR = 0x3A; 110 public static final int MTU_SIZE = 0x3B; 111 public static final int INTER_FRAME_INTERVAL = 0x3C; 112 public static final int DL_TDOA_BLOCK_STRIDING = 0x43; 113 public static final int SESSION_KEY = 0x45; 114 public static final int SUBSESSION_KEY = 0x46; 115 public static final int SESSION_DATA_TRANSFER_STATUS_NTF_CONFIG = 0x47; 116 public static final int SESSION_TIME_BASE = 0x48; 117 public static final int APPLICATION_DATA_ENDPOINT = 0x4C; 118 119 // Android specific params. 120 public static final int NUM_RANGE_MEASUREMENTS = NB_OF_RANGE_MEASUREMENTS; 121 public static final int NUM_AOA_AZIMUTH_MEASUREMENTS = NB_OF_AZIMUTH_MEASUREMENTS; 122 public static final int NUM_AOA_ELEVATION_MEASUREMENTS = NB_OF_ELEVATION_MEASUREMENTS; 123 124 public static final int ENABLE_DIAGNOSTICS_RSSI = ENABLE_DIAGNOSTICS; 125 public static final int ENABLE_DIAGRAMS_FRAME_REPORTS_FIELDS = DIAGRAMS_FRAME_REPORTS_FIELDS; 126 public static final int ANTENNA_MODE = android.hardware.uwb.fira_android 127 .UwbVendorSessionAppConfigTlvTypes.ANTENNA_MODE; 128 129 public static final int VENDOR_ID_BYTE_COUNT = 2; 130 public static final int STATIC_STS_IV_BYTE_COUNT = 6; 131 public static final int AOA_RESULT_REQ_INTERLEAVING = AOA_RESULT_REQ_ANTENNA_INTERLEAVING; 132 133 // CCC 134 //OpenParams 135 public static final int RANGING_PROTOCOL_VER = CCC_RANGING_PROTOCOL_VER; 136 public static final int UWB_CONFIG_ID = CCC_UWB_CONFIG_ID; 137 public static final int PULSESHAPE_COMBO = CCC_PULSESHAPE_COMBO; 138 public static final int URSK_TTL = CCC_URSK_TTL; 139 public static final int LAST_STS_INDEX_USED = CCC_LAST_INDEX_USED; 140 //StartedParams 141 public static final int HOP_MODE_KEY = CCC_HOP_MODE_KEY; 142 public static final int HOP_MODE_KEY_BYTE = 16; 143 public static final int UWB_TIME0 = CCC_UWB_TIME0; 144 145 public static final int RANGING_PROTOCOL_VER_BYTE_COUNT = 2; 146 147 // Radar App Config Parameter IDs 148 public static final int RADAR_TIMING_PARAMS_KEY = RADAR_TIMING_PARAMS; 149 public static final int SAMPLES_PER_SWEEP_KEY = SAMPLES_PER_SWEEP; 150 public static final int CHANNEL_NUMBER_KEY = RADAR_CHANNEL_NUMBER; 151 public static final int SWEEP_OFFSET_KEY = SWEEP_OFFSET; 152 public static final int RFRAME_CONFIG_KEY = RADAR_RFRAME_CONFIG; 153 public static final int PREAMBLE_DURATION_KEY = RADAR_PREAMBLE_DURATION; 154 public static final int PREAMBLE_CODE_INDEX_KEY = RADAR_PREAMBLE_CODE_INDEX; 155 public static final int SESSION_PRIORITY_KEY = RADAR_SESSION_PRIORITY; 156 public static final int BITS_PER_SAMPLE_KEY = BITS_PER_SAMPLE; 157 public static final int PRF_MODE_KEY = RADAR_PRF_MODE; 158 public static final int NUMBER_OF_BURSTS_KEY = NUMBER_OF_BURSTS; 159 public static final int RADAR_DATA_TYPE_KEY = RADAR_DATA_TYPE; 160 getTagBytes(int tagType)161 public static byte[] getTagBytes(int tagType) { 162 int tagLength = 1; 163 ByteBuffer buffer = ByteBuffer.allocate(Integer.BYTES).putInt(tagType); 164 return Arrays.copyOfRange(buffer.array(), Integer.BYTES - tagLength, Integer.BYTES); 165 } 166 } 167