From 730dcdea440a8ddf7cc205b47f4dfc39516fdd4c Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Tue, 23 Aug 2011 12:01:59 -0300 Subject: [PATCH] Added Utils::channel_to_mhz to convert channel to mhz frequency. --- include/utils.h | 9 ++++++++- src/utils.cpp | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/utils.h b/include/utils.h index 4ab9bed..ece8024 100644 --- a/include/utils.h +++ b/include/utils.h @@ -164,7 +164,14 @@ namespace Tins { * \param data_size The size of the input buffer. */ uint32_t crc32(uint8_t* data, uint32_t data_size); - + + /** + * \brief Converts a channel number to its mhz representation. + * \param channel The channel number. + * \return The channel's mhz representation. + */ + uint16_t channel_to_mhz(uint16_t channel); + /** \brief Generic function to iterate through interface and collect * data. * diff --git a/src/utils.cpp b/src/utils.cpp index 4c033de..adcc1ce 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -248,6 +248,10 @@ bool Tins::Utils::interface_id(const string &iface, uint32_t &id) { return (((int32_t)id) != -1); } +uint16_t Tins::Utils::channel_to_mhz(uint16_t channel) { + return 2407 + (channel * 5); +} + uint32_t Tins::Utils::crc32(uint8_t* data, uint32_t data_size) { uint32_t i, crc = 0; static uint32_t crc_table[] = {