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     public static final FiraProtocolVersion PROTOCOL_VERSION_2_0 = new FiraProtocolVersion(2, 0);
50 
51     /** Service ID for FiRa profile */
52     @IntDef(
53             value = {
54                     PACS_PROFILE_SERVICE_ID,
55             })
56     public @interface ServiceID {}
57 
58     public static final int PACS_PROFILE_SERVICE_ID = 1;
59 
60     /** UWB Channel selections */
61     @Retention(RetentionPolicy.SOURCE)
62     @IntDef(
63             value = {
64                 UWB_CHANNEL_5,
65                 UWB_CHANNEL_6,
66                 UWB_CHANNEL_8,
67                 UWB_CHANNEL_9,
68                 UWB_CHANNEL_10,
69                 UWB_CHANNEL_12,
70                 UWB_CHANNEL_13,
71                 UWB_CHANNEL_14,
72             })
73     public @interface UwbChannel {}
74 
75     public static final int UWB_CHANNEL_5 = 5;
76     public static final int UWB_CHANNEL_6 = 6;
77     public static final int UWB_CHANNEL_8 = 8;
78     public static final int UWB_CHANNEL_9 = 9;
79     public static final int UWB_CHANNEL_10 = 10;
80     public static final int UWB_CHANNEL_12 = 12;
81     public static final int UWB_CHANNEL_13 = 13;
82     public static final int UWB_CHANNEL_14 = 14;
83 
84     /** UWB Channel selections */
85     @Retention(RetentionPolicy.SOURCE)
86     @IntDef(
87             value = {
88                 UWB_PREAMBLE_CODE_INDEX_9,
89                 UWB_PREAMBLE_CODE_INDEX_10,
90                 UWB_PREAMBLE_CODE_INDEX_11,
91                 UWB_PREAMBLE_CODE_INDEX_12,
92                 UWB_PREAMBLE_CODE_INDEX_25,
93                 UWB_PREAMBLE_CODE_INDEX_26,
94                 UWB_PREAMBLE_CODE_INDEX_27,
95                 UWB_PREAMBLE_CODE_INDEX_28,
96                 UWB_PREAMBLE_CODE_INDEX_29,
97                 UWB_PREAMBLE_CODE_INDEX_30,
98                 UWB_PREAMBLE_CODE_INDEX_31,
99                 UWB_PREAMBLE_CODE_INDEX_32,
100             })
101     public @interface UwbPreambleCodeIndex {}
102 
103     public static final int UWB_PREAMBLE_CODE_INDEX_9 = 9;
104     public static final int UWB_PREAMBLE_CODE_INDEX_10 = 10;
105     public static final int UWB_PREAMBLE_CODE_INDEX_11 = 11;
106     public static final int UWB_PREAMBLE_CODE_INDEX_12 = 12;
107     public static final int UWB_PREAMBLE_CODE_INDEX_25 = 25;
108     public static final int UWB_PREAMBLE_CODE_INDEX_26 = 26;
109     public static final int UWB_PREAMBLE_CODE_INDEX_27 = 27;
110     public static final int UWB_PREAMBLE_CODE_INDEX_28 = 28;
111     public static final int UWB_PREAMBLE_CODE_INDEX_29 = 29;
112     public static final int UWB_PREAMBLE_CODE_INDEX_30 = 30;
113     public static final int UWB_PREAMBLE_CODE_INDEX_31 = 31;
114     public static final int UWB_PREAMBLE_CODE_INDEX_32 = 32;
115 
116     /** Ranging frame type */
117     @Retention(RetentionPolicy.SOURCE)
118     @IntDef(
119             value = {
120                 RFRAME_CONFIG_SP0,
121                 RFRAME_CONFIG_SP1,
122                 RFRAME_CONFIG_SP3,
123             })
124     public @interface RframeConfig {}
125 
126     /** Ranging frame without STS */
127     public static final int RFRAME_CONFIG_SP0 = 0;
128 
129     /** Ranging frame with STS following SFD */
130     public static final int RFRAME_CONFIG_SP1 = 1;
131 
132     /** Ranging frame with STS following SFD, no data */
133     public static final int RFRAME_CONFIG_SP3 = 3;
134 
135     /** Device type defined in FiRa */
136     @IntDef(
137             value = {
138                 RANGING_DEVICE_TYPE_CONTROLEE,
139                 RANGING_DEVICE_TYPE_CONTROLLER,
140                 RANGING_DEVICE_TYPE_DT_TAG,
141             })
142     public @interface RangingDeviceType {}
143 
144     public static final int RANGING_DEVICE_TYPE_CONTROLEE = 0;
145 
146     public static final int RANGING_DEVICE_TYPE_CONTROLLER = 1;
147 
148     public static final int RANGING_DEVICE_TYPE_DT_TAG = 2;
149 
150     /** Device role defined in FiRa */
151     @IntDef(
152             value = {
153                 RANGING_DEVICE_ROLE_RESPONDER,
154                 RANGING_DEVICE_ROLE_INITIATOR,
155                 RANGING_DEVICE_UT_TAG,
156                 RANGING_DEVICE_ROLE_ADVERTISER,
157                 RANGING_DEVICE_ROLE_OBSERVER,
158                 RANGING_DEVICE_DT_ANCHOR,
159                 RANGING_DEVICE_DT_TAG,
160             })
161     public @interface RangingDeviceRole {}
162 
163     public static final int RANGING_DEVICE_ROLE_RESPONDER = 0;
164 
165     public static final int RANGING_DEVICE_ROLE_INITIATOR = 1;
166 
167     public static final int RANGING_DEVICE_UT_TAG = 4;
168 
169     public static final int RANGING_DEVICE_ROLE_ADVERTISER = 5;
170 
171     public static final int RANGING_DEVICE_ROLE_OBSERVER = 6;
172 
173     public static final int RANGING_DEVICE_DT_ANCHOR = 7;
174 
175     public static final int RANGING_DEVICE_DT_TAG = 8;
176 
177     /** Ranging Round Usage */
178     @IntDef(
179             value = {
180                 RANGING_ROUND_USAGE_UL_TDOA,
181                 RANGING_ROUND_USAGE_SS_TWR_DEFERRED_MODE,
182                 RANGING_ROUND_USAGE_DS_TWR_DEFERRED_MODE,
183                 RANGING_ROUND_USAGE_SS_TWR_NON_DEFERRED_MODE,
184                 RANGING_ROUND_USAGE_DS_TWR_NON_DEFERRED_MODE,
185                 RANGING_ROUND_USAGE_OWR_AOA_MEASUREMENT,
186                 RANGING_ROUND_USAGE_DL_TDOA,
187                 RANGING_ROUND_USAGE_DATA_TRANSFER_MODE,
188             })
189     public @interface RangingRoundUsage {}
190 
191     /** Uplink Time Difference of Arrival (OWR) */
192     public static final int RANGING_ROUND_USAGE_UL_TDOA = 0;
193 
194     /** Single-sided two-way ranging, deferred */
195     public static final int RANGING_ROUND_USAGE_SS_TWR_DEFERRED_MODE = 1;
196 
197     /** Double-sided two-way ranging, deferred */
198     public static final int RANGING_ROUND_USAGE_DS_TWR_DEFERRED_MODE = 2;
199 
200     /** Single-sided two-way ranging, non-deferred */
201     public static final int RANGING_ROUND_USAGE_SS_TWR_NON_DEFERRED_MODE = 3;
202 
203     /** Double-sided two-way ranging, non-deferred */
204     public static final int RANGING_ROUND_USAGE_DS_TWR_NON_DEFERRED_MODE = 4;
205 
206     /** Downlink Time Difference of Arrival */
207     public static final int RANGING_ROUND_USAGE_DL_TDOA = 5;
208 
209     /** OWR for AoA measurement */
210     public static final int RANGING_ROUND_USAGE_OWR_AOA_MEASUREMENT = 6;
211 
212     /** Data transfer mode */
213     public static final int RANGING_ROUND_USAGE_DATA_TRANSFER_MODE = 9;
214 
215     /** Multi-Node mode */
216     @IntDef(
217             value = {
218                 MULTI_NODE_MODE_UNICAST,
219                 MULTI_NODE_MODE_ONE_TO_MANY,
220                 MULTI_NODE_MODE_MANY_TO_MANY,
221             })
222     public @interface MultiNodeMode {}
223 
224     public static final int MULTI_NODE_MODE_UNICAST = 0;
225 
226     public static final int MULTI_NODE_MODE_ONE_TO_MANY = 1;
227 
228     /** Unuported in Fira 1.1 */
229     public static final int MULTI_NODE_MODE_MANY_TO_MANY = 2;
230 
231     /** Scheduling Mode */
232     @IntDef(
233             value = {
234                 CONTENTION_BASED_RANGING,
235                 TIME_SCHEDULED_RANGING,
236                 HYBRID_SCHEDULED_RANGING,
237             })
238     public @interface SchedulingMode {}
239 
240     public static final int CONTENTION_BASED_RANGING = 0;
241 
242     public static final int TIME_SCHEDULED_RANGING = 1;
243 
244     public static final int HYBRID_SCHEDULED_RANGING = 2;
245 
246     /** Ranging Time Struct */
247     @IntDef(
248             value = {
249                 INTERVAL_BASED_SCHEDULING,
250                 BLOCK_BASED_SCHEDULING,
251             })
252     public @interface RangingTimeStruct {}
253 
254     public static final int INTERVAL_BASED_SCHEDULING = 0;
255 
256     public static final int BLOCK_BASED_SCHEDULING = 1;
257 
258     /** Hybrid session controller phase participation */
259     @IntDef(
260             value = {
261                 PARTICIPATION_AS_DEFINED_DEVICE_ROLE,
262                 NO_PARTICIPATION_IN_THE_PHASE,
263                 PARTICIPATION_AS_INITIATOR,
264                 PARTICIPATION_AS_RESPONDER,
265             })
266     public @interface PhaseParticipationHybridSessionController {}
267 
268     public static final int PARTICIPATION_AS_DEFINED_DEVICE_ROLE = 0;
269 
270     public static final int NO_PARTICIPATION_IN_THE_PHASE = 1;
271 
272     public static final int PARTICIPATION_AS_INITIATOR = 2;
273 
274     public static final int PARTICIPATION_AS_RESPONDER = 3;
275 
276     /** Cc Constraint Length */
277     @IntDef(
278             value = {
279                 CONSTRAINT_LENGTH_3,
280                 CONSTRAINT_LENGTH_7,
281             })
282     public @interface CcConstraintLength {}
283 
284     public static final int CONSTRAINT_LENGTH_3 = 3;
285 
286     public static final int CONSTRAINT_LENGTH_7 = 7;
287 
288     /** Measurement Report Type */
289     @IntDef(
290             value = {
291                 MEASUREMENT_REPORT_TYPE_INITIATOR_TO_RESPONDER,
292                 MEASUREMENT_REPORT_TYPE_RESPONDER_TO_INITIATOR,
293             })
294     public @interface MeasurementReportType {}
295 
296     public static final int MEASUREMENT_REPORT_TYPE_INITIATOR_TO_RESPONDER = 0;
297 
298     public static final int MEASUREMENT_REPORT_TYPE_RESPONDER_TO_INITIATOR = 1;
299 
300     /** Measurement Report Phase */
301     @IntDef(
302             value = {
303                 MEASUREMENT_REPORT_PHASE_NOTSET,
304                 MEASUREMENT_REPORT_PHASE_SET,
305             })
306     public @interface MeasurementReportPhase {}
307 
308     public static final int MEASUREMENT_REPORT_PHASE_NOTSET = 0;
309 
310     public static final int MEASUREMENT_REPORT_PHASE_SET = 1;
311 
312     /** PRF Mode */
313     @IntDef(
314             value = {
315                 PRF_MODE_BPRF,
316                 PRF_MODE_HPRF,
317                 PRF_MODE_HPRF_HIGH_DATA_RATE,
318             })
319     public @interface PrfMode {}
320 
321     public static final int PRF_MODE_BPRF = 0;
322 
323     public static final int PRF_MODE_HPRF = 1;
324 
325     public static final int PRF_MODE_HPRF_HIGH_DATA_RATE = 2;
326 
327     /** Preamble duration: BPRF always uses 64 symbols */
328     @IntDef(
329             value = {
330                 PREAMBLE_DURATION_T32_SYMBOLS,
331                 PREAMBLE_DURATION_T64_SYMBOLS,
332             })
333     public @interface PreambleDuration {}
334 
335     /** HPRF only */
336     public static final int PREAMBLE_DURATION_T32_SYMBOLS = 0;
337 
338     public static final int PREAMBLE_DURATION_T64_SYMBOLS = 1;
339 
340     /** PSDU data Rate */
341     @IntDef(
342             value = {
343                 PSDU_DATA_RATE_6M81,
344                 PSDU_DATA_RATE_7M80,
345                 PSDU_DATA_RATE_27M2,
346                 PSDU_DATA_RATE_31M2,
347             })
348     public @interface PsduDataRate {}
349 
350     /** 6.81 Mbps, default BPRF rate */
351     public static final int PSDU_DATA_RATE_6M81 = 0;
352 
353     /** 7.80 Mbps, BPRF rate with convolutional encoding K = 7 */
354     public static final int PSDU_DATA_RATE_7M80 = 1;
355 
356     /** 27.2 Mbps, default HPRF rate */
357     public static final int PSDU_DATA_RATE_27M2 = 2;
358 
359     /** 31.2 Mbps, HPRF rate with convolutional encoding K = 7 */
360     public static final int PSDU_DATA_RATE_31M2 = 3;
361 
362     /** BPRF PHY Header data rate */
363     @IntDef(
364             value = {
365                 BPRF_PHR_DATA_RATE_850K,
366                 BPRF_PHR_DATA_RATE_6M81,
367             })
368     public @interface BprfPhrDataRate {}
369 
370     /** 850 kbps */
371     public static final int BPRF_PHR_DATA_RATE_850K = 0;
372 
373     /** 6.81 Mbps */
374     public static final int BPRF_PHR_DATA_RATE_6M81 = 1;
375 
376     /** MAC FCS type */
377     @IntDef(
378             value = {
379                 MAC_FCS_TYPE_CRC_16,
380                 MAC_FCS_TYPE_CRC_32,
381             })
382     public @interface MacFcsType {}
383 
384     public static final int MAC_FCS_TYPE_CRC_16 = 0;
385     /** HPRF only */
386     public static final int MAC_FCS_TYPE_CRC_32 = 1;
387 
388     /** STS Config */
389     @IntDef(
390             value = {
391                 STS_CONFIG_STATIC,
392                 STS_CONFIG_DYNAMIC,
393                 STS_CONFIG_DYNAMIC_FOR_CONTROLEE_INDIVIDUAL_KEY,
394                 STS_CONFIG_PROVISIONED,
395                 STS_CONFIG_PROVISIONED_FOR_CONTROLEE_INDIVIDUAL_KEY,
396             })
397     public @interface StsConfig {}
398 
399     public static final int STS_CONFIG_STATIC = 0;
400 
401     public static final int STS_CONFIG_DYNAMIC = 1;
402 
403     public static final int STS_CONFIG_DYNAMIC_FOR_CONTROLEE_INDIVIDUAL_KEY = 2;
404 
405     public static final int STS_CONFIG_PROVISIONED = 3;
406 
407     public static final int STS_CONFIG_PROVISIONED_FOR_CONTROLEE_INDIVIDUAL_KEY = 4;
408 
409     /** AoA request */
410     @IntDef(
411             value = {
412                 AOA_RESULT_REQUEST_MODE_NO_AOA_REPORT,
413                 AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS,
414                 AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_AZIMUTH_ONLY,
415                 AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_ELEVATION_ONLY,
416                 AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_INTERLEAVED,
417             })
418     public @interface AoaResultRequestMode {}
419 
420     public static final int AOA_RESULT_REQUEST_MODE_NO_AOA_REPORT = 0;
421 
422     public static final int AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS = 1;
423 
424     public static final int AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_AZIMUTH_ONLY = 2;
425 
426     public static final int AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_ELEVATION_ONLY = 3;
427 
428     public static final int AOA_RESULT_REQUEST_MODE_REQ_AOA_RESULTS_INTERLEAVED = 0xF0;
429 
430     /** STS Segment count */
431     @IntDef(
432             value = {
433                 STS_SEGMENT_COUNT_VALUE_0,
434                 STS_SEGMENT_COUNT_VALUE_1,
435                 STS_SEGMENT_COUNT_VALUE_2,
436             })
437     public @interface StsSegmentCountValue {}
438 
439     public static final int STS_SEGMENT_COUNT_VALUE_0 = 0;
440 
441     public static final int STS_SEGMENT_COUNT_VALUE_1 = 1;
442 
443     public static final int STS_SEGMENT_COUNT_VALUE_2 = 2;
444 
445     /** SFD ID */
446     @IntDef(
447             value = {
448                 SFD_ID_VALUE_0,
449                 SFD_ID_VALUE_1,
450                 SFD_ID_VALUE_2,
451                 SFD_ID_VALUE_3,
452                 SFD_ID_VALUE_4,
453             })
454     public @interface SfdIdValue {}
455 
456     public static final int SFD_ID_VALUE_0 = 0;
457     public static final int SFD_ID_VALUE_1 = 1;
458     public static final int SFD_ID_VALUE_2 = 2;
459     public static final int SFD_ID_VALUE_3 = 3;
460     public static final int SFD_ID_VALUE_4 = 4;
461 
462     /**
463      * Hopping mode (Since FiRa supports vendor-specific values. This annotation is not enforced.)
464      */
465     @IntDef(
466             value = {
467                 HOPPING_MODE_DISABLE,
468                 HOPPING_MODE_FIRA_HOPPING_ENABLE,
469             })
470     public @interface HoppingMode {}
471 
472       /** UCI spec default: 25 slots per ranging round. */
473     public static final int SLOTS_PER_RR = 25;
474     public static final int MIN_CAP_SIZE = 5;
475     public static final int HOPPING_MODE_DISABLE = 0;
476     public static final int HOPPING_MODE_FIRA_HOPPING_ENABLE = 1;
477 
478     /** STS Length */
479     @IntDef(
480             value = {
481                 STS_LENGTH_32_SYMBOLS,
482                 STS_LENGTH_64_SYMBOLS,
483                 STS_LENGTH_128_SYMBOLS,
484             })
485     public @interface StsLength {}
486 
487     public static final int STS_LENGTH_32_SYMBOLS = 0;
488     public static final int STS_LENGTH_64_SYMBOLS = 1;
489     public static final int STS_LENGTH_128_SYMBOLS = 2;
490 
491     /** Range Data Notification Config */
492     @IntDef(
493             value = {
494                 RANGE_DATA_NTF_CONFIG_DISABLE,
495                 RANGE_DATA_NTF_CONFIG_ENABLE,
496                 RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_LEVEL_TRIG,
497                 RANGE_DATA_NTF_CONFIG_ENABLE_AOA_LEVEL_TRIG,
498                 RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_LEVEL_TRIG,
499                 RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_EDGE_TRIG,
500                 RANGE_DATA_NTF_CONFIG_ENABLE_AOA_EDGE_TRIG,
501                 RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_EDGE_TRIG,
502             })
503     public @interface RangeDataNtfConfig {}
504 
505     public static final int RANGE_DATA_NTF_CONFIG_DISABLE = 0;
506     public static final int RANGE_DATA_NTF_CONFIG_ENABLE = 1;
507     public static final int RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_LEVEL_TRIG = 2;
508     public static final int RANGE_DATA_NTF_CONFIG_ENABLE_AOA_LEVEL_TRIG = 3;
509     public static final int RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_LEVEL_TRIG = 4;
510     public static final int RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_EDGE_TRIG = 5;
511     public static final int RANGE_DATA_NTF_CONFIG_ENABLE_AOA_EDGE_TRIG = 6;
512     public static final int RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_EDGE_TRIG = 7;
513 
514     /** MAC address mode: short (2 bytes) or extended (8 bytes) */
515     @IntDef(
516             value = {
517                 MAC_ADDRESS_MODE_2_BYTES,
518                 MAC_ADDRESS_MODE_8_BYTES_2_BYTES_HEADER,
519                 MAC_ADDRESS_MODE_8_BYTES,
520             })
521     public @interface MacAddressMode {}
522 
523     public static final int MAC_ADDRESS_MODE_2_BYTES = 0;
524 
525     /** Not supported by UCI 1.0 */
526     public static final int MAC_ADDRESS_MODE_8_BYTES_2_BYTES_HEADER = 1;
527 
528     public static final int MAC_ADDRESS_MODE_8_BYTES = 2;
529 
530     /** AoA type is not defined in UCI. This decides what AoA result we want to get */
531     @IntDef(
532             value = {
533                 AOA_TYPE_AZIMUTH,
534                 AOA_TYPE_ELEVATION,
535                 AOA_TYPE_AZIMUTH_AND_ELEVATION,
536             })
537     public @interface AoaType {}
538 
539     public static final int AOA_TYPE_AZIMUTH = 0;
540     public static final int AOA_TYPE_ELEVATION = 1;
541 
542     /**
543      * How to get both angles is hardware dependent. Some hardware can get both angle in one round,
544      * some needs two rounds.
545      */
546     public static final int AOA_TYPE_AZIMUTH_AND_ELEVATION = 2;
547 
548     /** Status codes defined in UCI */
549     @IntDef(
550             value = {
551                 STATUS_CODE_OK,
552                 STATUS_CODE_REJECTED,
553                 STATUS_CODE_FAILED,
554                 STATUS_CODE_SYNTAX_ERROR,
555                 STATUS_CODE_INVALID_PARAM,
556                 STATUS_CODE_INVALID_RANGE,
557                 STATUS_CODE_INVALID_MESSAGE_SIZE,
558                 STATUS_CODE_UNKNOWN_GID,
559                 STATUS_CODE_UNKNOWN_OID,
560                 STATUS_CODE_READ_ONLY,
561                 STATUS_CODE_COMMAND_RETRY,
562                 STATUS_CODE_UNKNOWN,
563                 STATUS_CODE_ERROR_SESSION_NOT_EXIST,
564                 STATUS_CODE_ERROR_SESSION_DUPLICATE,
565                 STATUS_CODE_ERROR_SESSION_ACTIVE,
566                 STATUS_CODE_ERROR_MAX_SESSIONS_EXCEEDED,
567                 STATUS_CODE_ERROR_SESSION_NOT_CONFIGURED,
568                 STATUS_CODE_ERROR_ACTIVE_SESSIONS_ONGOING,
569                 STATUS_CODE_ERROR_MULTICAST_LIST_FULL,
570                 STATUS_CODE_ERROR_ADDRESS_NOT_FOUND,
571                 STATUS_CODE_ERROR_ADDRESS_ALREADY_PRESENT,
572                 STATUS_CODE_OK_NEGATIVE_DISTANCE_REPORT,
573                 STATUS_CODE_RANGING_TX_FAILED,
574                 STATUS_CODE_RANGING_RX_TIMEOUT,
575                 STATUS_CODE_RANGING_RX_PHY_DEC_FAILED,
576                 STATUS_CODE_RANGING_RX_PHY_TOA_FAILED,
577                 STATUS_CODE_RANGING_RX_PHY_STS_FAILED,
578                 STATUS_CODE_RANGING_RX_MAC_DEC_FAILED,
579                 STATUS_CODE_RANGING_RX_MAC_IE_DEC_FAILED,
580                 STATUS_CODE_RANGING_RX_MAC_IE_MISSING,
581                 STATUS_CODE_ERROR_ROUND_INDEX_NOT_ACTIVATED,
582                 STATUS_CODE_ERROR_NUMBER_OF_ACTIVE_RANGING_ROUNDS_EXCEEDED,
583                 STATUS_CODE_ERROR_ROUND_INDEX_NOT_SET_AS_INITIATOR,
584                 STATUS_CODE_ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST,
585             })
586     public @interface StatusCode {}
587 
588     public static final int STATUS_CODE_OK = 0x00;
589     public static final int STATUS_CODE_REJECTED = 0x01;
590     public static final int STATUS_CODE_FAILED = 0x02;
591     public static final int STATUS_CODE_SYNTAX_ERROR = 0x03;
592     public static final int STATUS_CODE_INVALID_PARAM = 0x04;
593     public static final int STATUS_CODE_INVALID_RANGE = 0x05;
594     public static final int STATUS_CODE_INVALID_MESSAGE_SIZE = 0x06;
595     public static final int STATUS_CODE_UNKNOWN_GID = 0x07;
596     public static final int STATUS_CODE_UNKNOWN_OID = 0x08;
597     public static final int STATUS_CODE_READ_ONLY = 0x09;
598     public static final int STATUS_CODE_COMMAND_RETRY = 0x0A;
599     public static final int STATUS_CODE_UNKNOWN = 0x0B;
600     public static final int STATUS_CODE_ERROR_SESSION_NOT_EXIST = 0x11;
601     public static final int STATUS_CODE_ERROR_SESSION_DUPLICATE = 0x12;
602     public static final int STATUS_CODE_ERROR_SESSION_ACTIVE = 0x13;
603     public static final int STATUS_CODE_ERROR_MAX_SESSIONS_EXCEEDED = 0x14;
604     public static final int STATUS_CODE_ERROR_SESSION_NOT_CONFIGURED = 0x15;
605     public static final int STATUS_CODE_ERROR_ACTIVE_SESSIONS_ONGOING = 0x16;
606     public static final int STATUS_CODE_ERROR_MULTICAST_LIST_FULL = 0x17;
607     public static final int STATUS_CODE_ERROR_ADDRESS_NOT_FOUND = 0x18;
608     public static final int STATUS_CODE_ERROR_ADDRESS_ALREADY_PRESENT = 0x19;
609     public static final int STATUS_CODE_OK_NEGATIVE_DISTANCE_REPORT = 0x1B;
610     public static final int STATUS_CODE_RANGING_TX_FAILED = 0x20;
611     public static final int STATUS_CODE_RANGING_RX_TIMEOUT = 0x21;
612     public static final int STATUS_CODE_RANGING_RX_PHY_DEC_FAILED = 0x22;
613     public static final int STATUS_CODE_RANGING_RX_PHY_TOA_FAILED = 0x23;
614     public static final int STATUS_CODE_RANGING_RX_PHY_STS_FAILED = 0x24;
615     public static final int STATUS_CODE_RANGING_RX_MAC_DEC_FAILED = 0x25;
616     public static final int STATUS_CODE_RANGING_RX_MAC_IE_DEC_FAILED = 0x26;
617     public static final int STATUS_CODE_RANGING_RX_MAC_IE_MISSING = 0x27;
618     public static final int STATUS_CODE_ERROR_ROUND_INDEX_NOT_ACTIVATED = 0X28;
619     public static final int STATUS_CODE_ERROR_NUMBER_OF_ACTIVE_RANGING_ROUNDS_EXCEEDED = 0X29;
620     public static final int STATUS_CODE_ERROR_ROUND_INDEX_NOT_SET_AS_INITIATOR = 0X2A;
621     public static final int
622             STATUS_CODE_ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST = 0X2B;
623 
624     /**
625      * Table 28: Status codes in the DATA_TRANSFER_STATUS_NTF.
626      */
627     @IntDef(
628             value = {
629                     STATUS_CODE_DATA_TRANSFER_NTF_REPETITION_OK,
630                     STATUS_CODE_DATA_TRANSFER_NTF_OK,
631                     STATUS_CODE_DATA_TRANSFER_NTF_ERROR_DATA_TRANSFER,
632                     STATUS_CODE_DATA_TRANSFER_NTF_ERROR_NO_CREDIT_AVAILABLE,
633                     STATUS_CODE_DATA_TRANSFER_NTF_ERROR_REJECTED,
634                     STATUS_CODE_DATA_TRANSFER_NTF_SESSION_TYPE_NOT_SUPPORTED,
635                     STATUS_CODE_DATA_TRANSFER_NTF_ERROR_DATA_TRANSFER_IS_ONGOING,
636                     STATUS_CODE_DATA_TRANSFER_NTF_STATUS_INVALID_FORMAT
637             })
638     public @interface DataTransferStatusNtfCode {}
639 
640     public static final int STATUS_CODE_DATA_TRANSFER_NTF_REPETITION_OK = 0;
641     public static final int STATUS_CODE_DATA_TRANSFER_NTF_OK = 1;
642     public static final int STATUS_CODE_DATA_TRANSFER_NTF_ERROR_DATA_TRANSFER = 2;
643     public static final int STATUS_CODE_DATA_TRANSFER_NTF_ERROR_NO_CREDIT_AVAILABLE = 3;
644     public static final int STATUS_CODE_DATA_TRANSFER_NTF_ERROR_REJECTED = 4;
645     public static final int STATUS_CODE_DATA_TRANSFER_NTF_SESSION_TYPE_NOT_SUPPORTED = 5;
646     public static final int STATUS_CODE_DATA_TRANSFER_NTF_ERROR_DATA_TRANSFER_IS_ONGOING = 6;
647     public static final int STATUS_CODE_DATA_TRANSFER_NTF_STATUS_INVALID_FORMAT = 7;
648 
649     /**
650      * Table TBD: Status codes in the SESSION_DATA_TRANSFER_PHASE_CONFIGURATION_NTF.
651      */
652     @IntDef(
653             value = {
654                     STATUS_CODE_DATA_TRANSFER_PHASE_CONFIG_DTPCM_CONFIG_SUCCESS,
655                     STATUS_CODE_DATA_TRANSFER_PHASE_CONFIG_ERROR_DUPLICATE_SLOT_ASSIGNMENT
656             })
657     public @interface DataTransferPhaseConfigNtfStatusCode {}
658 
659     public static final int STATUS_CODE_DATA_TRANSFER_PHASE_CONFIG_DTPCM_CONFIG_SUCCESS = 0;
660     public static final int
661             STATUS_CODE_DATA_TRANSFER_PHASE_CONFIG_ERROR_DUPLICATE_SLOT_ASSIGNMENT = 1;
662 
663     /** State change reason codes defined in UCI table-15 */
664     @IntDef(
665             value = {
666                 STATE_CHANGE_REASON_CODE_BY_COMMANDS,
667                 STATE_CHANGE_REASON_CODE_MAX_RR_RETRY_REACHED,
668                 STATE_CHANGE_REASON_CODE_ERROR_SLOT_LENGTH_NOT_SUPPORTED,
669                 STATE_CHANGE_REASON_CODE_ERROR_INSUFFICIENT_SLOTS_PER_RR,
670                 STATE_CHANGE_REASON_CODE_ERROR_MAC_ADDRESS_MODE_NOT_SUPPORTED,
671                 STATE_CHANGE_REASON_CODE_ERROR_INVALID_RANGING_INTERVAL,
672                 STATE_CHANGE_REASON_CODE_ERROR_INVALID_STS_CONFIG,
673                 STATE_CHANGE_REASON_CODE_ERROR_INVALID_RFRAME_CONFIG,
674                 STATE_CHANGE_REASON_CODE_ERROR_HUS_NOT_ENOUGH_SLOTS,
675                 STATE_CHANGE_REASON_CODE_ERROR_HUS_CFP_PHASE_TOO_SHORT,
676                 STATE_CHANGE_REASON_CODE_ERROR_HUS_CAP_PHASE_TOO_SHORT,
677                 STATE_CHANGE_REASON_CODE_ERROR_HUS_OTHERS,
678             })
679     public @interface StateChangeReasonCode {}
680 
681     public static final int STATE_CHANGE_REASON_CODE_BY_COMMANDS = 0;
682     public static final int STATE_CHANGE_REASON_CODE_MAX_RR_RETRY_REACHED = 1;
683     public static final int STATE_CHANGE_REASON_CODE_ERROR_SLOT_LENGTH_NOT_SUPPORTED = 0x20;
684     public static final int STATE_CHANGE_REASON_CODE_ERROR_INSUFFICIENT_SLOTS_PER_RR = 0x21;
685     public static final int STATE_CHANGE_REASON_CODE_ERROR_MAC_ADDRESS_MODE_NOT_SUPPORTED = 0x22;
686     public static final int STATE_CHANGE_REASON_CODE_ERROR_INVALID_RANGING_INTERVAL = 0x23;
687     public static final int STATE_CHANGE_REASON_CODE_ERROR_INVALID_STS_CONFIG = 0x24;
688     public static final int STATE_CHANGE_REASON_CODE_ERROR_INVALID_RFRAME_CONFIG = 0x25;
689     public static final int STATE_CHANGE_REASON_CODE_ERROR_HUS_NOT_ENOUGH_SLOTS = 0x26;
690     public static final int STATE_CHANGE_REASON_CODE_ERROR_HUS_CFP_PHASE_TOO_SHORT = 0x27;
691     public static final int STATE_CHANGE_REASON_CODE_ERROR_HUS_CAP_PHASE_TOO_SHORT = 0x28;
692     public static final int STATE_CHANGE_REASON_CODE_ERROR_HUS_OTHERS = 0x29;
693 
694     /** Multicast controlee add/delete actions defined in UCI */
695     @IntDef(
696             value = {
697                 MULTICAST_LIST_UPDATE_ACTION_ADD,
698                 MULTICAST_LIST_UPDATE_ACTION_DELETE,
699                 P_STS_MULTICAST_LIST_UPDATE_ACTION_ADD_16_BYTE,
700                 P_STS_MULTICAST_LIST_UPDATE_ACTION_ADD_32_BYTE,
701             })
702     public @interface MulticastListUpdateAction {}
703 
704     public static final int MULTICAST_LIST_UPDATE_ACTION_ADD = 0x0;
705     public static final int MULTICAST_LIST_UPDATE_ACTION_DELETE = 0x1;
706     public static final int P_STS_MULTICAST_LIST_UPDATE_ACTION_ADD_16_BYTE = 0x2;
707     public static final int P_STS_MULTICAST_LIST_UPDATE_ACTION_ADD_32_BYTE = 0x3;
708 
709     @IntDef(
710             value = {
711                 MULTICAST_LIST_UPDATE_STATUS_OK,
712                 MULTICAST_LIST_UPDATE_STATUS_ERROR_MULTICAST_LIST_FULL,
713                 MULTICAST_LIST_UPDATE_STATUS_ERROR_KEY_FETCH_FAIL,
714                 MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_ID_NOT_FOUND,
715                 MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_KEY_NOT_FOUND,
716                 MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_KEY_NOT_APPLICABLE,
717                 MULTICAST_LIST_UPDATE_STATUS_ERROR_SESSION_KEY_NOT_FOUND,
718                 MULTICAST_LIST_UPDATE_STATUS_ERROR_ADDRESS_NOT_FOUND,
719                 MULTICAST_LIST_UPDATE_STATUS_ERROR_ADDRESS_ALREADY_PRESENT,
720             })
721     public @interface MulticastListUpdateStatus {}
722 
723     public static final int MULTICAST_LIST_UPDATE_STATUS_OK = 0;
724     public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_MULTICAST_LIST_FULL = 1;
725     public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_KEY_FETCH_FAIL = 2;
726     public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_ID_NOT_FOUND = 3;
727     public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_KEY_NOT_FOUND = 4;
728     public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_SUB_SESSION_KEY_NOT_APPLICABLE = 5;
729     public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_SESSION_KEY_NOT_FOUND = 6;
730     public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_ADDRESS_NOT_FOUND = 7;
731     public static final int MULTICAST_LIST_UPDATE_STATUS_ERROR_ADDRESS_ALREADY_PRESENT = 8;
732 
733     /** Capability related definitions starts from here */
734     @IntDef(
735             value = {
736                 DEVICE_CLASS_1,
737                 DEVICE_CLASS_2,
738                 DEVICE_CLASS_3,
739             })
740     public @interface DeviceClass {}
741 
742     public static final int DEVICE_CLASS_1 = 1; // Controller & controlee
743     public static final int DEVICE_CLASS_2 = 2; // Controller
744     public static final int DEVICE_CLASS_3 = 3; // Controlee
745 
746     /** Length of UL-TDoA Device ID */
747     @IntDef(
748             value = {
749                     UL_TDOA_DEVICE_ID_NONE,
750                     UL_TDOA_DEVICE_ID_16_BIT,
751                     UL_TDOA_DEVICE_ID_32_BIT,
752                     UL_TDOA_DEVICE_ID_64_BIT,
753             })
754     public @interface UlTdoaDeviceIdType {}
755 
756     public static final int UL_TDOA_DEVICE_ID_NONE = 0;
757     public static final int UL_TDOA_DEVICE_ID_16_BIT = 1;
758     public static final int UL_TDOA_DEVICE_ID_32_BIT = 2;
759     public static final int UL_TDOA_DEVICE_ID_64_BIT = 3;
760 
761     /** TX Timestamp of UL-TDoA */
762     @IntDef(
763             value = {
764                     TX_TIMESTAMP_NONE,
765                     TX_TIMESTAMP_40_BIT,
766                     TX_TIMESTAMP_64_BIT,
767             })
768     public @interface UlTdoaTxTimestampType {}
769 
770     public static final int TX_TIMESTAMP_NONE = 0;
771     public static final int TX_TIMESTAMP_40_BIT = 1;
772     public static final int TX_TIMESTAMP_64_BIT = 2;
773 
774     public static final int RANGE_DATA_NTF_PROXIMITY_NEAR_DEFAULT = 0;
775     public static final int RANGE_DATA_NTF_PROXIMITY_FAR_DEFAULT = 20000;
776     public static final double RANGE_DATA_NTF_AOA_AZIMUTH_LOWER_DEFAULT = -Math.PI;
777     public static final double RANGE_DATA_NTF_AOA_AZIMUTH_UPPER_DEFAULT = Math.PI;
778     public static final double RANGE_DATA_NTF_AOA_ELEVATION_LOWER_DEFAULT = -Math.PI / 2;
779     public static final double RANGE_DATA_NTF_AOA_ELEVATION_UPPER_DEFAULT = Math.PI / 2;
780 
781     public enum AoaCapabilityFlag implements FlagEnum {
782         HAS_AZIMUTH_SUPPORT(1),
783         HAS_ELEVATION_SUPPORT(1 << 1),
784         HAS_FOM_SUPPORT(1 << 2),
785         HAS_FULL_AZIMUTH_SUPPORT(1 << 3),
786         HAS_INTERLEAVING_SUPPORT(1 << 4);
787 
788         private final long mValue;
789 
AoaCapabilityFlag(long value)790         private AoaCapabilityFlag(long value) {
791             mValue = value;
792         }
793 
794         @Override
getValue()795         public long getValue() {
796             return mValue;
797         }
798     }
799 
800     public enum DeviceRoleCapabilityFlag implements FlagEnum {
801         HAS_CONTROLEE_INITIATOR_SUPPORT(1),
802         HAS_CONTROLEE_RESPONDER_SUPPORT(1 << 1),
803         HAS_CONTROLLER_INITIATOR_SUPPORT(1 << 2),
804         HAS_CONTROLLER_RESPONDER_SUPPORT(1 << 3),
805         HAS_UT_SYNCHRONIZATION_SUPPORT(1 << 4),
806         HAS_UT_ANCHOR_SUPPORT(1 << 5),
807         HAS_UT_TAG_SUPPORT(1 << 6),
808         HAS_ADVERTISER_SUPPORT(1 << 7),
809         HAS_OBSERVER_SUPPORT(1 << 8),
810         HAS_DT_ANCHOR_SUPPORT(1 << 9),
811         HAS_DT_TAG_SUPPORT(1 << 10);
812 
813         private final long mValue;
814 
DeviceRoleCapabilityFlag(long value)815         private DeviceRoleCapabilityFlag(long value) {
816             mValue = value;
817         }
818 
819         @Override
getValue()820         public long getValue() {
821             return mValue;
822         }
823     }
824 
825     public enum MultiNodeCapabilityFlag implements FlagEnum {
826         HAS_UNICAST_SUPPORT(1),
827         HAS_ONE_TO_MANY_SUPPORT(1 << 1),
828         HAS_MANY_TO_MANY_SUPPORT(1 << 2);
829 
830         private final long mValue;
831 
MultiNodeCapabilityFlag(long value)832         private MultiNodeCapabilityFlag(long value) {
833             mValue = value;
834         }
835 
836         @Override
getValue()837         public long getValue() {
838             return mValue;
839         }
840     }
841 
842     public enum RangingTimeStructCapabilitiesFlag implements FlagEnum {
843         HAS_INTERVAL_BASED_SCHEDULING_SUPPORT(1),
844         HAS_BLOCK_BASED_SCHEDULING_SUPPORT(1 << 1);
845 
846         private final long mValue;
847 
RangingTimeStructCapabilitiesFlag(long value)848         private RangingTimeStructCapabilitiesFlag(long value) {
849             mValue = value;
850         }
851 
852         @Override
getValue()853         public long getValue() {
854             return mValue;
855         }
856     }
857 
858     public enum SchedulingModeCapabilitiesFlag implements FlagEnum {
859         HAS_CONTENTION_BASED_RANGING_SUPPORT(1),
860         HAS_TIME_SCHEDULED_RANGING_SUPPORT(1 << 1);
861 
862         private final long mValue;
863 
SchedulingModeCapabilitiesFlag(long value)864         private SchedulingModeCapabilitiesFlag(long value) {
865             mValue = value;
866         }
867 
868         @Override
getValue()869         public long getValue() {
870             return mValue;
871         }
872     }
873 
874     public enum CcConstraintLengthCapabilitiesFlag implements FlagEnum {
875         HAS_CONSTRAINT_LENGTH_3_SUPPORT(1),
876         HAS_CONSTRAINT_LENGTH_7_SUPPORT(1 << 1);
877 
878         private final long mValue;
879 
CcConstraintLengthCapabilitiesFlag(long value)880         private CcConstraintLengthCapabilitiesFlag(long value) {
881             mValue = value;
882         }
883 
884         @Override
getValue()885         public long getValue() {
886             return mValue;
887         }
888     }
889 
890     public enum PrfCapabilityFlag implements FlagEnum {
891         HAS_BPRF_SUPPORT(1),
892         HAS_HPRF_SUPPORT(1 << 1);
893 
894         private final long mValue;
895 
PrfCapabilityFlag(long value)896         private PrfCapabilityFlag(long value) {
897             mValue = value;
898         }
899 
900         @Override
getValue()901         public long getValue() {
902             return mValue;
903         }
904     }
905 
906     public enum RangingRoundCapabilityFlag implements FlagEnum {
907         HAS_DS_TWR_SUPPORT(1),
908         HAS_SS_TWR_SUPPORT(1 << 1),
909         // TODO(b/265047064) : Check if addition of non-deferred mode is needed.
910         HAS_OWR_UL_TDOA_SUPPORT(1 << 2),
911         HAS_OWR_DL_TDOA_SUPPORT(1 << 3),
912         HAS_OWR_AOA_SUPPORT(1 << 4),
913         HAS_ESS_TWR_SUPPORT(1 << 5),
914         HAS_ADS_TWR_SUPPORT(1 << 6);
915 
916         private final long mValue;
917 
RangingRoundCapabilityFlag(long value)918         private RangingRoundCapabilityFlag(long value) {
919             mValue = value;
920         }
921 
922         @Override
getValue()923         public long getValue() {
924             return mValue;
925         }
926     }
927 
928     public enum RframeCapabilityFlag implements FlagEnum {
929         HAS_SP0_RFRAME_SUPPORT(1),
930         HAS_SP1_RFRAME_SUPPORT(1 << 1),
931         HAS_SP3_RFRAME_SUPPORT(1 << 3);
932 
933         private final long mValue;
934 
RframeCapabilityFlag(long value)935         private RframeCapabilityFlag(long value) {
936             mValue = value;
937         }
938 
939         @Override
getValue()940         public long getValue() {
941             return mValue;
942         }
943     }
944 
945     public enum StsCapabilityFlag implements FlagEnum {
946         HAS_STATIC_STS_SUPPORT(1),
947         HAS_DYNAMIC_STS_SUPPORT(1 << 1),
948         HAS_DYNAMIC_STS_INDIVIDUAL_CONTROLEE_KEY_SUPPORT(1 << 2),
949         HAS_PROVISIONED_STS_SUPPORT(1 << 3),
950         HAS_PROVISIONED_STS_INDIVIDUAL_CONTROLEE_KEY_SUPPORT(1 << 4);
951 
952         private final long mValue;
953 
StsCapabilityFlag(long value)954         private StsCapabilityFlag(long value) {
955             mValue = value;
956         }
957 
958         @Override
getValue()959         public long getValue() {
960             return mValue;
961         }
962     }
963 
964     public enum PsduDataRateCapabilityFlag implements FlagEnum {
965         HAS_6M81_SUPPORT(1),
966         HAS_7M80_SUPPORT(1 << 1),
967         HAS_27M2_SUPPORT(1 << 2),
968         HAS_31M2_SUPPORT(1 << 3);
969 
970         private final long mValue;
971 
PsduDataRateCapabilityFlag(long value)972         private PsduDataRateCapabilityFlag(long value) {
973             mValue = value;
974         }
975 
976         @Override
getValue()977         public long getValue() {
978             return mValue;
979         }
980     }
981 
982     public enum BprfParameterSetCapabilityFlag implements FlagEnum {
983         HAS_SET_1_SUPPORT(1),
984         HAS_SET_2_SUPPORT(1 << 1),
985         HAS_SET_3_SUPPORT(1 << 2),
986         HAS_SET_4_SUPPORT(1 << 3),
987         HAS_SET_5_SUPPORT(1 << 4),
988         HAS_SET_6_SUPPORT(1 << 5);
989 
990         private final long mValue;
991 
BprfParameterSetCapabilityFlag(long value)992         private BprfParameterSetCapabilityFlag(long value) {
993             mValue = value;
994         }
995 
996         @Override
getValue()997         public long getValue() {
998             return mValue;
999         }
1000     }
1001 
1002     public enum HprfParameterSetCapabilityFlag implements FlagEnum {
1003         HAS_SET_1_SUPPORT(1L),
1004         HAS_SET_2_SUPPORT(1L << 1),
1005         HAS_SET_3_SUPPORT(1L << 2),
1006         HAS_SET_4_SUPPORT(1L << 3),
1007         HAS_SET_5_SUPPORT(1L << 4),
1008         HAS_SET_6_SUPPORT(1L << 5),
1009         HAS_SET_7_SUPPORT(1L << 6),
1010         HAS_SET_8_SUPPORT(1L << 7),
1011         HAS_SET_9_SUPPORT(1L << 8),
1012         HAS_SET_10_SUPPORT(1L << 9),
1013         HAS_SET_11_SUPPORT(1L << 10),
1014         HAS_SET_12_SUPPORT(1L << 11),
1015         HAS_SET_13_SUPPORT(1L << 12),
1016         HAS_SET_14_SUPPORT(1L << 13),
1017         HAS_SET_15_SUPPORT(1L << 14),
1018         HAS_SET_16_SUPPORT(1L << 15),
1019         HAS_SET_17_SUPPORT(1L << 16),
1020         HAS_SET_18_SUPPORT(1L << 17),
1021         HAS_SET_19_SUPPORT(1L << 18),
1022         HAS_SET_20_SUPPORT(1L << 19),
1023         HAS_SET_21_SUPPORT(1L << 20),
1024         HAS_SET_22_SUPPORT(1L << 21),
1025         HAS_SET_23_SUPPORT(1L << 22),
1026         HAS_SET_24_SUPPORT(1L << 23),
1027         HAS_SET_25_SUPPORT(1L << 24),
1028         HAS_SET_26_SUPPORT(1L << 25),
1029         HAS_SET_27_SUPPORT(1L << 26),
1030         HAS_SET_28_SUPPORT(1L << 27),
1031         HAS_SET_29_SUPPORT(1L << 28),
1032         HAS_SET_30_SUPPORT(1L << 29),
1033         HAS_SET_31_SUPPORT(1L << 30),
1034         HAS_SET_32_SUPPORT(1L << 31),
1035         HAS_SET_33_SUPPORT(1L << 32),
1036         HAS_SET_34_SUPPORT(1L << 33),
1037         HAS_SET_35_SUPPORT(1L << 34);
1038 
1039         private final long mValue;
1040 
HprfParameterSetCapabilityFlag(long value)1041         private HprfParameterSetCapabilityFlag(long value) {
1042             mValue = value;
1043         }
1044 
1045         @Override
getValue()1046         public long getValue() {
1047             return mValue;
1048         }
1049     }
1050 
1051     public enum RangeDataNtfConfigCapabilityFlag implements FlagEnum {
1052         HAS_RANGE_DATA_NTF_CONFIG_DISABLE(1 << RANGE_DATA_NTF_CONFIG_DISABLE),
1053         HAS_RANGE_DATA_NTF_CONFIG_ENABLE(1 << RANGE_DATA_NTF_CONFIG_ENABLE),
1054         HAS_RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_LEVEL_TRIG(
1055                 1 << RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_LEVEL_TRIG),
1056         HAS_RANGE_DATA_NTF_CONFIG_ENABLE_AOA_LEVEL_TRIG(
1057                 1 << RANGE_DATA_NTF_CONFIG_ENABLE_AOA_LEVEL_TRIG),
1058         HAS_RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_LEVEL_TRIG(
1059                 1 << RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_LEVEL_TRIG),
1060         HAS_RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_EDGE_TRIG(
1061                 1 << RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_EDGE_TRIG),
1062         HAS_RANGE_DATA_NTF_CONFIG_ENABLE_AOA_EDGE_TRIG(
1063                 1 << RANGE_DATA_NTF_CONFIG_ENABLE_AOA_EDGE_TRIG),
1064         HAS_RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_EDGE_TRIG(
1065                 1 << RANGE_DATA_NTF_CONFIG_ENABLE_PROXIMITY_AOA_EDGE_TRIG);
1066 
1067 
1068 
1069         private final long mValue;
1070 
RangeDataNtfConfigCapabilityFlag(long value)1071         private RangeDataNtfConfigCapabilityFlag(long value) {
1072             mValue = value;
1073         }
1074 
1075         @Override
getValue()1076         public long getValue() {
1077             return mValue;
1078         }
1079     }
1080 
1081     /**
1082      * Suspend Ranging Support (FiRa 2.0)
1083      */
1084     @IntDef(
1085             value = {
1086                     SUSPEND_RANGING_DISABLED,
1087                     SUSPEND_RANGING_ENABLED,
1088             })
1089     public @interface SuspendRanging {}
1090 
1091     public static final int SUSPEND_RANGING_DISABLED = 0;
1092     public static final int SUSPEND_RANGING_ENABLED = 1;
1093 
1094     /**
1095      * Session Key length supported (FiRa 2.0)
1096      */
1097     @IntDef(
1098             value = {
1099                     KEY_LENGTH_256_BITS_NOT_SUPPORTED,
1100                     KEY_LENGTH_256_BITS_SUPPORTED,
1101             })
1102     public @interface SessionKeyLength {}
1103 
1104     public static final int KEY_LENGTH_256_BITS_NOT_SUPPORTED = 0;
1105     public static final int KEY_LENGTH_256_BITS_SUPPORTED = 1;
1106 
1107     /**
1108      * Session Type (for SESSION_INIT_CMD)
1109      */
1110     @IntDef(
1111             value = {
1112                     SESSION_TYPE_RANGING,
1113                     SESSION_TYPE_RANGING_AND_IN_BAND_DATA,
1114                     SESSION_TYPE_DATA_TRANSFER,
1115                     SESSION_TYPE_RANGING_ONLY_PHASE,
1116                     SESSION_TYPE_IN_BAND_DATA_PHASE,
1117                     SESSION_TYPE_RANGING_WITH_DATA_PHASE,
1118                     SESSION_TYPE_DEVICE_TEST_MODE,
1119             })
1120     public @interface SessionType{}
1121 
1122     public static final int SESSION_TYPE_RANGING = 0;
1123     public static final int SESSION_TYPE_RANGING_AND_IN_BAND_DATA = 1;
1124     public static final int SESSION_TYPE_DATA_TRANSFER = 2;
1125     public static final int SESSION_TYPE_RANGING_ONLY_PHASE = 3;
1126     public static final int SESSION_TYPE_IN_BAND_DATA_PHASE = 4;
1127     public static final int SESSION_TYPE_RANGING_WITH_DATA_PHASE = 5;
1128     public static final int SESSION_TYPE_DEVICE_TEST_MODE = 0xD0;
1129 
1130     /** Which type of filter to use for filtering AoA/distance readings. */
1131     @IntDef(
1132             value = {
1133                     FILTER_TYPE_NONE,
1134                     FILTER_TYPE_DEFAULT,
1135                     FILTER_TYPE_APPLICATION,
1136             })
1137     public @interface FilterType {}
1138     public static final int FILTER_TYPE_NONE = 0;
1139     public static final int FILTER_TYPE_DEFAULT = 1;
1140     public static final int FILTER_TYPE_APPLICATION = 2;
1141 
1142     // Default value (Unlimited)
1143     public static final int MAX_NUMBER_OF_MEASUREMENTS_DEFAULT = 0;
1144 
1145     public static final int SESSION_TIME_BASE_PARAM_LEN = 9;
1146     public static final int SESSION_HANDLE_LEN = 4;
1147     public static final int SESSION_OFFSET_TIME_LEN = 4;
1148 
1149     // Default value (Host as the both secure & non-secure endpoint).
1150     public static final int APPLICATION_DATA_ENDPOINT_DEFAULT = 0;
1151 
1152     //Reference time base feature mask.
1153     public static final int SESSION_TIME_BASE_REFERENCE_FEATURE_ENABLED = 1;
1154     /**
1155      * Antenna Mode (Android-specific app config)
1156      */
1157     @IntDef(
1158             value = {
1159                     ANTENNA_MODE_OMNI,
1160                     ANTENNA_MODE_DIRECTIONAL,
1161             })
1162     public @interface AntennaMode {}
1163 
1164     /** (Default) The ranging antenna is used for both Tx and Rx. **/
1165     public static final int ANTENNA_MODE_OMNI = 0;
1166     /** The patch antenna is used for both Tx and Rx. **/
1167     public static final int ANTENNA_MODE_DIRECTIONAL = 1;
1168 
1169     // Helper functions
longToUwbAddress(long value, int length)1170     protected static UwbAddress longToUwbAddress(long value, int length) {
1171         ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
1172         buffer.putLong(value);
1173         return UwbAddress.fromBytes(Arrays.copyOf(buffer.array(), length));
1174     }
1175 
1176     /** Helper functions to convert UwbAdrress in long value. */
uwbAddressToLong(UwbAddress address)1177     public static long uwbAddressToLong(UwbAddress address) {
1178         ByteBuffer buffer = ByteBuffer.wrap(Arrays.copyOf(address.toBytes(), Long.BYTES));
1179         return buffer.getLong();
1180     }
1181 }
1182