| 106 | } |
| 107 | |
| 108 | void ManagementAir::loop() { |
| 109 | while (m_tx_thread_run) { |
| 110 | // Air: Continuously broadcast channel width |
| 111 | // Calculate the interval in which we broadcast the channel width management |
| 112 | // frame |
| 113 | auto management_frame_interval = |
| 114 | std::chrono::milliseconds(500); // default 2Hz |
| 115 | const auto elapsed_since_last_change_ms = |
| 116 | openhd::util::steady_clock_time_epoch_ms() - m_last_change_timestamp_ms; |
| 117 | if (elapsed_since_last_change_ms < 2 * 1000) { |
| 118 | // If the last change is recent, send in higher interval |
| 119 | management_frame_interval = std::chrono::milliseconds(20); |
| 120 | } |
| 121 | const auto elapsed_since_last_management_frame = |
| 122 | std::chrono::steady_clock::now() - m_air_last_management_frame; |
| 123 | if (elapsed_since_last_management_frame < management_frame_interval) { |
| 124 | continue; |
| 125 | } |
| 126 | DataManagementTxBandwidth managementFrame{m_curr_frequency_mhz.load(), |
| 127 | m_curr_channel_width_mhz.load()}; |
| 128 | auto data = pack_management_frame(managementFrame); |
| 129 | auto radiotap_header = m_tx_header->thread_safe_get(); |
| 130 | m_wb_txrx->tx_inject_packet(openhd::MANAGEMENT_RADIO_PORT_AIR_TX, |
| 131 | data.data(), data.size(), radiotap_header, |
| 132 | true); |
| 133 | std::this_thread::sleep_for(management_frame_interval); |
| 134 | // std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | void ManagementAir::on_new_management_packet(const uint8_t *data, |
| 139 | int data_len) { |
nothing calls this directly
no test coverage detected