1 /* 2 * Copyright (C) 2024 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.aliro; 18 19 import android.os.Build.VERSION_CODES; 20 import android.os.PersistableBundle; 21 22 import androidx.annotation.IntDef; 23 import androidx.annotation.IntRange; 24 import androidx.annotation.RequiresApi; 25 26 import com.google.uwb.support.base.Params; 27 28 import java.lang.annotation.Retention; 29 import java.lang.annotation.RetentionPolicy; 30 31 /** 32 * Defines parameters for Aliro operation. 33 * 34 * This started out as a copy of {@code CccParams}. 35 */ 36 @RequiresApi(VERSION_CODES.LOLLIPOP) 37 public abstract class AliroParams extends Params { 38 public static final String PROTOCOL_NAME = "aliro"; 39 40 @Override getProtocolName()41 public final String getProtocolName() { 42 return PROTOCOL_NAME; 43 } 44 isCorrectProtocol(PersistableBundle bundle)45 public static boolean isCorrectProtocol(PersistableBundle bundle) { 46 return isProtocol(bundle, PROTOCOL_NAME); 47 } 48 isCorrectProtocol(String protocolName)49 public static boolean isCorrectProtocol(String protocolName) { 50 return protocolName.equals(PROTOCOL_NAME); 51 } 52 53 public static final AliroProtocolVersion PROTOCOL_VERSION_1_0 = new AliroProtocolVersion(1, 0); 54 55 /** Pulse Shapse (details below) */ 56 @Retention(RetentionPolicy.SOURCE) 57 @IntDef( 58 value = { 59 PULSE_SHAPE_SYMMETRICAL_ROOT_RAISED_COSINE, 60 PULSE_SHAPE_PRECURSOR_FREE, 61 PULSE_SHAPE_PRECURSOR_FREE_SPECIAL 62 }) 63 public @interface PulseShape {} 64 65 /** 66 * Indicates the symmetrical root raised cosine pulse shape as defined by Digital Key R3 Section 67 * 21.5. 68 */ 69 public static final int PULSE_SHAPE_SYMMETRICAL_ROOT_RAISED_COSINE = 0x0; 70 71 /** Indicates the precursor-free pulse shape as defined by Digital Key R3 Section 21.5. */ 72 public static final int PULSE_SHAPE_PRECURSOR_FREE = 0x1; 73 74 /** 75 * Indicates a special case of the precursor-free pulse shape as defined by Digital Key R3 76 * Section 21.5. 77 */ 78 public static final int PULSE_SHAPE_PRECURSOR_FREE_SPECIAL = 0x2; 79 80 /** Config (details below) */ 81 @Retention(RetentionPolicy.SOURCE) 82 @IntDef( 83 value = { 84 UWB_CONFIG_0, 85 UWB_CONFIG_1, 86 }) 87 public @interface UwbConfig {} 88 89 /** Indicates UWB Config 0 as defined by Digital Key R3 Section 21.4. */ 90 public static final int UWB_CONFIG_0 = 0; 91 92 /** Indicates UWB Config 1 as defined by Digital Key R3 Section 21.4. */ 93 public static final int UWB_CONFIG_1 = 1; 94 95 /** Channels */ 96 @Retention(RetentionPolicy.SOURCE) 97 @IntDef( 98 value = { 99 UWB_CHANNEL_5, 100 UWB_CHANNEL_9, 101 }) 102 public @interface Channel {} 103 104 public static final int UWB_CHANNEL_5 = 5; 105 public static final int UWB_CHANNEL_9 = 9; 106 107 /** Sync Codes */ 108 @Retention(RetentionPolicy.SOURCE) 109 @IntRange(from = 1, to = 32) 110 public @interface SyncCodeIndex {} 111 112 /** Hopping Config */ 113 @Retention(RetentionPolicy.SOURCE) 114 @IntDef( 115 value = { 116 HOPPING_CONFIG_MODE_NONE, 117 HOPPING_CONFIG_MODE_CONTINUOUS, 118 HOPPING_CONFIG_MODE_ADAPTIVE, 119 }) 120 public @interface HoppingConfigMode {} 121 122 public static final int HOPPING_CONFIG_MODE_NONE = 0; 123 public static final int HOPPING_CONFIG_MODE_CONTINUOUS = 1; 124 public static final int HOPPING_CONFIG_MODE_ADAPTIVE = 2; 125 126 /** Hopping Sequence */ 127 @Retention(RetentionPolicy.SOURCE) 128 @IntDef( 129 value = { 130 HOPPING_SEQUENCE_DEFAULT, 131 HOPPING_SEQUENCE_AES, 132 }) 133 public @interface HoppingSequence {} 134 135 public static final int HOPPING_SEQUENCE_DEFAULT = 0; 136 public static final int HOPPING_SEQUENCE_AES = 1; 137 138 /** Chaps per Slot (i.e. slot duration) */ 139 @Retention(RetentionPolicy.SOURCE) 140 @IntDef( 141 value = { 142 CHAPS_PER_SLOT_3, 143 CHAPS_PER_SLOT_4, 144 CHAPS_PER_SLOT_6, 145 CHAPS_PER_SLOT_8, 146 CHAPS_PER_SLOT_9, 147 CHAPS_PER_SLOT_12, 148 CHAPS_PER_SLOT_24, 149 }) 150 public @interface ChapsPerSlot {} 151 152 public static final int CHAPS_PER_SLOT_3 = 3; 153 public static final int CHAPS_PER_SLOT_4 = 4; 154 public static final int CHAPS_PER_SLOT_6 = 6; 155 public static final int CHAPS_PER_SLOT_8 = 8; 156 public static final int CHAPS_PER_SLOT_9 = 9; 157 public static final int CHAPS_PER_SLOT_12 = 12; 158 public static final int CHAPS_PER_SLOT_24 = 24; 159 160 /** Slots per Round */ 161 @Retention(RetentionPolicy.SOURCE) 162 @IntDef( 163 value = { 164 SLOTS_PER_ROUND_6, 165 SLOTS_PER_ROUND_8, 166 SLOTS_PER_ROUND_9, 167 SLOTS_PER_ROUND_12, 168 SLOTS_PER_ROUND_16, 169 SLOTS_PER_ROUND_18, 170 SLOTS_PER_ROUND_24, 171 SLOTS_PER_ROUND_32, 172 SLOTS_PER_ROUND_36, 173 SLOTS_PER_ROUND_48, 174 SLOTS_PER_ROUND_72, 175 SLOTS_PER_ROUND_96, 176 }) 177 public @interface SlotsPerRound {} 178 179 public static final int SLOTS_PER_ROUND_6 = 6; 180 public static final int SLOTS_PER_ROUND_8 = 8; 181 public static final int SLOTS_PER_ROUND_9 = 9; 182 public static final int SLOTS_PER_ROUND_12 = 12; 183 public static final int SLOTS_PER_ROUND_16 = 16; 184 public static final int SLOTS_PER_ROUND_18 = 18; 185 public static final int SLOTS_PER_ROUND_24 = 24; 186 public static final int SLOTS_PER_ROUND_32 = 32; 187 public static final int SLOTS_PER_ROUND_36 = 36; 188 public static final int SLOTS_PER_ROUND_48 = 48; 189 public static final int SLOTS_PER_ROUND_72 = 72; 190 public static final int SLOTS_PER_ROUND_96 = 96; 191 192 /** Error Reason */ 193 @Retention(RetentionPolicy.SOURCE) 194 @IntDef( 195 value = { 196 PROTOCOL_ERROR_UNKNOWN, 197 PROTOCOL_ERROR_SE_BUSY, 198 PROTOCOL_ERROR_LIFECYCLE, 199 PROTOCOL_ERROR_NOT_FOUND, 200 }) 201 public @interface ProtocolError {} 202 203 public static final int PROTOCOL_ERROR_UNKNOWN = 0; 204 public static final int PROTOCOL_ERROR_SE_BUSY = 1; 205 public static final int PROTOCOL_ERROR_LIFECYCLE = 2; 206 public static final int PROTOCOL_ERROR_NOT_FOUND = 3; 207 208 /** Session Type */ 209 @Retention(RetentionPolicy.SOURCE) 210 @IntDef( 211 value = {SESSION_TYPE_ALIRO}) 212 public @interface SessionType {} 213 214 /** Range Data Notification Config */ 215 @IntDef( 216 value = { 217 RANGE_DATA_NTF_CONFIG_DISABLE, 218 RANGE_DATA_NTF_CONFIG_ENABLE, 219 RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_LEVEL_TRIG, 220 RANGE_DATA_NTF_CONFIG_ENABLE_AOA_LEVEL_TRIG, 221 RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_LEVEL_TRIG, 222 RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_EDGE_TRIG, 223 RANGE_DATA_NTF_CONFIG_ENABLE_AOA_EDGE_TRIG, 224 RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_EDGE_TRIG, 225 }) 226 public @interface RangeDataNtfConfig {} 227 228 public static final int RANGE_DATA_NTF_CONFIG_DISABLE = 0; 229 public static final int RANGE_DATA_NTF_CONFIG_ENABLE = 1; 230 public static final int RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_LEVEL_TRIG = 2; 231 public static final int RANGE_DATA_NTF_CONFIG_ENABLE_AOA_LEVEL_TRIG = 3; 232 public static final int RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_LEVEL_TRIG = 4; 233 public static final int RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_EDGE_TRIG = 5; 234 public static final int RANGE_DATA_NTF_CONFIG_ENABLE_AOA_EDGE_TRIG = 6; 235 public static final int RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_EDGE_TRIG = 7; 236 237 public static final int RANGE_DATA_NTF_PROXIMITY_NEAR_DEFAULT = 0; 238 public static final int RANGE_DATA_NTF_PROXIMITY_FAR_DEFAULT = 20000; 239 public static final double RANGE_DATA_NTF_AOA_AZIMUTH_LOWER_DEFAULT = -Math.PI; 240 public static final double RANGE_DATA_NTF_AOA_AZIMUTH_UPPER_DEFAULT = Math.PI; 241 public static final double RANGE_DATA_NTF_AOA_ELEVATION_LOWER_DEFAULT = -Math.PI / 2; 242 public static final double RANGE_DATA_NTF_AOA_ELEVATION_UPPER_DEFAULT = Math.PI / 2; 243 244 public static final int SESSION_TYPE_ALIRO = 0xA2; 245 246 public static final long UWB_INITIATION_TIME_MS_UNSET = 0; 247 248 public static final int STS_INDEX_UNSET = 0; 249 } 250