[Positioning] AccessPoint: frequency in Hz
The AP frequency was (by mistake) in MHz. It is now in Hz, as documented. Function PosUtil::channel_to_frequency() is renamed wifi_channel_to_hz().
This commit is contained in:
parent
f0831db109
commit
9f907b4db5
|
@ -13,7 +13,7 @@ class AccessPoint: public WifiDevice
|
|||
{
|
||||
protected:
|
||||
Point3D coordinates ;
|
||||
unsigned int frequency ; ///< Frequency (channel) in Hz
|
||||
unsigned long frequency ; ///< Frequency (channel) in Hz
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -31,13 +31,13 @@ public:
|
|||
const unsigned int &channel = AP_DEFAULT_CHANNEL):
|
||||
WifiDevice(_ip_addr, _mac_addr, _antenna_gain, _trx_power),
|
||||
coordinates(_coordinates),
|
||||
frequency(PosUtil::channel_to_frequency(channel)) {}
|
||||
frequency(PosUtil::wifi_channel_to_hz(channel)) {}
|
||||
|
||||
AccessPoint(const WifiDevice &source,
|
||||
const Point3D &_coordinates,
|
||||
const unsigned int &channel = AP_DEFAULT_CHANNEL):
|
||||
WifiDevice(source), coordinates(_coordinates),
|
||||
frequency(PosUtil::channel_to_frequency(channel)) {}
|
||||
frequency(PosUtil::wifi_channel_to_hz(channel)) {}
|
||||
|
||||
AccessPoint(const WifiDevice &source):
|
||||
WifiDevice(source), coordinates(Point3D()), frequency(0) {}
|
||||
|
@ -51,14 +51,14 @@ public:
|
|||
/** @name Read accessors */
|
||||
//@{
|
||||
const Point3D& get_coordinates(void) const ;
|
||||
unsigned int get_frequency(void) const ;
|
||||
unsigned long get_frequency(void) const ;
|
||||
//@}
|
||||
|
||||
/** @name Write accessors */
|
||||
//@{
|
||||
void set_coordinates(const Point3D &_coordinates) ;
|
||||
void set_channel(const unsigned int channel) ;
|
||||
void set_frequency(const unsigned int _frequency) ;
|
||||
void set_frequency(const unsigned long _frequency) ;
|
||||
//@}
|
||||
|
||||
/** @name Operators */
|
||||
|
@ -83,7 +83,7 @@ inline const Point3D& AccessPoint::get_coordinates() const
|
|||
}
|
||||
|
||||
|
||||
inline unsigned int AccessPoint::get_frequency() const
|
||||
inline unsigned long AccessPoint::get_frequency() const
|
||||
{
|
||||
return frequency ;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ inline void AccessPoint::set_coordinates(const Point3D &_coordinates)
|
|||
*/
|
||||
inline void AccessPoint::set_channel(const unsigned int channel)
|
||||
{
|
||||
set_frequency(PosUtil::channel_to_frequency(channel)) ;
|
||||
set_frequency(PosUtil::wifi_channel_to_hz(channel)) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,7 +117,7 @@ inline void AccessPoint::set_channel(const unsigned int channel)
|
|||
* Note that set_channel() is more secure because a wrong channel
|
||||
* number will cause #frequency to be nullified.
|
||||
*/
|
||||
inline void AccessPoint::set_frequency(const unsigned int _frequency)
|
||||
inline void AccessPoint::set_frequency(const unsigned long _frequency)
|
||||
{
|
||||
frequency = _frequency ;
|
||||
}
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
|
||||
|
||||
|
||||
/* Wi-Fi channel frequencies in Hz */
|
||||
#define CHANNEL_1 2412
|
||||
#define CHANNEL_2 2417
|
||||
#define CHANNEL_3 2422
|
||||
#define CHANNEL_4 2427
|
||||
#define CHANNEL_5 2432
|
||||
#define CHANNEL_6 2437
|
||||
#define CHANNEL_7 2442
|
||||
#define CHANNEL_8 2447
|
||||
#define CHANNEL_9 2452
|
||||
#define CHANNEL_10 2457
|
||||
#define CHANNEL_11 2462
|
||||
#define CHANNEL_12 2467
|
||||
#define CHANNEL_13 2472
|
||||
#define CHANNEL_14 2477
|
||||
/* Wi-Fi channel frequencies in MHz */
|
||||
#define CHANNEL_1 2412000000ul
|
||||
#define CHANNEL_2 2417000000ul
|
||||
#define CHANNEL_3 2422000000ul
|
||||
#define CHANNEL_4 2427000000ul
|
||||
#define CHANNEL_5 2432000000ul
|
||||
#define CHANNEL_6 2437000000ul
|
||||
#define CHANNEL_7 2442000000ul
|
||||
#define CHANNEL_8 2447000000ul
|
||||
#define CHANNEL_9 2452000000ul
|
||||
#define CHANNEL_10 2457000000ul
|
||||
#define CHANNEL_11 2462000000ul
|
||||
#define CHANNEL_12 2467000000ul
|
||||
#define CHANNEL_13 2472000000ul
|
||||
#define CHANNEL_14 2477000000ul
|
||||
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
|||
* Note that if \em channel is a frequency in Hz, this function will
|
||||
* consider it as a wrong value and return 0.
|
||||
*/
|
||||
unsigned int PosUtil::channel_to_frequency(const int &channel)
|
||||
unsigned long PosUtil::wifi_channel_to_hz(const unsigned int &channel)
|
||||
{
|
||||
switch (channel)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ public:
|
|||
/** @name Wi-Fi */
|
||||
//@{
|
||||
/// Converts a Wi-Fi channel to the corresponding frequency in Hz
|
||||
static unsigned int channel_to_frequency(const int &channel) ;
|
||||
static unsigned long wifi_channel_to_hz(const unsigned int &channel) ;
|
||||
//@}
|
||||
} ;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
TS_ASSERT_EQUALS(accesspoint1.get_antenna_gain(), 6) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_trx_power(), 38) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_frequency(),
|
||||
PosUtil::channel_to_frequency(10)) ;
|
||||
PosUtil::wifi_channel_to_hz(10)) ;
|
||||
|
||||
// Write & read accessors
|
||||
Point3D point3d2(78,23,4) ;
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
TS_ASSERT_DELTA(accesspoint1.get_trx_power(), 22.7, 0.00001) ;
|
||||
accesspoint1.set_channel(13) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_frequency(),
|
||||
PosUtil::channel_to_frequency(13)) ;
|
||||
PosUtil::wifi_channel_to_hz(13)) ;
|
||||
accesspoint1.set_frequency(2423) ;
|
||||
TS_ASSERT_EQUALS(accesspoint1.get_frequency(), 2423u) ;
|
||||
}
|
||||
|
|
|
@ -9,15 +9,17 @@ public:
|
|||
void test_wifi(void)
|
||||
{
|
||||
// Bad values
|
||||
TS_ASSERT_EQUALS(PosUtil::channel_to_frequency(0),
|
||||
TS_ASSERT_EQUALS(PosUtil::wifi_channel_to_hz(0),
|
||||
static_cast<unsigned int>(0)) ;
|
||||
TS_ASSERT_EQUALS(PosUtil::channel_to_frequency(15),
|
||||
TS_ASSERT_EQUALS(PosUtil::wifi_channel_to_hz(15),
|
||||
static_cast<unsigned int>(0)) ;
|
||||
|
||||
// Good values
|
||||
for (unsigned int i = 1 ; i < 15 ; ++i)
|
||||
TS_ASSERT(PosUtil::channel_to_frequency(i) >= 2412 &&
|
||||
PosUtil::channel_to_frequency(i) <= 2477) ;
|
||||
{
|
||||
TS_ASSERT(PosUtil::wifi_channel_to_hz(i) >= 2412000000ul) ;
|
||||
TS_ASSERT(PosUtil::wifi_channel_to_hz(i) <= 2477000000ul) ;
|
||||
}
|
||||
}
|
||||
|
||||
} ;
|
||||
|
|
Loading…
Reference in New Issue