The wifi_scan main class. More...
#include <wifiscan.h>
Classes | |
struct | DeviceAddressCompare |
struct | iwmask_name |
Bit to name mapping. More... | |
struct | iwscan_state |
Scan state and meta-information, used to decode events. More... | |
Public Member Functions | |
01. Constructors and destructor | |
WifiScan (std::vector< int > channels, std::string interface="wlan0") | |
Default constructor. | |
virtual | ~WifiScan () |
Destructor. | |
02. Configuration | |
std::string | interface () const |
Get the interface on which scans are performed. | |
void | set_interface (std::string interface) |
Set the interface to perform scans on. | |
03. ROS operations | |
void | createFingerprint (ros::Publisher *pub) |
Publishes a Fingerprint message to the Publisher pub. | |
Private Member Functions | |
struct wireless_scan * | iw_process_scanning_token (struct iw_event *event, struct wireless_scan *wscan) |
Process/store one element from the scanning results in wireless_scan. | |
double | MeanRSSI (const std::vector< double > &RSSIValues) |
int | scan_channels (wireless_scan_head *context) |
Scan the channels indicated in channels. | |
Private Attributes | |
std::vector< int > | channels_ |
char * | interface_ |
int | kernel_version_ |
struct iw_range | range_ |
int | socket_ |
The wifi_scan main class.
The WifiScan class allows for easy operations on the iwlib library, and easy publishing to the defined topics.
Definition at line 53 of file wifiscan.h.
WifiScan::WifiScan | ( | std::vector< int > | channels, |
std::string | interface = "wlan0" |
||
) |
Default constructor.
channels | The channels to scan. Defaults to all channels. |
interface | The Ethernet interface to scan. Defaults to "wlan0". |
Definition at line 313 of file wifiscan.cpp.
WifiScan::~WifiScan | ( | ) | [virtual] |
Destructor.
Definition at line 326 of file wifiscan.cpp.
void WifiScan::createFingerprint | ( | ros::Publisher * | pub | ) |
Publishes a Fingerprint message to the Publisher pub.
A fingerprint is a list of all visible WiFi access points' device addresses linked with their corresponding received signal strength indication.
pub | A ROS Publisher, publishing wifi_scan::Fingerprint messages. Example: ros::Publisher pub = node.advertise<wifi_scan::Fingerprint> ("wifi_fp", 10); |
WIFISCAN_ERROR_OPENING_IOCTL_SOCKET | Error opening ioctl socket. |
WIFISCAN_ERROR_IN_IW_SCAN | Error in iw_scan(). |
Definition at line 331 of file wifiscan.cpp.
std::string WifiScan::interface | ( | ) | const [inline] |
Get the interface on which scans are performed.
Definition at line 156 of file wifiscan.h.
struct wireless_scan * WifiScan::iw_process_scanning_token | ( | struct iw_event * | event, |
struct wireless_scan * | wscan | ||
) | [read, private] |
Process/store one element from the scanning results in wireless_scan.
event | |
wscan |
Definition at line 21 of file wifiscan.cpp.
double WifiScan::MeanRSSI | ( | const std::vector< double > & | RSSIValues | ) | [private] |
Definition at line 302 of file wifiscan.cpp.
int WifiScan::scan_channels | ( | wireless_scan_head * | context | ) | [private] |
Scan the channels indicated in channels.
This code is based on the iwlist print_scanning_info function. See source code of the libiw project (iwlist.c).
I would like to update this function to a class method, so that this range info can be a private variable and must not be constantly checked. Also, the function should be void and use throws instead of returns to indicate errors.
context | Scan results. |
Definition at line 99 of file wifiscan.cpp.
void WifiScan::set_interface | ( | std::string | interface | ) | [inline] |
Set the interface to perform scans on.
interface | An std::string that corresponds to a live Ethernet interface. |
Definition at line 167 of file wifiscan.h.
std::vector<int> WifiScan::channels_ [private] |
Definition at line 56 of file wifiscan.h.
char* WifiScan::interface_ [private] |
Definition at line 55 of file wifiscan.h.
int WifiScan::kernel_version_ [private] |
Definition at line 60 of file wifiscan.h.
struct iw_range WifiScan::range_ [private] |
Definition at line 58 of file wifiscan.h.
int WifiScan::socket_ [private] |
Definition at line 59 of file wifiscan.h.