owlps/owlps-positioning/posutil.hh

47 lines
1.3 KiB
C++

#ifndef _OWLPS_POSITIONING_POSUTIL_HH_
#define _OWLPS_POSITIONING_POSUTIL_HH_
#include <ctime>
#include <stdint.h> // <cstdint> is not C++ 98 compliant
/* 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
/// Utilitary class
class PosUtil
{
public:
/** @name Wi-Fi */
//@{
/// Converts a Wi-Fi channel to the corresponding frequency in Hz
static unsigned int channel_to_frequency(const int &channel) ;
//@}
/** @name Time & Dates */
//@{
/// Converts a struct timespec into a value in milliseconds
static uint64_t timespec_to_ms(const struct timespec &d) ;
/// Converts a time value in milliseconds into a struct timespec
static struct timespec ms_to_timespec(const uint64_t &tms) ;
/// Converts a struct timespec into a value in nanoseconds
static uint64_t timespec_to_ns(const struct timespec &d) ;
/// Converts a time value in nanoseconds into a struct timespec
static struct timespec ns_to_timespec(const uint64_t &tns) ;
//@}
} ;
#endif // _OWLPS_POSITIONING_POSUTIL_HH_