wifiscan.h
Go to the documentation of this file.
00001 /*
00002  The WifiScan class allows WiFi scans using iwlib.h.
00003  Copyright (C) 2013  Rafael Berkvens rafael.berkvens@ua.ac.be
00004 
00005  This program is free software: you can redistribute it and/or modify
00006  it under the terms of the GNU General Public License as published by
00007  the Free Software Foundation, either version 3 of the License, or
00008  (at your option) any later version.
00009 
00010  This program is distributed in the hope that it will be useful,
00011  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  GNU General Public License for more details.
00014 
00015  You should have received a copy of the GNU General Public License
00016  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #ifndef WIFISCAN_H
00020 #define WIFISCAN_H
00021 
00022 #include <cstdio>
00023 #include <string>
00024 #include <map>
00025 #include <string>
00026 #include <vector>
00027 
00028 #include <iwlib.h>
00029 
00030 #include <ros/ros.h>
00031 #include <ros/time.h>
00032 #include <ros/console.h>
00033 
00034 #include <wifi_scan/Fingerprint.h>
00035 
00036 #define WIFISCAN_ERROR_OPENING_IOCTL_SOCKET -1
00037 #define WIFISCAN_ERROR_IN_IW_SCAN -2
00038 #define WIFISCAN_ERROR_GETTING_RANGE_INFO -3
00039 #define WIFISCAN_ERROR_GETTING_BASIC_INFO -4
00040 
00041 #define SCAN_CHANNELS_NO_SCAN_SUPPORT -1
00042 #define SCAN_CHANNELS_UNHANDLED_SIGNAL -2
00043 #define SCAN_CHANNELS_ALLOCATION_FAILED -3
00044 #define SCAN_CHANNELS_FAILED_TO_READ -4
00045 #define SCAN_CHANNELS_PROBLEMS_PROCESSING -5
00046 
00053 class WifiScan
00054 {
00055   char * interface_;
00056   std::vector<int> channels_;
00057 
00058   struct iw_range range_;
00059   int socket_;
00060   int kernel_version_;
00061 
00070   struct iwscan_state
00071   {
00072     int ap_num;
00073     int val_index;
00074   };
00075 
00084   struct iwmask_name
00085   {
00086     unsigned int mask;
00087     const char * name;
00088   };
00089 
00099   struct wireless_scan * iw_process_scanning_token(
00100       struct iw_event * event, struct wireless_scan * wscan);
00101 
00116   int scan_channels(wireless_scan_head * context);
00117 
00118   struct DeviceAddressCompare
00119   {
00120     bool operator()(const std::string &lhs, const std::string &rhs) const;
00121   };
00122 
00123   double MeanRSSI(const std::vector<double> &RSSIValues);
00124 
00125 public:
00129 
00130 
00139   WifiScan(std::vector<int> channels, std::string interface = "wlan0");
00144   virtual ~WifiScan();
00146 
00150 
00151 
00156   std::string interface() const
00157   {
00158     return (std::string) interface_;
00159   }
00167   void set_interface(std::string interface)
00168   {
00169     delete interface_;
00170     this->interface_ = new char[interface.length() + 1];
00171     std::strcpy(interface_, interface.c_str());
00172   }
00174 
00178 
00179 
00194   void createFingerprint(ros::Publisher *pub);
00196 };
00197 
00198 #endif // WIFISCAN_H
00199 // kate: indent-mode cstyle; indent-width 2; replace-tabs on; 


wifi_scan
Author(s): Rafael Berkvens
autogenerated on Fri Aug 28 2015 13:41:23