View Javadoc
1   /*
2    * Copyright (C) 2018 Alberto Irurueta Carro (alberto@irurueta.com)
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.irurueta.navigation.indoor;
17  
18  /**
19   * Contains a signal strength reading associated to a given radio source
20   * (e.g. Wi-Fi access point or bluetooth beacon).
21   *
22   * @param <S> a {@link RadioSource} type.
23   */
24  public class RssiReading<S extends RadioSource> extends Reading<S> {
25  
26      /**
27       * Received signal strength indicator of a 802.11 network or bluetooth beacon, in dBm.
28       */
29      private double rssi;
30  
31      /**
32       * Standard deviation of RSSI, if available.
33       */
34      private Double rssiStandardDeviation;
35  
36      /**
37       * Constructor.
38       *
39       * @param source radio source associated to this reading.
40       * @param rssi   received signal strength indicator in dBm.
41       * @throws IllegalArgumentException if radio source data is null.
42       */
43      public RssiReading(final S source, final double rssi) {
44          super(source);
45          this.rssi = rssi;
46      }
47  
48      /**
49       * Constructor.
50       *
51       * @param source                radio source associated to this reading.
52       * @param rssi                  received signal strength indicator in dBm.
53       * @param rssiStandardDeviation standard deviation of RSSI, if available.
54       * @throws IllegalArgumentException if radio source data is null or
55       *                                  standard deviation is zero or negative.
56       */
57      public RssiReading(final S source, final double rssi, final Double rssiStandardDeviation) {
58          this(source, rssi);
59  
60          if (rssiStandardDeviation != null && rssiStandardDeviation <= 0.0) {
61              throw new IllegalArgumentException();
62          }
63  
64          this.rssiStandardDeviation = rssiStandardDeviation;
65      }
66  
67      /**
68       * Empty constructor.
69       */
70      protected RssiReading() {
71          super();
72      }
73  
74      /**
75       * Contains radio source reading type.
76       *
77       * @return reading type.
78       */
79      @Override
80      public ReadingType getType() {
81          return ReadingType.RSSI_READING;
82      }
83  
84      /**
85       * Gets received signal strength indicator of this 802.11 network, in dBm.
86       *
87       * @return received signal strength indicator.
88       */
89      public double getRssi() {
90          return rssi;
91      }
92  
93      /**
94       * Gets standard deviation of RSSI, if available.
95       *
96       * @return standard deviation of RSSI, if available.
97       */
98      public Double getRssiStandardDeviation() {
99          return rssiStandardDeviation;
100     }
101 }