diff --git a/src/WBTxRx.cpp b/src/WBTxRx.cpp index 5323bceb..14c7d997 100644 --- a/src/WBTxRx.cpp +++ b/src/WBTxRx.cpp @@ -492,7 +492,7 @@ void WBTxRx::on_new_packet(const uint8_t wlan_idx,const uint8_t *pkt,const int p auto &this_wifi_card_stats = m_rx_stats_per_card.at(wlan_idx); PerCardCalculators& this_wifi_card_calc= *m_per_card_calc.at(wlan_idx); if(m_options.debug_rssi>=2){ - m_console->debug("{}",radiotap::rx::all_rf_path_to_string(parsedPacket->allAntennaValues)); + m_console->debug("{}",radiotap::rx::all_rf_path_to_string(parsedPacket->rf_paths)); } this_wifi_card_calc.rf_aggregator.on_valid_openhd_packet(parsedPacket.value()); this_wifi_card_stats.count_p_valid++; @@ -562,7 +562,8 @@ bool WBTxRx::process_received_data_packet(int wlan_idx,uint8_t stream_index,bool m_packet_decrypt_time.reset(); } } - on_valid_packet(nonce,wlan_idx,stream_index,decrypted->data(),decrypted->size()); + on_valid_data_packet(nonce, wlan_idx, stream_index, decrypted->data(), + decrypted->size()); // Calculate sequence number stats per card auto& seq_nr_for_card=m_per_card_calc.at(wlan_idx)->seq_nr; seq_nr_for_card.on_new_sequence_number(nonce); @@ -589,7 +590,7 @@ bool WBTxRx::process_received_data_packet(int wlan_idx,uint8_t stream_index,bool return false; } -void WBTxRx::on_valid_packet(uint64_t nonce,int wlan_index,const uint8_t stream_index,const uint8_t *data, const int data_len) { +void WBTxRx::on_valid_data_packet(uint64_t nonce,int wlan_index,const uint8_t stream_index,const uint8_t *data, const int data_len) { if(m_output_cb!= nullptr){ m_output_cb(nonce,wlan_index,stream_index,data,data_len); } diff --git a/src/WBTxRx.h b/src/WBTxRx.h index c9f1a70a..2ef21e26 100644 --- a/src/WBTxRx.h +++ b/src/WBTxRx.h @@ -341,7 +341,9 @@ class WBTxRx { // returns true if packet could be decrypted successfully bool process_received_data_packet(int wlan_idx,uint8_t stream_index,bool encrypted,uint64_t nonce,const uint8_t *pkt_payload,int pkt_payload_size); // called avery time we have successfully decrypted a packet - void on_valid_packet(uint64_t nonce,int wlan_index,uint8_t stream_index,const uint8_t *data,int data_len); + void on_valid_data_packet(uint64_t nonce,int wlan_index, + uint8_t stream_index,const uint8_t *data, + int data_len); static std::string options_to_string(const std::vector& wifi_cards,const Options& options); // Adjustment of which card is used for injecting packets in case there are multiple RX card(s) // (Of all cards currently receiving data, find the one with the highest reported dBm) diff --git a/src/radiotap/RadiotapHeaderRx.hpp b/src/radiotap/RadiotapHeaderRx.hpp index c09ff09a..95fac999 100644 --- a/src/radiotap/RadiotapHeaderRx.hpp +++ b/src/radiotap/RadiotapHeaderRx.hpp @@ -38,12 +38,12 @@ struct ParsedAdapter{ }; struct ParsedRxRadiotapPacket { - // Size can be anything from size=1 to size== N where N is the number of Antennas of this adapter - const std::vector allAntennaValues; const Ieee80211HeaderRaw *ieee80211Header; const uint8_t *payload; const std::size_t payloadSize; - ParsedAdapter adapter; + const ParsedAdapter adapter; + // Size can be anything from size=1 to size== N where N is the number of Antennas of this adapter + const std::vector rf_paths; }; // Returns std::nullopt if radiotap was unable to parse the header @@ -68,6 +68,7 @@ static std::optional process_received_radiotap_packet(co // for rtl8812au fixup // ParsedAdapter parsed_adapter{}; + std::vector parsed_rf_paths{}; int8_t currentAntenna = -1; // not confirmed yet, but one radiotap packet might include stats for multiple antennas @@ -163,7 +164,7 @@ static std::optional process_received_radiotap_packet(co ss<<(int)antsignal<<","; } std::cout<& all_rf static std::string parsed_radiotap_to_string(const ParsedRxRadiotapPacket& parsed){ std::stringstream ss; - ss<avg; + } + } + if(packet.adapter.radiotap_dbm_antnoise.has_value()){ + const auto radiotap_dbm_antnoise=packet.adapter.radiotap_dbm_antnoise.value(); + auto opt_minmaxavg= adapter_noise.add_and_recalculate_if_needed(radiotap_dbm_antnoise); + if(opt_minmaxavg.has_value()){ + m_current_rx_stats.adapter.noise_dbm=opt_minmaxavg->avg; + } + } + if(packet.adapter.radiotap_lock_quality.has_value()){ + const auto radiotap_lock_quality=packet.adapter.radiotap_lock_quality.value(); + adapter_signal_quality.add_signal_quality(radiotap_lock_quality); + m_current_rx_stats.adapter.card_signal_quality_perc=adapter_signal_quality.get_current_signal_quality(); + } + for(int i=0;i1) return ; + auto& per_path=index==0 ? m_antenna1 : m_antenna2; + auto& current=index==0 ? m_current_rx_stats.antenna1 : m_current_rx_stats.antenna2; + { + auto opt_minmaxavg= per_path.rssi_dbm.add_and_recalculate_if_needed(data.radiotap_dbm_antsignal); + if(opt_minmaxavg.has_value()){ + current.rssi_dbm=opt_minmaxavg->avg; + } + } + { + auto opt_minmaxavg= per_path.noise_dbm.add_and_recalculate_if_needed(data.radiotap_dbm_antnoise); + if(opt_minmaxavg.has_value()){ + current.rssi_dbm=opt_minmaxavg->avg; + } + } + { + per_path.signal_quality.add_signal_quality(data.radiotap_dbm_antsignal); + current.card_signal_quality_perc=per_path.signal_quality.get_current_signal_quality(); + } +} + +void RadiotapRxRfAggregator::set_debug_invalid_values(bool enable) { + adapter_rssi.set_debug_invalid_rssi(enable,0); + adapter_noise.set_debug_invalid_rssi(enable,0); + m_antenna1.rssi_dbm.set_debug_invalid_rssi(enable,1); + m_antenna2.rssi_dbm.set_debug_invalid_rssi(enable,2); +} + +void RadiotapRxRfAggregator::reset() { + m_current_rx_stats={}; + adapter_rssi.reset(); + adapter_noise.reset(); + m_antenna1.rssi_dbm.reset(); + m_antenna2.rssi_dbm.reset(); +} diff --git a/src/radiotap/RadiotapRxRfAggregator.h b/src/radiotap/RadiotapRxRfAggregator.h index 6bbe3775..6a8570b1 100644 --- a/src/radiotap/RadiotapRxRfAggregator.h +++ b/src/radiotap/RadiotapRxRfAggregator.h @@ -5,41 +5,12 @@ #ifndef WIFIBROADCAST_RADIOTAPRXRFAGGREGATOR_H #define WIFIBROADCAST_RADIOTAPRXRFAGGREGATOR_H -#include "RSSIAccumulator.hpp" #include "RadiotapHeaderRx.hpp" +#include "RSSIAccumulator.hpp" #include "SignalQualityAccumulator.hpp" class RadiotapRxRfAggregator { public: - void on_valid_openhd_packet(const radiotap::rx::ParsedRxRadiotapPacket& packet){ - if(packet.adapter.radiotap_dbm_antsignal.has_value()){ - const auto radiotap_dbm_antsignal=packet.adapter.radiotap_dbm_antsignal.value(); - auto opt_minmaxavg= adapter_rssi.add_and_recalculate_if_needed(radiotap_dbm_antsignal); - if(opt_minmaxavg.has_value()){ - m_current_rx_stats.adapter.rssi_dbm=opt_minmaxavg->avg; - } - } - if(packet.adapter.radiotap_dbm_antnoise.has_value()){ - const auto radiotap_dbm_antnoise=packet.adapter.radiotap_dbm_antnoise.value(); - auto opt_minmaxavg= adapter_noise.add_and_recalculate_if_needed(radiotap_dbm_antnoise); - if(opt_minmaxavg.has_value()){ - m_current_rx_stats.adapter.noise_dbm=opt_minmaxavg->avg; - } - } - if(packet.adapter.radiotap_lock_quality.has_value()){ - const auto radiotap_lock_quality=packet.adapter.radiotap_lock_quality.value(); - adapter_signal_quality.add_signal_quality(radiotap_lock_quality); - m_current_rx_stats.adapter.card_signal_quality_perc=adapter_signal_quality.get_current_signal_quality(); - } - for(int i=0;i1) return ; - auto& per_path=index==0 ? m_antenna1 : m_antenna2; - auto& current=index==0 ? m_current_rx_stats.antenna1 : m_current_rx_stats.antenna2; - { - auto opt_minmaxavg= per_path.rssi_dbm.add_and_recalculate_if_needed(data.radiotap_dbm_antsignal); - if(opt_minmaxavg.has_value()){ - current.rssi_dbm=opt_minmaxavg->avg; - } - } - { - auto opt_minmaxavg= per_path.noise_dbm.add_and_recalculate_if_needed(data.radiotap_dbm_antnoise); - if(opt_minmaxavg.has_value()){ - current.rssi_dbm=opt_minmaxavg->avg; - } - } - { - per_path.signal_quality.add_signal_quality(data.radiotap_dbm_antsignal); - current.card_signal_quality_perc=per_path.signal_quality.get_current_signal_quality(); - } - } + void on_per_rf_path(int index,const radiotap::rx::ParsedRfPath& data); // Stats per-adapter RSSIAccumulator adapter_rssi{}; RSSIAccumulator adapter_noise{};