worked on wifi-scanner for linux
new time-grouping for vap grouper adjusted test-cases minor changes/fixes/improvements
This commit is contained in:
47
sensors/radio/scan/WiFiRAW.h
Normal file
47
sensors/radio/scan/WiFiRAW.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef INDOOR_WIFIRAW_H
|
||||
#define INDOOR_WIFIRAW_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* parse raw binary wifi packets as defined within the standard
|
||||
*/
|
||||
class WiFiRAW {
|
||||
|
||||
public:
|
||||
|
||||
enum Tags {
|
||||
TAG_SSID = 0x00
|
||||
};
|
||||
|
||||
struct TaggedParams {
|
||||
std::string ssid;
|
||||
};
|
||||
|
||||
/** parsed tagged params within wifi packets: [tag][len][len-bytes][tag][len][len-bytes]... */
|
||||
static TaggedParams parseTaggedParams(const uint8_t* data, const size_t len) {
|
||||
|
||||
TaggedParams res;
|
||||
|
||||
int pos = 0;
|
||||
while(pos < len) {
|
||||
|
||||
const int tag = data[pos+0]; // the tag-ID
|
||||
const int len = data[pos+1]; // the lenght of the following data
|
||||
|
||||
switch(tag) {
|
||||
case TAG_SSID: res.ssid = std::string( (const char*) &(data[pos+2]), len); break;
|
||||
}
|
||||
|
||||
// position at the start of the next tag
|
||||
pos += 1 + 1 + len;
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // INDOOR_WIFIRAW_H
|
||||
Reference in New Issue
Block a user