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 package com.android.server.uwb.data; 17 18 import java.util.Arrays; 19 20 public class UwbRangingData { 21 public long mSeqCounter; 22 public long mSessionId; 23 public int mRcrIndication; 24 public long mCurrRangingInterval; 25 public int mRangingMeasuresType; 26 public int mMacAddressMode; 27 public int mNoOfRangingMeasures; 28 public UwbTwoWayMeasurement[] mRangingTwoWayMeasures; 29 public byte[] mRawNtfData; 30 public UwbOwrAoaMeasurement mRangingOwrAoaMeasure; 31 public UwbDlTDoAMeasurement[] mUwbDlTDoAMeasurements; 32 UwbRangingData(long seqCounter, long sessionId, int rcrIndication, long currRangingInterval, int rangingMeasuresType, int macAddressMode, int noOfRangingMeasures, UwbTwoWayMeasurement[] rangingTwoWayMeasures, byte[] rawNtfData)33 public UwbRangingData(long seqCounter, long sessionId, int rcrIndication, 34 long currRangingInterval, int rangingMeasuresType, int macAddressMode, 35 int noOfRangingMeasures, UwbTwoWayMeasurement[] rangingTwoWayMeasures, 36 byte[] rawNtfData) { 37 this.mSeqCounter = seqCounter; 38 this.mSessionId = sessionId; 39 this.mRcrIndication = rcrIndication; 40 this.mCurrRangingInterval = currRangingInterval; 41 this.mRangingMeasuresType = rangingMeasuresType; 42 this.mMacAddressMode = macAddressMode; 43 this.mNoOfRangingMeasures = noOfRangingMeasures; 44 this.mRangingTwoWayMeasures = rangingTwoWayMeasures; 45 this.mRawNtfData = rawNtfData; 46 } 47 UwbRangingData(long seqCounter, long sessionId, int rcrIndication, long currRangingInterval, int rangingMeasuresType, int macAddressMode, int noOfRangingMeasures, UwbOwrAoaMeasurement rangingOwrAoaMeasure, byte[] rawNtfData)48 public UwbRangingData(long seqCounter, long sessionId, int rcrIndication, 49 long currRangingInterval, int rangingMeasuresType, int macAddressMode, 50 int noOfRangingMeasures, UwbOwrAoaMeasurement rangingOwrAoaMeasure, 51 byte[] rawNtfData) { 52 this.mSeqCounter = seqCounter; 53 this.mSessionId = sessionId; 54 this.mRcrIndication = rcrIndication; 55 this.mCurrRangingInterval = currRangingInterval; 56 this.mRangingMeasuresType = rangingMeasuresType; 57 this.mMacAddressMode = macAddressMode; 58 this.mNoOfRangingMeasures = noOfRangingMeasures; 59 this.mRangingOwrAoaMeasure = rangingOwrAoaMeasure; 60 this.mRawNtfData = rawNtfData; 61 } 62 UwbRangingData(long seqCounter, long sessionId, int rcrIndication, long currRangingInterval, int rangingMeasuresType, int macAddressMode, int noOfRangingMeasures, UwbDlTDoAMeasurement[] uwbDlTDoAMeasurements, byte[] rawNtfData)63 public UwbRangingData(long seqCounter, long sessionId, int rcrIndication, 64 long currRangingInterval, int rangingMeasuresType, int macAddressMode, 65 int noOfRangingMeasures, UwbDlTDoAMeasurement[] uwbDlTDoAMeasurements, 66 byte[] rawNtfData) { 67 this.mSeqCounter = seqCounter; 68 this.mSessionId = sessionId; 69 this.mRcrIndication = rcrIndication; 70 this.mCurrRangingInterval = currRangingInterval; 71 this.mRangingMeasuresType = rangingMeasuresType; 72 this.mMacAddressMode = macAddressMode; 73 this.mNoOfRangingMeasures = noOfRangingMeasures; 74 this.mUwbDlTDoAMeasurements = uwbDlTDoAMeasurements; 75 this.mRawNtfData = rawNtfData; 76 } 77 getSequenceCounter()78 public long getSequenceCounter() { 79 return mSeqCounter; 80 } 81 getSessionId()82 public long getSessionId() { 83 return mSessionId; 84 } 85 getRcrIndication()86 public int getRcrIndication() { 87 return mRcrIndication; 88 } 89 getCurrRangingInterval()90 public long getCurrRangingInterval() { 91 return mCurrRangingInterval; 92 } 93 getRangingMeasuresType()94 public int getRangingMeasuresType() { 95 return mRangingMeasuresType; 96 } 97 getMacAddressMode()98 public int getMacAddressMode() { 99 return mMacAddressMode; 100 } 101 getNoOfRangingMeasures()102 public int getNoOfRangingMeasures() { 103 return mNoOfRangingMeasures; 104 } 105 getRangingTwoWayMeasures()106 public UwbTwoWayMeasurement[] getRangingTwoWayMeasures() { 107 return mRangingTwoWayMeasures; 108 } 109 getRawNtfData()110 public byte[] getRawNtfData() { 111 return mRawNtfData; 112 } 113 getRangingOwrAoaMeasure()114 public UwbOwrAoaMeasurement getRangingOwrAoaMeasure() { 115 return mRangingOwrAoaMeasure; 116 } 117 getUwbDlTDoAMeasurements()118 public UwbDlTDoAMeasurement[] getUwbDlTDoAMeasurements() { 119 return mUwbDlTDoAMeasurements; 120 } 121 toString()122 public String toString() { 123 if (mRangingMeasuresType == UwbUciConstants.RANGING_MEASUREMENT_TYPE_TWO_WAY) { 124 return "UwbRangingData { " 125 + " SeqCounter = " + mSeqCounter 126 + ", SessionId = " + mSessionId 127 + ", RcrIndication = " + mRcrIndication 128 + ", CurrRangingInterval = " + mCurrRangingInterval 129 + ", RangingMeasuresType = " + mRangingMeasuresType 130 + ", MacAddressMode = " + mMacAddressMode 131 + ", NoOfRangingMeasures = " + mNoOfRangingMeasures 132 + ", RangingTwoWayMeasures = " + Arrays.toString(mRangingTwoWayMeasures) 133 + ", RawNotificationData = " + Arrays.toString(mRawNtfData) 134 + '}'; 135 } else if (mRangingMeasuresType == UwbUciConstants.RANGING_MEASUREMENT_TYPE_OWR_AOA) { 136 return "UwbRangingData { " 137 + " SeqCounter = " + mSeqCounter 138 + ", SessionId = " + mSessionId 139 + ", RcrIndication = " + mRcrIndication 140 + ", CurrRangingInterval = " + mCurrRangingInterval 141 + ", RangingMeasuresType = " + mRangingMeasuresType 142 + ", MacAddressMode = " + mMacAddressMode 143 + ", NoOfRangingMeasures = " + mNoOfRangingMeasures 144 + ", RangingOwrAoaMeasure = " + mRangingOwrAoaMeasure.toString() 145 + ", RawNotificationData = " + Arrays.toString(mRawNtfData) 146 + '}'; 147 } else if (mRangingMeasuresType == UwbUciConstants.RANGING_MEASUREMENT_TYPE_DL_TDOA) { 148 return "UwbRangingData { " 149 + " SeqCounter = " + mSeqCounter 150 + ", SessionId = " + mSessionId 151 + ", RcrIndication = " + mRcrIndication 152 + ", CurrRangingInterval = " + mCurrRangingInterval 153 + ", RangingMeasuresType = " + mRangingMeasuresType 154 + ", MacAddressMode = " + mMacAddressMode 155 + ", NoOfRangingMeasures = " + mNoOfRangingMeasures 156 + ", RangingDlTDoAMeasure = " + Arrays.toString(mUwbDlTDoAMeasurements) 157 + ", RawNotificationData = " + Arrays.toString(mRawNtfData) 158 + '}'; 159 } else { 160 // TODO(jh0.jang) : ONE WAY RANGING(TDOA)? 161 return null; 162 } 163 } 164 } 165