Skip to content

Commit

Permalink
finalizing touches
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Sep 27, 2023
1 parent 24c5833 commit a59fa88
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 61 deletions.
74 changes: 34 additions & 40 deletions app/telemetry/models/aohdsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,11 @@ void AOHDSystem::process_x1(const mavlink_openhd_stats_monitor_mode_wifi_link_t
set_curr_mcs_index(new_mcs_index);
set_curr_channel_mhz(msg.curr_tx_channel_mhz);
set_curr_channel_width_mhz(msg.curr_tx_channel_w_mhz);
if(!m_is_air){
WBLinkSettingsHelper::instance().validate_and_set_channel_mhz(msg.curr_tx_channel_mhz);
WBLinkSettingsHelper::instance().validate_and_set_channel_width_mhz(msg.curr_tx_channel_w_mhz);
if(m_is_air){
WBLinkSettingsHelper::instance().validate_and_set_air_channel_width_mhz(msg.curr_tx_channel_w_mhz);
}else{
WBLinkSettingsHelper::instance().validate_and_set_gnd_channel_mhz(msg.curr_tx_channel_mhz);
WBLinkSettingsHelper::instance().validate_and_set_gnd_channel_width_mhz(msg.curr_tx_channel_w_mhz);
}
set_curr_bitrate_kbits(msg.curr_rate_kbits);
set_curr_n_rate_adjustments(msg.curr_n_rate_adjustments);
Expand Down Expand Up @@ -453,46 +455,38 @@ void AOHDSystem::process_x4b(const mavlink_openhd_stats_wb_video_ground_fec_perf

void AOHDSystem::update_alive()
{
// On the air unit, we consider it alive if "any" message has come in, not only the mavlink heartbeat
const int32_t last_heartbeat_or_message = m_is_air ? m_last_message_ms : m_last_heartbeat_ms;
if(last_heartbeat_or_message==-1){
set_is_alive(false);
}else{
const auto elapsed_since_last_heartbeat=QOpenHDMavlinkHelper::getTimeMilliseconds()-last_heartbeat_or_message;
// after X seconds, consider as "not alive"
const bool alive=elapsed_since_last_heartbeat< 3*1000;
if(alive != m_is_alive){
// message when state changes
send_message_hud_connection(alive);
//
set_is_alive(alive);
}
}
}

void AOHDSystem::send_message_hud_connection(bool connected){
std::stringstream message;
if(m_is_air){
message << "Air unit ";
}else{
message << "Ground unit ";
}
if(connected){
message << "connected";
HUDLogMessagesModel::instance().add_message_info(message.str().c_str());
//QOpenHD::instance().textToSpeech_sayMessage(message.str().c_str());
}else{
message << "disconnected";
HUDLogMessagesModel::instance().add_message_warning(message.str().c_str());
// NOTE: Since we are really resourcefully with the link, we consider the system alive if any message coming from it has
// come through, not only a heartbeat
// AIR: Quite lossy, and r.n we send about 2 to 3 telemetry packets per second
// GROUND: OpenHD (can) send a lot of data to QOpenHD, since there are no bw constraints
const int tmp=m_last_message_ms;
if(tmp<=-1){
update_alive_status_with_hud_message(false);
return;
}
const auto elapsed_ms=QOpenHDMavlinkHelper::getTimeMilliseconds()-m_last_message_ms;
const bool alive=elapsed_ms < (m_is_air ? 3*1000 : 2*1000);
update_alive_status_with_hud_message(alive);
}

bool AOHDSystem::should_request_version()
void AOHDSystem::update_alive_status_with_hud_message(bool alive)
{
if(m_openhd_version=="N/A" && m_n_times_version_has_been_requested<10){
m_n_times_version_has_been_requested++;
return true;
if(alive != m_is_alive){
// message when state changes
std::stringstream message;
if(m_is_air){
message << "Air unit ";
}else{
message << "Ground unit ";
}
if(alive){
message << "connected";
HUDLogMessagesModel::instance().add_message_info(message.str().c_str());
//QOpenHD::instance().textToSpeech_sayMessage(message.str().c_str());
}else{
message << "disconnected";
HUDLogMessagesModel::instance().add_message_warning(message.str().c_str());
}
set_is_alive(alive);
}
return false;
}

10 changes: 2 additions & 8 deletions app/telemetry/models/aohdsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,13 @@ class AOHDSystem : public QObject
std::chrono::steady_clock::time_point m_last_message_openhd_stats_total_all_wifibroadcast_streams=std::chrono::steady_clock::now();
// Model / fire and forget data only end
private:
int64_t x_last_dropped_packets=-1;
void send_message_hud_connection(bool connected);
public:
// Ditry, until we have send command with retransmissions
// request version if not set yet, but no more than x times
bool should_request_version();
private:
int m_n_times_version_has_been_requested=0;
int64_t x_last_dropped_packets=-1;
private:
// do not completely pollute the HUD with this error message
std::chrono::steady_clock::time_point m_last_tx_error_hud_message=std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point m_last_n_cameras_message=std::chrono::steady_clock::now();
bool m_stbc_warning_shown=false;
void update_alive_status_with_hud_message(bool alive);
};


Expand Down
13 changes: 11 additions & 2 deletions app/telemetry/settings/wblinksettingshelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool WBLinkSettingsHelper::start_scan_channels(int freq_bands,int channel_widths
}


void WBLinkSettingsHelper::validate_and_set_channel_mhz(int channel_mhz)
void WBLinkSettingsHelper::validate_and_set_gnd_channel_mhz(int channel_mhz)
{
if(channel_mhz<=1000 || channel_mhz>=8000){
qDebug()<<"Invalid channel "<<channel_mhz<<"Mhz";
Expand All @@ -62,7 +62,7 @@ void WBLinkSettingsHelper::validate_and_set_channel_mhz(int channel_mhz)
}
}

void WBLinkSettingsHelper::validate_and_set_channel_width_mhz(int channel_width_mhz)
void WBLinkSettingsHelper::validate_and_set_gnd_channel_width_mhz(int channel_width_mhz)
{
if(!(channel_width_mhz==20 || channel_width_mhz==40 || channel_width_mhz==80)){
qDebug()<<"Invalid channel width "<<channel_width_mhz<<" Mhz";
Expand All @@ -75,6 +75,15 @@ void WBLinkSettingsHelper::validate_and_set_channel_width_mhz(int channel_width_
}
}

void WBLinkSettingsHelper::validate_and_set_air_channel_width_mhz(int channel_width_mhz)
{
if(!(channel_width_mhz==20 || channel_width_mhz==40 || channel_width_mhz==80)){
qDebug()<<"Invalid channel width "<<channel_width_mhz<<" Mhz";
return;
}
set_curr_air_channel_width_mhz(channel_width_mhz);
}

void WBLinkSettingsHelper::set_simplify_channels(bool enable)
{
m_simplify_channels=enable;
Expand Down
6 changes: 4 additions & 2 deletions app/telemetry/settings/wblinksettingshelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class WBLinkSettingsHelper : public QObject
// These are also in aohdsystem, their usage (and correct setting of them) is required here, too
L_RO_PROP(int,curr_channel_mhz,set_curr_channel_mhz,-1)
L_RO_PROP(int,curr_channel_width_mhz,set_curr_channel_width_mhz,-1);
L_RO_PROP(int,curr_air_channel_width_mhz,set_curr_air_channel_width_mhz,-1);

// Set to true once the channels from the ground have been succesfully fetched
//L_RO_PROP(bool,has_fetched_channels,set_has_fetched_channels,false);
Expand All @@ -55,8 +56,9 @@ class WBLinkSettingsHelper : public QObject
void process_message_openhd_wifibroadcast_supported_channels(const mavlink_openhd_wifbroadcast_supported_channels_t& msg);
void process_message_openhd_wifibroadcast_analyze_channels_progress(const mavlink_openhd_wifbroadcast_analyze_channels_progress_t& msg);
void process_message_openhd_wifibroadcast_scan_channels_progress(const mavlink_openhd_wifbroadcast_scan_channels_progress_t& msg);
void validate_and_set_channel_mhz(int channel);
void validate_and_set_channel_width_mhz(int channel_width_mhz);
void validate_and_set_gnd_channel_mhz(int channel);
void validate_and_set_gnd_channel_width_mhz(int channel_width_mhz);
void validate_and_set_air_channel_width_mhz(int channel_width_mhz);
public:
Q_INVOKABLE void set_simplify_channels(bool enable);
//Q_INVOKABLE void fetch_channels_if_needed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,16 +504,16 @@ the analyze channels feature or experience - [169] 5845Mhz is a good bet in Eur
onClicked: {
set_channel_width_async(20);
}
highlighted: _wbLinkSettingsHelper.curr_channel_width_mhz==20
enabled: _wbLinkSettingsHelper.ui_rebuild_models>0 && _ohdSystemAir.is_alive
highlighted: _wbLinkSettingsHelper.curr_air_channel_width_mhz==20
enabled: _ohdSystemAir.is_alive
}
Button{
text: "40Mhz"
onClicked: {
set_channel_width_async(40);
}
highlighted: _wbLinkSettingsHelper.curr_channel_width_mhz==40
enabled: _wbLinkSettingsHelper.ui_rebuild_models>0 && _ohdSystemAir.is_alive
highlighted: _wbLinkSettingsHelper.curr_air_channel_width_mhz==40
enabled: _ohdSystemAir.is_alive
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion qml/ui/configpopup/status/QOpenHDVersionCard.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Card {
id: title
height: 48
color: "#ff3a3a3a"
text: qsTr("QOpenHD-evo-2.5.0-beta3")
text: qsTr("QOpenHD-evo-2.5.0-beta4X")
font.pixelSize: 36
}
}
Expand Down
5 changes: 1 addition & 4 deletions qml/ui/widgets/WBLinkRateControlWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ BaseWidget {
widgetActionWidth: m_widget_action_w
widgetActionHeight: m_widget_action_h

property int m_curr_channel_width: _ohdSystemGround.curr_channel_width_mhz

property int m_curr_channel_width: _ohdSystemAir.curr_channel_width_mhz
property int m_curr_mcs_index: _ohdSystemAir.curr_mcs_index
property int m_curr_bitrate_kbits: _ohdSystemAir.curr_bitrate_kbits

Expand Down Expand Up @@ -324,15 +323,13 @@ Make the video more stable (less microfreezes) on the cost of less image quality
set_channel_width_async(20)
}
highlighted: m_curr_channel_width==20
//enabled: _ohdSystemAir.is_alive
}
Button{
text: "40Mhz"
onClicked: {
set_channel_width_async(40)
}
highlighted: m_curr_channel_width==40
//enabled: _ohdSystemAir.is_alive
}
}
}
Expand Down

0 comments on commit a59fa88

Please sign in to comment.