diff --git a/app/telemetry/action/ohdaction.cpp b/app/telemetry/action/ohdaction.cpp index c61538816..23d958956 100644 --- a/app/telemetry/action/ohdaction.cpp +++ b/app/telemetry/action/ohdaction.cpp @@ -4,7 +4,7 @@ #include "../util/openhd_defines.hpp" #include "impl/cmdsender.h" -#include "../models/aohdsystem.h" +//#include "../models/aohdsystem.h" OHDAction::OHDAction(QObject *parent) : QObject{parent} @@ -18,7 +18,7 @@ OHDAction& OHDAction::instance() return instance; } -void OHDAction::request_openhd_version_async() +/*void OHDAction::request_openhd_version_async() { if(AOHDSystem::instanceAir().is_alive()){ auto cmd_air=cmd::helper::create_cmd_request_openhd_version(OHD_SYS_ID_AIR,0); @@ -28,7 +28,7 @@ void OHDAction::request_openhd_version_async() auto cmd_gnd=cmd::helper::create_cmd_request_openhd_version(OHD_SYS_ID_GROUND,0); CmdSender::instance().send_command_long_async(cmd_gnd,nullptr); } -} +}*/ bool OHDAction::send_command_reboot_air(bool reboot) { diff --git a/app/telemetry/action/ohdaction.h b/app/telemetry/action/ohdaction.h index a335b81cf..9a6ccb5de 100644 --- a/app/telemetry/action/ohdaction.h +++ b/app/telemetry/action/ohdaction.h @@ -16,7 +16,8 @@ class OHDAction : public QObject static OHDAction& instance(); public: // request the OpenHD version, both OpenHD air and ground unit will respond to that message. - Q_INVOKABLE void request_openhd_version_async(); + // Deprecated, version is now broadcasted, too + //Q_INVOKABLE void request_openhd_version_async(); // send the reboot / shutdown command to openhd air or ground unit // @param system_id: 0 for ground, 1 for air, 2 for FC Q_INVOKABLE bool send_command_reboot_air(bool reboot); diff --git a/app/telemetry/connection/tcp_connection.cpp b/app/telemetry/connection/tcp_connection.cpp index d92756f53..b13f7d66e 100644 --- a/app/telemetry/connection/tcp_connection.cpp +++ b/app/telemetry/connection/tcp_connection.cpp @@ -132,6 +132,7 @@ bool TCPConnection::setup_socket() return false; } #endif + return true; } diff --git a/app/telemetry/models/wificard.cpp b/app/telemetry/models/wificard.cpp index 469b38cc2..574ced1f7 100644 --- a/app/telemetry/models/wificard.cpp +++ b/app/telemetry/models/wificard.cpp @@ -3,18 +3,44 @@ #include #include "../../logging/hudlogmessagesmodel.h" +#include "util/qopenhdmavlinkhelper.hpp" -static QString card_driver_type_as_string(int type){ - if(type==0)return "UNSUPPORTED"; - if(type==1)return "RTL88X2AU"; - if(type==2)return "RTL88X2BU"; - return "N/A?"; +static std::string wifi_card_type_to_string(const int card_type) { + switch (card_type) { + case 0: + return "RTL88X2AU_OHD"; + case 1: + return "RTL88X2BU_OHD"; + case 2: + return "RTL_88X2AU"; + case 3: + return "RTL_88X2BU"; + case 4: + return "ATHEROS"; + case 5: + return "MT_7921u"; + case 6: + return "RALINK"; + case 7: + return "INTEL"; + case 8: + return "BROADCOM"; + case 9: + default: + return "UNKNOWN"; + } } + WiFiCard::WiFiCard(bool is_air,int card_idx,QObject *parent) : QObject{parent},m_is_air_card(is_air),m_card_idx(card_idx) { + if(!m_is_air_card){ + m_alive_timer = std::make_unique(this); + QObject::connect(m_alive_timer.get(), &QTimer::timeout, this, &WiFiCard::update_alive); + m_alive_timer->start(1000); + } } @@ -44,6 +70,7 @@ WiFiCard &WiFiCard::instance_air() void WiFiCard::process_mavlink(const mavlink_openhd_stats_monitor_mode_wifi_card_t &msg) { + m_last_mavlink_message=QOpenHDMavlinkHelper::getTimeMilliseconds(); set_alive(true); set_curr_rx_rssi_dbm(msg.rx_rssi); set_curr_rx_rssi_dbm_antenna1(msg.rx_rssi_1); @@ -93,10 +120,10 @@ void WiFiCard::process_mavlink(const mavlink_openhd_stats_monitor_mode_wifi_card } } set_card_type(msg.card_type); - set_card_type_as_string(card_driver_type_as_string(msg.card_type)); + set_card_type_as_string(wifi_card_type_to_string(msg.card_type).c_str()); const int card_type=msg.card_type; bool supported = false; - if(card_type==1 || card_type==3)supported=true; + if(card_type==0 || card_type==1)supported=true; set_card_type_supported(supported); } @@ -113,3 +140,11 @@ int WiFiCard::helper_get_gnd_curr_best_rssi() return best_rssi; } +void WiFiCard::update_alive() +{ + const auto elapsed_since_last_message=QOpenHDMavlinkHelper::getTimeMilliseconds()-m_last_mavlink_message; + if(elapsed_since_last_message>5*1000){ + set_alive(false); + } +} + diff --git a/app/telemetry/models/wificard.h b/app/telemetry/models/wificard.h index e54719af2..e31e2a80b 100644 --- a/app/telemetry/models/wificard.h +++ b/app/telemetry/models/wificard.h @@ -1,7 +1,9 @@ #ifndef WIFICARD_H #define WIFICARD_H +#include #include +#include #include "../../../lib/lqtutils_master/lqtutils_prop.h" #include "../util/mavlink_include.h" @@ -46,6 +48,10 @@ class WiFiCard : public QObject // On the OSD, we show how many packets were received on each card in X seconds intervals std::chrono::steady_clock::time_point m_last_packets_in_X_second_recalculation=std::chrono::steady_clock::now(); int64_t m_last_packets_in_X_second_value=-1; + // Card alive - ONLY USED FOR GROUND CARD(s) + std::unique_ptr m_alive_timer = nullptr; + std::atomic m_last_mavlink_message=0; + void update_alive(); }; #endif // WIFICARD_H diff --git a/app/telemetry/settings/wblinksettingshelper.cpp b/app/telemetry/settings/wblinksettingshelper.cpp index 465c695b9..403ed549c 100644 --- a/app/telemetry/settings/wblinksettingshelper.cpp +++ b/app/telemetry/settings/wblinksettingshelper.cpp @@ -7,6 +7,15 @@ #include #include #include "../action/ohdaction.h" +#include "../../util/qopenhd.h" + +static void tmp_log_result(bool enable,const std::string message){ + if(enable){ + HUDLogMessagesModel::instance().add_message_info(message.c_str()); + }else{ + qDebug()<<"Not logged to HUD:"<(value),"BWIDTH"); +} + QList WBLinkSettingsHelper::get_supported_frequencies() { std::lock_guard lock(m_supported_channels_mutex); diff --git a/app/telemetry/settings/wblinksettingshelper.h b/app/telemetry/settings/wblinksettingshelper.h index fec8640fb..a76a57a53 100644 --- a/app/telemetry/settings/wblinksettingshelper.h +++ b/app/telemetry/settings/wblinksettingshelper.h @@ -82,17 +82,17 @@ class WBLinkSettingsHelper : public QObject Q_INVOKABLE int change_param_air_and_ground_frequency(int value){ return change_param_air_and_ground_blocking(PARAM_ID_WB_FREQ,value); } - Q_INVOKABLE int change_param_air_and_ground_channel_width(int value){ - //return change_param_air_and_ground_blocking(PARAM_ID_WB_CHANNEL_WIDTH,value); - change_param_air_async(OHD_COMP_ID_LINK_PARAM,PARAM_ID_WB_CHANNEL_WIDTH,static_cast(value),"BWIDTH"); - return 0; - } + // + // Changing the channel width (bandwidth) is a bit special - read the documentation in openhd + // wb_link for more info. + // This method won't return any success / error message, since we update the UI not depending on the result, + // but what channel width the ground reports via broadcast + // + Q_INVOKABLE void change_param_air_channel_width_async(int value,bool log_result); + Q_INVOKABLE bool change_param_ground_only_frequency(int value){ return change_param_ground_only_blocking(PARAM_ID_WB_FREQ,value); } - Q_INVOKABLE bool change_param_ground_only_channel_width(int value){ - return change_param_ground_only_blocking(PARAM_ID_WB_CHANNEL_WIDTH,value); - } Q_INVOKABLE QList get_supported_frequencies(); Q_INVOKABLE QString get_frequency_description(int frequency_mhz); Q_INVOKABLE int get_frequency_pollution(int frequency_mhz); diff --git a/qml/ui/HUDOverlayGrid.qml b/qml/ui/HUDOverlayGrid.qml index 090bb1bcb..68e51f72f 100644 --- a/qml/ui/HUDOverlayGrid.qml +++ b/qml/ui/HUDOverlayGrid.qml @@ -27,9 +27,9 @@ Item { property bool m_keyboard_navigation_active: false onM_keyboard_navigation_activeChanged: { if(m_keyboard_navigation_active){ - _hudLogMessagesModel.add_message_info("JOYSTICK NAVIGATION ENABLED"); + _qopenhd.show_toast("JOYSTICK NAVIGATION ENABLED"); }else{ - _hudLogMessagesModel.add_message_info("JOYSTICK NAVIGATION DISABLED"); + _qopenhd.show_toast("JOYSTICK NAVIGATION DISABLED"); } } diff --git a/qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml b/qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml index 32c40baec..d64ac00b5 100644 --- a/qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml +++ b/qml/ui/configpopup/openhd_settings/DialoqueChangeTxPower.qml @@ -61,13 +61,13 @@ You can still use the RAW OpenHD AIR / GROUND Parameters to change your tx power }else{ wifi_card_chip_type=_wifi_card_air.card_type; } - if(wifi_card_chip_type<=0){ - _messageBoxInstance.set_text_and_show("Card type unknown - please use a supported card. You can still change the tx power manually via the param set, but probably + if(!(wifi_card_chip_type==0 || wifi_card_chip_type==1)){ + _messageBoxInstance.set_text_and_show("Card type unknown / unsupported - please use a supported card. You can still change the tx power manually via the param set, but probably the card driver and/or the linux kernel doesn't support changing it."); return; } - // OpenHD has 0 for unknown, we do not allow 0 - m_card_chip_type=wifi_card_chip_type-1; + // 0 is RTL8812AU, 1 is RTL8812BU + m_card_chip_type=wifi_card_chip_type; //m_card_chip_type=0; // RTL8812AU dialoqueTxPower.visible=true } diff --git a/qml/ui/configpopup/openhd_settings/MavlinkExtraWBParamPanel.qml b/qml/ui/configpopup/openhd_settings/MavlinkExtraWBParamPanel.qml index 5adaf48c6..3c3ad2b6f 100644 --- a/qml/ui/configpopup/openhd_settings/MavlinkExtraWBParamPanel.qml +++ b/qml/ui/configpopup/openhd_settings/MavlinkExtraWBParamPanel.qml @@ -213,6 +213,14 @@ Rectangle{ return ret; } + function set_channel_width_async(channel_width_mhz){ + if(!_ohdSystemAir.is_alive){ + _qopenhd.show_toast("Cannot change BW:"+channel_width_mhz+"Mhz, AIR not alive") + return; + } + _wbLinkSettingsHelper.change_param_air_channel_width_async(channel_width_mhz,false); + } + property string m_text_warning_nosync_frequency: "WARNING: THIS CHANGES YOUR GROUND UNIT FREQUENCY WITHOUT CHANGING YOUR AIR UNIT FREQUENCY ! Only enable if you want to quickly change your ground unit's frequency to the already set frequency of a running air unit (And know both frequency and channel width on top of your head)"; @@ -472,18 +480,16 @@ the analyze channels feature or experience - [169] 5845Mhz is a good bet in Eur _messageBoxInstance.set_text_and_show(m_info_text_change_channel_width) } } - /*FreqComboBoxRow{ m_main_text: _fcM }*/ - Text{ text: "Curr:"+get_text_current_frequency(); } Button{ text: "20Mhz" onClicked: { - set_channel_width(20) + set_channel_width_async(20); } highlighted: _wbLinkSettingsHelper.curr_channel_width_mhz==20 enabled: _wbLinkSettingsHelper.ui_rebuild_models>0 && _ohdSystemAir.is_alive @@ -491,7 +497,7 @@ the analyze channels feature or experience - [169] 5845Mhz is a good bet in Eur Button{ text: "40Mhz" onClicked: { - set_channel_width(40) + set_channel_width_async(40); } highlighted: _wbLinkSettingsHelper.curr_channel_width_mhz==40 enabled: _wbLinkSettingsHelper.ui_rebuild_models>0 && _ohdSystemAir.is_alive diff --git a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml index e88d3b458..c1db18f19 100644 --- a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml +++ b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml @@ -92,17 +92,9 @@ ColumnLayout { Layout.preferredWidth: left_part_preferred_with text: qsTr("OHD Version:") } - Button{ - text: "N/A" - onClicked: _ohdAction.request_openhd_version_async() - visible: (m_version==="N/A") - Layout.preferredHeight: text_minHeight - Layout.minimumHeight: text_minHeight - height: text_minHeight - } Text { text: m_version - visible: !(m_version==="N/A") && !b_version_warning.visible + visible: !b_version_warning.visible } ButtonYellow{ text: m_version diff --git a/qml/ui/widgets/WBLinkRateControlWidget.qml b/qml/ui/widgets/WBLinkRateControlWidget.qml index d0a681ade..ee857b08b 100644 --- a/qml/ui/widgets/WBLinkRateControlWidget.qml +++ b/qml/ui/widgets/WBLinkRateControlWidget.qml @@ -136,19 +136,12 @@ BaseWidget { _wbLinkSettingsHelper.set_param_air_only_mcs_async(mcs_index) } - function set_channel_width(channel_width_mhz){ - if(!_ohdSystemGround.is_alive){ - _hudLogMessagesModel.add_message_warning("GND not alive,cannot set "+channel_width_mhz+"Mhz Bandwidth") - return - } + function set_channel_width_async(channel_width_mhz){ if(!_ohdSystemAir.is_alive){ - _hudLogMessagesModel.add_message_warning("AIR not alive,cannot set "+channel_width_mhz+"Mhz Bandwidth") + _hudLogMessagesModel.add_message_warning("Cannot change BW:"+channel_width_mhz+"Mhz, AIR not alive"); return; } - var result = _wbLinkSettingsHelper.change_param_air_and_ground_channel_width(channel_width_mhz) - if(result !== 0){ - _hudLogMessagesModel.add_message_warning("Cannot set "+channel_width_mhz+"Mhz Bandwidth") - } + _wbLinkSettingsHelper.change_param_air_channel_width_async(channel_width_mhz,true); } property string m_DESCRIPTION_CHANNEL_WIDTH: " @@ -328,18 +321,18 @@ Make the video more stable (less microfreezes) on the cost of less image quality Button{ text: "20Mhz" onClicked: { - set_channel_width(20) + set_channel_width_async(20) } highlighted: m_curr_channel_width==20 - enabled: !m_is_armed + //enabled: _ohdSystemAir.is_alive } Button{ text: "40Mhz" onClicked: { - set_channel_width(40) + set_channel_width_async(40) } highlighted: m_curr_channel_width==40 - enabled: !m_is_armed + //enabled: _ohdSystemAir.is_alive } } }