Skip to content

Commit

Permalink
more debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Oct 10, 2023
1 parent 76fa18f commit a526de6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/WBTxRx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ void WBTxRx::on_new_packet(const uint8_t wlan_idx,const uint8_t *pkt,const int p
}
this_wifi_card_calc.rf_aggregator.on_valid_openhd_packet(parsedPacket.value());
if(m_options.rx_radiotap_debug_level==3 || m_options.rx_radiotap_debug_level==4){
m_console->debug("{}",RadiotapRxRfAggregator::card_key_rf_indicators_to_string(this_wifi_card_calc.rf_aggregator.get_current()));
this_wifi_card_calc.rf_aggregator.debug_every_one_second();
}
this_wifi_card_stats.count_p_valid++;
if(wlan_idx==0){
Expand Down
9 changes: 9 additions & 0 deletions src/radiotap/RadiotapRxRfAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ std::string RadiotapRxRfAggregator::card_key_rf_indicators_to_string(
indicators.antenna2.rssi_dbm,indicators.antenna2.noise_dbm,indicators.antenna2.card_signal_quality_perc);
}

void RadiotapRxRfAggregator::debug_every_one_second() {
const auto now=std::chrono::steady_clock::now();
if(now-m_last_debug_log>=std::chrono::seconds(1)){
auto current=get_current();
wifibroadcast::log::get_default()->debug("{}",RadiotapRxRfAggregator::card_key_rf_indicators_to_string(current));
m_last_debug_log=now;
}
}

void RadiotapRxRfAggregator::KeyRfAggregators::reset() {
rssi_dbm.reset();
noise_dbm.reset();
Expand Down
3 changes: 3 additions & 0 deletions src/radiotap/RadiotapRxRfAggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "RadiotapHeaderRx.hpp"
#include "RSSIAccumulator.hpp"
#include "SignalQualityAccumulator.hpp"
#include <chrono>

/**
* Aggregates all key rf metrics.
Expand Down Expand Up @@ -40,6 +41,7 @@ class RadiotapRxRfAggregator {
return m_current_rx_stats;
}
static std::string card_key_rf_indicators_to_string(const CardKeyRfIndicators& indicators);
void debug_every_one_second();
private:
struct KeyRfAggregators{
RSSIAccumulator rssi_dbm;
Expand All @@ -54,6 +56,7 @@ class RadiotapRxRfAggregator {
KeyRfAggregators m_agg_antenna1;
KeyRfAggregators m_agg_antenna2;
CardKeyRfIndicators m_current_rx_stats{};
std::chrono::steady_clock::time_point m_last_debug_log=std::chrono::steady_clock::now();
};

static std::ostream& operator<<(std::ostream& strm, const RadiotapRxRfAggregator::CardKeyRfIndicators& data){
Expand Down

0 comments on commit a526de6

Please sign in to comment.