owlps/owlps-positioner/src/wifidevice.hh

191 lines
4.8 KiB
C++

/*
* This file is part of the Owl Positioning System (OwlPS).
* OwlPS is a project of the University of Franche-Comte
* (Université de Franche-Comté), France.
*
* Copyright © Université de Franche-Comté 2007-2012.
*
* Corresponding author: Matteo Cypriani <mcy@lm7.fr>
*
***********************************************************************
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL:
* http://www.cecill.info
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided
* only with a limited warranty and the software's authors, the holder
* of the economic rights, and the successive licensors have only
* limited liability.
*
* In this respect, the user's attention is drawn to the risks
* associated with loading, using, modifying and/or developing or
* reproducing the software by the user in light of its specific status
* of free software, that may mean that it is complicated to manipulate,
* and that also therefore means that it is reserved for developers and
* experienced professionals having in-depth computer knowledge. Users
* are therefore encouraged to load and test the software's suitability
* as regards their requirements in conditions enabling the security of
* their systems and/or data to be ensured and, more generally, to use
* and operate it in the same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*
***********************************************************************
*/
#ifndef _OWLPS_POSITIONING_WIFIDEVICE_HH_
#define _OWLPS_POSITIONING_WIFIDEVICE_HH_
#include "posutil.hh"
#include <string>
#include <ostream>
#define WIFIDEVICE_DEFAULT_ANTENNA_GAIN 2
#define WIFIDEVICE_DEFAULT_TRX_POWER 20 // 20 dBm = 100 mW
/// Represents a Wi-Fi enabled device
/**
* This class is virtual by design, you should derive it to create new
* types of Wi-Fi devices.
*/
class WifiDevice
{
protected:
std::string ip_addr ;
std::string mac_addr ;
float antenna_gain ; ///< Antenna gain in dBi
float trx_power ; ///< Transmit power in dBm
public:
WifiDevice(const std::string &_ip_addr,
const std::string &_mac_addr,
const float _antenna_gain,
const float _trx_power) ;
WifiDevice(const WifiDevice &source):
ip_addr(source.ip_addr), mac_addr(source.mac_addr),
antenna_gain(source.antenna_gain), trx_power(source.trx_power) {}
virtual ~WifiDevice(void) {}
/** @name Read accessors */
//@{
const std::string& get_ip_addr(void) const ;
const std::string& get_mac_addr(void) const ;
float get_antenna_gain(void) const ;
float get_trx_power(void) const ;
//@}
/** @name Write accessors */
//@{
void set_ip_addr(const std::string &_ip_addr) ;
void set_mac_addr(const std::string &_mac_addr) ;
void set_antenna_gain(float _antenna_gain) ;
void set_trx_power(float _trx_power) ;
//@}
/** @name Operators */
//@{
WifiDevice& operator=(const WifiDevice &wd) ;
bool operator==(const WifiDevice &wd) const ;
bool operator!=(const WifiDevice &wl) const ;
//@}
/// Displays a WifiDevice
friend std::ostream &operator<<(std::ostream &os, const WifiDevice &wd) ;
} ;
/* *** Constructors *** */
inline WifiDevice::
WifiDevice(const std::string &_ip_addr = "",
const std::string &_mac_addr = "",
const float _antenna_gain = WIFIDEVICE_DEFAULT_ANTENNA_GAIN,
const float _trx_power = WIFIDEVICE_DEFAULT_TRX_POWER):
ip_addr(_ip_addr), mac_addr(_mac_addr),
antenna_gain(_antenna_gain), trx_power(_trx_power)
{
assert_uppercase(mac_addr) ;
}
/* *** Read accessors *** */
inline const std::string& WifiDevice::get_ip_addr() const
{
return ip_addr ;
}
inline const std::string& WifiDevice::get_mac_addr() const
{
return mac_addr ;
}
inline float WifiDevice::get_antenna_gain() const
{
return antenna_gain ;
}
inline float WifiDevice::get_trx_power() const
{
return trx_power ;
}
/* *** Write accessors *** */
inline void WifiDevice::set_ip_addr(const std::string &_ip_addr)
{
ip_addr = _ip_addr ;
}
inline void WifiDevice::set_mac_addr(const std::string &_mac_addr)
{
assert_uppercase(_mac_addr) ;
mac_addr = _mac_addr ;
}
inline void WifiDevice::set_antenna_gain(float _antenna_gain)
{
antenna_gain = _antenna_gain ;
}
inline void WifiDevice::set_trx_power(float _trx_power)
{
trx_power = _trx_power ;
}
/* *** Operators *** */
inline bool WifiDevice::operator!=(const WifiDevice &wd) const
{
return !(*this == wd) ;
}
#endif // _OWLPS_POSITIONING_WIFIDEVICE_HH_