17 #include <sys/types.h> 27 static void dummy(std::uint64_t tsft, std::uint16_t frequency,
unsigned numBins,
void * spectralSample)
37 spectralValidSamples_(0),
39 spectralTruncated_(0),
40 spectralFrequencyMismatch_(0)
42 spectralPath_ =
"/sys/kernel/debug/ieee80211/" + phyName +
"/ath9k";
43 if (access(spectralPath_.c_str(), O_RDONLY) != 0)
44 spectralPath_ =
"/sys/kernel/debug/ieee80211/" + phyName +
"/ath10k";
67 return access(spectralPath_.c_str(), O_RDONLY) == 0;
73 return spectralPath_.find(
"ath9k") != std::string::npos;
79 return spectralPath_.find(
"ath10k") != std::string::npos;
94 while (read(spectralHandle_.
fd(), buf,
sizeof(buf)) > 0);
95 spectralHandle_.
close();
101 if (!spectralHandle_) {
103 frequencyOffset_ = 0;
126 frequencyOffset_ = offset;
132 prefix_ void senf::emu::AthSpectralScan::handleSpectralEvent(
int _dummy_)
149 spectralValidSamples_++;
152 spectralFrequencyMismatch_++;
155 spectralTruncated_++;
167 spectralValidSamples_++;
170 spectralFrequencyMismatch_++;
173 spectralTruncated_++;
182 std::uint16_t offset (0);
191 signed numBins (length +
sizeof(tlv) -
sizeof(*ath10k));
193 spectralValidSamples_++;
196 spectralTruncated_++;
200 spectralFrequencyMismatch_++;
203 spectralTruncated_++;
214 spectralTruncated_++;
225 if ((cfd = open( (spectralPath_ +
"/" + option).c_str(), O_RDONLY)) != -1) {
226 char buf[128];
int rd;
227 if ((rd = read(cfd, buf,
sizeof((buf)))) > 0) {
239 if ((cfd = open( (spectralPath_ +
"/" + option).c_str(), O_WRONLY)) != -1) {
240 bool rtn (write(cfd, value.c_str(), value.size()) ==
signed(value.size()));
255 if (spectralEvent_.
enabled()) {
260 if ((dfd = open((spectralPath_ +
"/spectral_scan0").c_str(), O_RDONLY|O_NONBLOCK)) == -1) {
264 spectralHandle_.
SetFd(dfd);
265 spectralEvent_.
handle(spectralHandle_);
272 spectralFrames_ = spectralValidSamples_ = spectralFrequencyMismatch_ = spectralTruncated_ = spectralUnknown_ = 0;
281 os << (
is_ath9k() ?
"ath9k" :
"ath10k") << (spectralEvent_.
enabled() ?
" enabled: " :
" disabled: ") <<
"fd " << spectralHandle_.
fd()
282 <<
", frames total " << spectralFrames_ <<
", valid samples " << spectralValidSamples_
283 <<
", frequency mismatch " << spectralFrequencyMismatch_
284 <<
", truncated " << spectralTruncated_ <<
", unknown type " << spectralUnknown_ << std::endl;
#define SPECTRAL_HT20_40_NUM_BINS
unsigned spectralShortRepeat() const
unsigned spectralCount() const
FdEvent & events(int events)
unsigned spectralFFTPeriod() const
boost::function< R(Args)> membind(R(T::*fn)(Args), T *ob)
struct fft_sample_tlv tlv
bool callback(AthSpectralScanCallback const &cb)
#define SPECTRAL_ATH10K_MAX_NUM_BINS
struct fft_sample_tlv tlv
std::function< void(std::uint64_t tsft, std::uint16_t frequency, unsigned numBins, void *spectralSample)> AthSpectralScanCallback
struct fft_sample_tlv tlv
bool spectralSetting(std::string option, std::string value)
unsigned spectralBins() const
FdEvent & handle(Handle const &handle)
void frequency(std::uint32_t freq, std::uint32_t bandwidth, std::int32_t offset=0)
#define SPECTRAL_HT20_NUM_BINS
AthSpectralScan(std::string phyName)
struct fft_sample_tlv tlv
void stats(std::ostream &os)
unsigned spectralPeriod() const