1 /*
2  * Copyright (C) 2022 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 androidx.core.uwb.backend.impl.internal;
18 
19 /** Timing-related parameters. */
20 public class RangingTimingParams {
21 
22     private final int mRangingIntervalNormal;
23     private final int mRangingIntervalFast;
24     private final int mRangingIntervalInfrequent;
25     private final int mSlotPerRangingRound;
26     private final int mSlotDurationRstu;
27     private final int mInitiationTimeMs;
28     private final boolean mHoppingEnabled;
29 
RangingTimingParams( int rangingIntervalNormal, int rangingIntervalFast, int rangingIntervalInfrequent, int slotPerRangingRound, int slotDurationRstu, int initiationTimeMs, boolean hoppingEnabled)30     RangingTimingParams(
31             int rangingIntervalNormal,
32             int rangingIntervalFast,
33             int rangingIntervalInfrequent,
34             int slotPerRangingRound,
35             int slotDurationRstu,
36             int initiationTimeMs,
37             boolean hoppingEnabled) {
38         mRangingIntervalNormal = rangingIntervalNormal;
39         mRangingIntervalFast = rangingIntervalFast;
40         mRangingIntervalInfrequent = rangingIntervalInfrequent;
41         mSlotPerRangingRound = slotPerRangingRound;
42         mSlotDurationRstu = slotDurationRstu;
43         mInitiationTimeMs = initiationTimeMs;
44         mHoppingEnabled = hoppingEnabled;
45     }
46 
getRangingIntervalNormal()47     public int getRangingIntervalNormal() {
48         return mRangingIntervalNormal;
49     }
50 
getRangingIntervalFast()51     public int getRangingIntervalFast() {
52         return mRangingIntervalFast;
53     }
54 
getRangingIntervalInfrequent()55     public int getRangingIntervalInfrequent() {
56         return mRangingIntervalInfrequent;
57     }
58 
getSlotPerRangingRound()59     public int getSlotPerRangingRound() {
60         return mSlotPerRangingRound;
61     }
62 
getSlotDurationRstu()63     public int getSlotDurationRstu() {
64         return mSlotDurationRstu;
65     }
66 
getInitiationTimeMs()67     public int getInitiationTimeMs() {
68         return mInitiationTimeMs;
69     }
70 
isHoppingEnabled()71     public boolean isHoppingEnabled() {
72         return mHoppingEnabled;
73     }
74 
75     /** Converts updateRate to numerical ranging interval value. */
getRangingInterval(@tils.RangingUpdateRate int updateRate)76     public int getRangingInterval(@Utils.RangingUpdateRate int updateRate) {
77         switch (updateRate) {
78             case Utils.NORMAL:
79                 return mRangingIntervalNormal;
80             case Utils.INFREQUENT:
81                 return mRangingIntervalInfrequent;
82             case Utils.FAST:
83                 return mRangingIntervalFast;
84             default:
85                 throw new IllegalArgumentException("Argument updateRate is invalid.");
86         }
87     }
88 }
89