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   * Data related to a Wi-Fi access point with estimated transmitted power.
20   */
21  public class WifiAccessPointWithPower extends WifiAccessPoint implements RadioSourceWithPower {
22  
23      /**
24       * Default exponent typically used on free space for path loss propagation in
25       * terms of distance. This value is used for free space environments.
26       */
27      public static final double DEFAULT_PATH_LOSS_EXPONENT = 2.0;
28  
29      /**
30       * Transmitted power expressed in dBm's.
31       */
32      private double transmittedPower;
33  
34      /**
35       * Standard deviation of transmitted power value or null if unknown.
36       */
37      private Double transmittedPowerStandardDeviation;
38  
39      /**
40       * Exponent typically used on free space for path loss propagation in
41       * terms of distance.
42       * On different environments path loss exponent might have different values:
43       * - Free space: 2.0
44       * - Urban Area: 2.7 to 3.5
45       * - Suburban Area: 3 to 5
46       * - Indoor (line-of-sight): 1.6 to 1.8
47       * If path loss exponent estimation is not enabled, this value will always be equal to
48       * {@link #DEFAULT_PATH_LOSS_EXPONENT}
49       */
50      private double pathLossExponent = DEFAULT_PATH_LOSS_EXPONENT;
51  
52      /**
53       * Standard deviation of path loss exponent or null if unknown.
54       */
55      private Double pathLossExponentStandardDeviation;
56  
57      /**
58       * Constructor.
59       *
60       * @param bssid            basic service set identifier of this access point in the form of a six-byte MAC address:
61       *                         xx:xx:xx:xx:xx:xx.
62       * @param frequency        frequency used by this Access Point (expressed in Hz).
63       * @param transmittedPower transmitted power by this access point (expressed in dBm's).
64       * @throws IllegalArgumentException if BSSID is null or frequency is negative.
65       */
66      public WifiAccessPointWithPower(final String bssid, final double frequency, final double transmittedPower) {
67          super(bssid, frequency);
68          this.transmittedPower = transmittedPower;
69      }
70  
71      /**
72       * Constructor.
73       *
74       * @param bssid            basic service set identifier of this access point in the form of a six-byte MAC address:
75       *                         xx:xx:xx:xx:xx:xx.
76       * @param frequency        frequency used by this Access Point (expressed in Hz).
77       * @param ssid             service set identifier (SSID) of this 802.11 network.
78       * @param transmittedPower transmitted power by this access point (expressed in dBM's).
79       * @throws IllegalArgumentException if BSSID is null or frequency is negative.
80       */
81      public WifiAccessPointWithPower(
82              final String bssid, final double frequency, final String ssid, final double transmittedPower) {
83          super(bssid, frequency, ssid);
84          this.transmittedPower = transmittedPower;
85      }
86  
87      /**
88       * Constructor.
89       *
90       * @param bssid                             basic service set identifier of this access point in the form of a six-byte MAC address:
91       *                                          xx:xx:xx:xx:xx:xx.
92       * @param frequency                         frequency used by this Access Point (expressed in Hz).
93       * @param transmittedPower                  transmitted power by this access point (expressed in dBm's).
94       * @param transmittedPowerStandardDeviation standard deviation of transmitted power value or null if
95       *                                          unknown.
96       * @throws IllegalArgumentException if either BSSID is null, frequency is negative
97       *                                  or transmitted power standard deviation is negative.
98       */
99      public WifiAccessPointWithPower(
100             final String bssid, final double frequency, final double transmittedPower,
101             final Double transmittedPowerStandardDeviation) {
102         this(bssid, frequency, transmittedPower);
103 
104         if (transmittedPowerStandardDeviation != null && transmittedPowerStandardDeviation < 0.0) {
105             throw new IllegalArgumentException();
106         }
107         this.transmittedPowerStandardDeviation = transmittedPowerStandardDeviation;
108     }
109 
110     /**
111      * Constructor.
112      *
113      * @param bssid                             basic service set identifier of this access point in the form of a six-byte MAC address:
114      *                                          xx:xx:xx:xx:xx:xx.
115      * @param frequency                         frequency used by this Access Point (expressed in Hz).
116      * @param ssid                              service set identifier (SSID) of this 802.11 network.
117      * @param transmittedPower                  transmitted power by this access point (expressed in dBM's).
118      * @param transmittedPowerStandardDeviation standard deviation of transmitted power value or null if unknown.
119      * @throws IllegalArgumentException if either BSSID is null, frequency is negative,
120      *                                  or transmitted power standard deviation is negative.
121      */
122     public WifiAccessPointWithPower(
123             final String bssid, final double frequency, final String ssid, final double transmittedPower,
124             final Double transmittedPowerStandardDeviation) {
125         this(bssid, frequency, ssid, transmittedPower);
126 
127         if (transmittedPowerStandardDeviation != null && transmittedPowerStandardDeviation < 0.0) {
128             throw new IllegalArgumentException();
129         }
130         this.transmittedPowerStandardDeviation = transmittedPowerStandardDeviation;
131     }
132 
133     /**
134      * Constructor.
135      *
136      * @param bssid            basic service set identifier of this access point in the form of a six-byte MAC address:
137      *                         xx:xx:xx:xx:xx:xx.
138      * @param frequency        frequency used by this Access Point (expressed in Hz).
139      * @param transmittedPower transmitted power by this access point (expressed in dBm's).
140      * @param pathLossExponent path loss exponent. By default, this is 2.0.
141      * @throws IllegalArgumentException if BSSID is null or frequency is negative.
142      */
143     public WifiAccessPointWithPower(
144             final String bssid, final double frequency, final double transmittedPower, final double pathLossExponent) {
145         this(bssid, frequency, transmittedPower);
146         this.pathLossExponent = pathLossExponent;
147     }
148 
149     /**
150      * Constructor.
151      *
152      * @param bssid                             basic service set identifier of this access point in the form of a six-byte MAC address:
153      *                                          xx:xx:xx:xx:xx:xx.
154      * @param frequency                         frequency used by this Access Point (expressed in Hz).
155      * @param transmittedPower                  transmitted power by this access point (expressed in dBm's).
156      * @param transmittedPowerStandardDeviation standard deviation of transmitted power value or null if
157      *                                          unknown.
158      * @param pathLossExponent                  path loss exponent. By default, this is 2.0.
159      * @throws IllegalArgumentException if either BSSID is null, frequency is negative
160      *                                  or transmitted power standard deviation is negative.
161      */
162     public WifiAccessPointWithPower(
163             final String bssid, final double frequency, final double transmittedPower,
164             final Double transmittedPowerStandardDeviation, final double pathLossExponent) {
165         this(bssid, frequency, transmittedPower, transmittedPowerStandardDeviation);
166         this.pathLossExponent = pathLossExponent;
167     }
168 
169     /**
170      * Constructor.
171      *
172      * @param bssid                             basic service set identifier of this access point in the form of a six-byte MAC address:
173      *                                          xx:xx:xx:xx:xx:xx.
174      * @param frequency                         frequency used by this Access Point (expressed in Hz).
175      * @param ssid                              service set identifier (SSID) of this 802.11 network.
176      * @param transmittedPower                  transmitted power by this access point (expressed in dBM's).
177      * @param transmittedPowerStandardDeviation standard deviation of transmitted power value or null if
178      *                                          unknown.
179      * @param pathLossExponent                  path loss exponent. By default, this is 2.0.
180      * @throws IllegalArgumentException if either BSSID is null, frequency is negative,
181      *                                  or transmitted power standard deviation is negative.
182      */
183     public WifiAccessPointWithPower(
184             final String bssid, final double frequency, final String ssid, final double transmittedPower,
185             final Double transmittedPowerStandardDeviation, final double pathLossExponent) {
186         this(bssid, frequency, ssid, transmittedPower, transmittedPowerStandardDeviation);
187         this.pathLossExponent = pathLossExponent;
188     }
189 
190     /**
191      * Constructor.
192      *
193      * @param bssid                             basic service set identifier of this access point in the form of a six-byte MAC address:
194      *                                          xx:xx:xx:xx:xx:xx.
195      * @param frequency                         frequency used by this Access Point (expressed in Hz).
196      * @param transmittedPower                  transmitted power by this access point (expressed in dBm's).
197      * @param transmittedPowerStandardDeviation standard deviation of transmitted power value or null if
198      *                                          unknown.
199      * @param pathLossExponent                  path loss exponent. By default, this is 2.0.
200      * @param pathLossExponentStandardDeviation standard deviation of path loss exponent or null if
201      *                                          unknown.
202      * @throws IllegalArgumentException if either BSSID is null, frequency is negative
203      *                                  or any standard deviation is negative.
204      */
205     public WifiAccessPointWithPower(
206             final String bssid, final double frequency, final double transmittedPower,
207             final Double transmittedPowerStandardDeviation, final double pathLossExponent,
208             final Double pathLossExponentStandardDeviation) {
209         this(bssid, frequency, transmittedPower, transmittedPowerStandardDeviation, pathLossExponent);
210 
211         if (pathLossExponentStandardDeviation != null && pathLossExponentStandardDeviation < 0.0) {
212             throw new IllegalArgumentException();
213         }
214         this.pathLossExponentStandardDeviation = pathLossExponentStandardDeviation;
215     }
216 
217     /**
218      * Constructor.
219      *
220      * @param bssid                             basic service set identifier of this access point in the form of a six-byte MAC address:
221      *                                          xx:xx:xx:xx:xx:xx.
222      * @param frequency                         frequency used by this Access Point (expressed in Hz).
223      * @param ssid                              service set identifier (SSID) of this 802.11 network.
224      * @param transmittedPower                  transmitted power by this access point (expressed in dBM's).
225      * @param transmittedPowerStandardDeviation standard deviation of transmitted power value or null if
226      *                                          unknown.
227      * @param pathLossExponent                  path loss exponent. By default, this is 2.0.
228      * @param pathLossExponentStandardDeviation standard deviation of path loss exponent or null if
229      *                                          unknown.
230      * @throws IllegalArgumentException if either BSSID is null, frequency is negative,
231      *                                  or transmitted power standard deviation is negative.
232      */
233     public WifiAccessPointWithPower(
234             final String bssid, final double frequency, final String ssid, final double transmittedPower,
235             final Double transmittedPowerStandardDeviation, final double pathLossExponent,
236             final Double pathLossExponentStandardDeviation) {
237         this(bssid, frequency, ssid, transmittedPower, transmittedPowerStandardDeviation, pathLossExponent);
238 
239         if (pathLossExponentStandardDeviation != null && pathLossExponentStandardDeviation < 0.0) {
240             throw new IllegalArgumentException();
241         }
242         this.pathLossExponentStandardDeviation = pathLossExponentStandardDeviation;
243     }
244 
245     /**
246      * Empty constructor.
247      */
248     protected WifiAccessPointWithPower() {
249         super();
250     }
251 
252     /**
253      * Gets transmitted power expressed in dBm's.
254      *
255      * @return transmitted power expressed in dBm's.
256      */
257     @Override
258     public double getTransmittedPower() {
259         return transmittedPower;
260     }
261 
262     /**
263      * Gets standard deviation of transmitted power value or null if unknown.
264      *
265      * @return standard deviation of transmitted power value or null if unknown.
266      */
267     @Override
268     public Double getTransmittedPowerStandardDeviation() {
269         return transmittedPowerStandardDeviation;
270     }
271 
272     /**
273      * Gets exponent typically used on free space for path loss propagation in
274      * terms of distance.
275      * On different environments path loss exponent might have different values:
276      * - Free space: 2.0
277      * - Urban Area: 2.7 to 3.5
278      * - Suburban Area: 3 to 5
279      * - Indoor (line-of-sight): 1.6 to 1.8
280      * If path loss exponent estimation is not enabled, this value will always be equal to
281      * {@link #DEFAULT_PATH_LOSS_EXPONENT}
282      *
283      * @return path loss exponent.
284      */
285     @Override
286     public double getPathLossExponent() {
287         return pathLossExponent;
288     }
289 
290     /**
291      * Gets standard deviation of path loss exponent or null if unknown.
292      *
293      * @return standard deviation of path loss exponent or null if unknown.
294      */
295     @Override
296     public Double getPathLossExponentStandardDeviation() {
297         return pathLossExponentStandardDeviation;
298     }
299 }