``` 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
```
```#![feature(use_extern_macros)]

//! rust-rfcalcs Radio Frequency (RF) Calculations in Rustlang
//!
//! Copyright 2017 Ryan Kurte
//!

pub mod types;
pub mod consts;

pub mod fresnel;

use types::*;
use consts::*;

/// Calculates the Free Space Path Loss (FSPL) in Decibels for a given frequency and distance
/// https://en.wikipedia.org/wiki/Free-space_path_loss#Free-space_path_loss_formula
pub fn free_space_path_loss(freq: Frequency, dist: Distance) -> Attenuation {
let fading = 20.0 * (4.0 * PI * dist.0 * freq.0 / C).log10();
}

#[cfg(test)]
mod tests {

extern crate assert_approx_eq;
use super::*;

#[test]
fn fspl() {
let mut path_loss: Attenuation;

/// Test against precalculated results
path_loss = free_space_path_loss(ghz(2.4), m(1e0));
assert_approx_eq::assert_approx_eq!(40.05, path_loss.0, 0.01);

path_loss = free_space_path_loss(ghz(2.4), m(1e3));
assert_approx_eq::assert_approx_eq!(100.05, path_loss.0, 0.01);

path_loss = free_space_path_loss(ghz(2.4), m(1e6));
assert_approx_eq::assert_approx_eq!(160.05, path_loss.0, 0.01);

path_loss = free_space_path_loss(mhz(433.0), m(1e3));
assert_approx_eq::assert_approx_eq!(85.178, path_loss.0, 0.01);

path_loss = free_space_path_loss(mhz(433.0), m(1e6));
assert_approx_eq::assert_approx_eq!(145.178, path_loss.0, 0.01);
}

}
```