AthSpectralScan.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 #ifndef HH_SENF_Ext_NetEmu_WLAN_AthSpectralScan_
15 #define HH_SENF_Ext_NetEmu_WLAN_AthSpectralScan_ 1
16 
17 // Custom includes
20 #include "spectral_common.h"
21 
23 namespace senf {
24 namespace emu {
25 
27  : public senf::FileHandle
28  {
29  public:
31  }
32 
33  void SetFd(int fd_) {
34  fd(fd_);
35  }
36  };
37 
39  {
40  public:
41  typedef std::function<void (std::uint64_t tsft, std::uint16_t frequency, unsigned numBins, void * spectralSample)> AthSpectralScanCallback;
42 
43  AthSpectralScan(std::string phyName);
44  ~AthSpectralScan();
45 
46  bool spectralSetting( std::string option, std::string value);
47  bool spectralSetting( std::string option, unsigned value);
48  unsigned spectralSetting( std::string option) const;
49 
50  bool callback(AthSpectralScanCallback const & cb);
51  void disable();
52  void frequency(std::uint32_t freq, std::uint32_t bandwidth, std::int32_t offset = 0);
53 
54  bool detected() const;
55  bool is_ath9k() const;
56  bool is_ath10k() const;
57 
58  void stats(std::ostream & os);
59 
60  unsigned spectralPeriod() const;
61  unsigned spectralFFTPeriod() const;
62  unsigned spectralShortRepeat() const;
63  unsigned spectralCount() const;
64  unsigned spectralBins() const;
65 
66  bool spectralPeriod(unsigned v);
67  bool spectralFFTPeriod(unsigned v);
68  bool spectralShortRepeat(unsigned v);
69  bool spectralCount(unsigned v);
70  bool spectralBins(unsigned v);
71 
72  private:
73  UnixFileHandle spectralHandle_;
74  senf::scheduler::FdEvent spectralEvent_;
75  std::string spectralPath_;
76  AthSpectralScanCallback callback_;
77  std::uint32_t frequency_;
78  std::int32_t frequencyOffset_;
79 
80  unsigned spectralFrames_;
81  unsigned spectralValidSamples_;
82  unsigned spectralUnknown_;
83  unsigned spectralTruncated_;
84  unsigned spectralFrequencyMismatch_;
85 
86  void handleSpectralEvent(int fd);
87  };
88 
89 }}
91 #endif
92 
friend friend class FileBody
STL namespace.
std::function< void(std::uint64_t tsft, std::uint16_t frequency, unsigned numBins, void *spectralSample)> AthSpectralScanCallback
int fd() const
__be16 freq