Skip to content

Commit

Permalink
Merge pull request #662 from OpenHD/consti-dev
Browse files Browse the repository at this point in the history
Fix adsb openssl errors (well, we can safely ignore them ... ;) )
  • Loading branch information
Consti10 authored Feb 19, 2024
2 parents 1eb49f7 + 3035121 commit 824aa60
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 40 deletions.
24 changes: 19 additions & 5 deletions app/adsb/adsbvehiclemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@

#include <QDebug>

static ADSBVehicleManager* _instance = nullptr;

ADSBVehicleManager* ADSBVehicleManager::instance()
{
if ( _instance == nullptr ) {
_instance = new ADSBVehicleManager();
}
return _instance;
// This is the only required c++ code for a thread safe singleton
static ADSBVehicleManager instance{};
return &instance;
}

ADSBVehicleManager::ADSBVehicleManager(QObject *parent) : QObject(parent)
Expand Down Expand Up @@ -191,6 +189,7 @@ void ADSBapi::run(void)

void ADSBapi::init(void) {
QNetworkAccessManager * manager = new QNetworkAccessManager(this);
//qDebug()<<"isStrictTransportSecurityEnabled:"<<(manager->isStrictTransportSecurityEnabled() ? "Y" : "N");

m_manager = manager;

Expand Down Expand Up @@ -222,13 +221,15 @@ void ADSBInternet::requestData(void) {
_adsb_enable = _settings.value("adsb_enable").toBool();
_adsb_show_internet_data = _settings.value("adsb_show_internet_data").toBool();
max_distance = _settings.value("adsb_radius").toInt();
QObject::connect(m_manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(dirty_onSslError(QNetworkReply*, QList<QSslError>)));

QString distance_string = QString::number(max_distance/1852); // convert meters to NM for api

// If adsb or adsb_internet is disabled by settings don't make the internet request and return
if (!_adsb_enable || !_adsb_show_internet_data) {
return;
}
// TODO - http instead of https ?
adsb_url="https://api.airplanes.live/v2/point/"+ lat_string +"/"+ lon_string + "/" + distance_string;
QNetworkRequest request;
QUrl api_request = adsb_url;
Expand All @@ -254,9 +255,15 @@ void ADSBInternet::processReply(QNetworkReply *reply) {
reply->deleteLater();
return;
}
if(!reply->isFinished()){
qDebug()<<"We should only get finished replies";
}


QJsonParseError errorPtr;
QByteArray data = reply->readAll();
//qDebug()<<"Len:"<<data.length()<<" available in reply:"<<reply->bytesAvailable();
//qDebug()<<"URL was:"<<reply->request().url();
QJsonDocument doc = QJsonDocument::fromJson(data, &errorPtr);

if (doc.isNull()) {
Expand Down Expand Up @@ -415,6 +422,13 @@ void ADSBInternet::processReply(QNetworkReply *reply) {
reply->deleteLater();
}

void ADSBInternet::dirty_onSslError(QNetworkReply *reply, QList<QSslError> errors)
{
// Consti10: Dang openssl - just ignore all SSL errors !
//qDebug()<<"got some ssl errors";
reply->ignoreSslErrors();
}

ADSBSdr::ADSBSdr()
: ADSBapi()
{
Expand Down
2 changes: 1 addition & 1 deletion app/adsb/adsbvehiclemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class ADSBInternet: public ADSBapi {

private slots:
void processReply(QNetworkReply *reply) override;
void dirty_onSslError(QNetworkReply* reply, QList<QSslError> errors);
void requestData() override;

private:
bool _adsb_show_internet_data;
};
Expand Down
21 changes: 15 additions & 6 deletions app/telemetry/settings/documentedparam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,21 @@ static std::vector<std::shared_ptr<XParam>> get_parameters_list(){
}),
"!!!Editing this param manually without care will result in a broken link!!!"
);
append_int(ret,openhd::WB_MCS_INDEX_VIA_RC_CHANNEL,
ImprovedIntSetting::createEnum({"Disable","Channel 1","CHannel 2","Channel 3","Channel 4","Channel 5",
"Channel 6","Channel 7","Channel 8","Channel 9","Channel 10"}),
"Dynamically change the MCS Index (Trade range <-> image quality (bitrate)) during flight using your RC and a specific channel "
"(similar to how flight modes work)."
);
{
std::vector<std::string> disable_or_channels{"Disable","Channel 1","CHannel 2","Channel 3","Channel 4","Channel 5",
"Channel 6","Channel 7","Channel 8","Channel 9","Channel 10"};
append_int(ret,openhd::WB_MCS_INDEX_VIA_RC_CHANNEL,
ImprovedIntSetting::createEnum(disable_or_channels),
"Dynamically change the MCS Index (Trade range <-> image quality (bitrate)) during flight using your RC and a specific channel "
"(similar to how flight modes work)."
);
append_int(ret,openhd::WB_BW_VIA_RC_CHANNEL,
ImprovedIntSetting::createEnum(disable_or_channels),
"Dynamically change the BW via RC. NOT ALWAYS SAFE TO USE !"
);

}

append_only_documented(ret,openhd::WB_FREQUENCY,"!!!Editing this param manually without care will result in a broken link!!!");
{
auto default_values=std::vector<ImprovedIntSetting::Item>{
Expand Down
1 change: 1 addition & 0 deletions app/telemetry/settings/param_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static constexpr auto WB_ENABLE_STBC="WB_E_STBC";
static constexpr auto WB_ENABLE_LDPC="WB_E_LDPC";
static constexpr auto WB_ENABLE_SHORT_GUARD="WB_E_SHORT_GUARD";
static constexpr auto WB_MCS_INDEX_VIA_RC_CHANNEL="MCS_VIA_RC";
static constexpr auto WB_BW_VIA_RC_CHANNEL = "BW_VIA_RC";
static constexpr auto WB_PASSIVE_MODE ="WB_PASSIVE_MODE";
static constexpr auto WB_DEV_AIR_SET_HIGH_RETRANSMIT_COUNT="DEV_HIGH_RETR";

Expand Down
32 changes: 13 additions & 19 deletions qml/ui/configpopup/openhd_settings/LinkQuickPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Rectangle{
Layout.alignment: Qt.AlignRight
visible:false
onClicked: {
var text="Please select a channel / frequency free of noise and interference. The current loss / pollution / throttle stats below can help,"+
var text="Please select a channel / frequency free of noise and interference. The current loss / pollution stats below can help,"+
"as well as the analyze channels feature or a frequency analyzer on your phone. DEF: Show OpenHD standard channels [1-5] only - they "+
" often are free of wifi pollution and should be used."
_messageBoxInstance.set_text_and_show(text)
Expand Down Expand Up @@ -315,6 +315,18 @@ Rectangle{
font.pixelSize: settings.qopenhd_general_font_pixel_size
}
Text{
width: m_small_width
height: m_small_height
text: {
return "TX ERRORS:\n"+_cameraStreamModelPrimary.total_n_tx_dropped_frames
}
color: _ohdSystemGround.wb_link_curr_foreign_pps > 20 ? "red" : "black"
verticalAlignment: Qt.AlignVCenter
horizontalAlignment: Qt.AlignHCenter
font.bold: false
font.pixelSize: settings.qopenhd_general_font_pixel_size
}
/*Text{
width: m_small_width
height: m_small_height
text: {
Expand All @@ -333,24 +345,6 @@ Rectangle{
horizontalAlignment: Qt.AlignHCenter
font.bold: false
font.pixelSize: settings.qopenhd_general_font_pixel_size
}
/*Item{ // FILLER
Layout.fillWidth: true
}*/
/*ButtonIconInfo{
onClicked: {
var text="High Loss / Pollution / active throttle hint at a polluted channel."
_messageBoxInstance.set_text_and_show(text)
}
}
ButtonIconWarning{
visible: (_ohdSystemGround.curr_rx_packet_loss_perc > 5 || _ohdSystemGround.wb_link_curr_foreign_pps > 20 || _ohdSystemAir.curr_n_rate_adjustments > 0)
onClicked: {
var text="On the bench, if you encounter issues like a high loss , high pollution or throttling, make sure:\n"+
"1) You are using a channel free of noise and interference (OHD channel 1-5 are a good bet)\n"+
"2) (RARELY,RTL8812AU only): Your TX card(s) aren't overamplifying the signal and have adequate cooling.";
_messageBoxInstance.set_text_and_show(text)
}
}*/
}
}
Expand Down
14 changes: 7 additions & 7 deletions qml/ui/widgets/WBLinkRateControlWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ BaseWidget {
property int m_curr_mcs_index: _ohdSystemAir.curr_mcs_index
property int m_curr_bitrate_kbits: _ohdSystemAir.curr_bitrate_kbits

property int m_curr_fine_adjustments: _ohdSystemAir.curr_n_rate_adjustments
//property int m_curr_fine_adjustments: _ohdSystemAir.curr_n_rate_adjustments

property int m_curr_fec_perc: _cameraStreamModelPrimary.curr_fec_percentage
property int m_curr_keyframe_i: _cameraStreamModelPrimary.curr_keyframe_interval
Expand Down Expand Up @@ -111,8 +111,8 @@ BaseWidget {
}
var ret=bitrate_kbits_readable(m_curr_bitrate_kbits);
//if(m_curr_fine_adjustments>0){
var fine_readable="-"+m_curr_fine_adjustments;
ret+=fine_readable;
// var fine_readable="-"+m_curr_fine_adjustments;
// ret+=fine_readable;
//}
ret += (" ["+m_curr_mcs_index+"]");
return ret;
Expand Down Expand Up @@ -276,7 +276,7 @@ Make the video more stable (less microfreezes) on the cost of less image quality
onCheckedChanged: settings.wb_link_rate_control_widget_show_fec_and_keyframe = checked
}
}
Item {
/*Item {
width: parent.width
height: 32
Text {
Expand All @@ -296,7 +296,7 @@ Make the video more stable (less microfreezes) on the cost of less image quality
checked: settings.wb_link_rate_control_widget_show_throttle_warning
onCheckedChanged: settings.wb_link_rate_control_widget_show_throttle_warning = checked
}
}
}*/


Item {
Expand Down Expand Up @@ -480,7 +480,7 @@ Make the video more stable (less microfreezes) on the cost of less image quality
styleColor: settings.color_glow
visible: settings.wb_link_rate_control_widget_show_fec_and_keyframe
}
Text{
/*Text{
width: parent.width
height: 14
color: settings.color_warn
Expand All @@ -497,7 +497,7 @@ Make the video more stable (less microfreezes) on the cost of less image quality
}
return "";
}
}
}*/

}
}
Expand Down
5 changes: 3 additions & 2 deletions qml/ui/widgets/map/MapWidgetForm.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,12 @@ BaseWidget {
anchors.left: parent.left
verticalAlignment: Text.AlignVCenter
}
// Consti10: I think this is in metres
NewSlider {
orientation: Qt.Horizontal
from: 5000
from: (5*1000)
value: settings.adsb_radius
to: 50000
to: (100*1000)
stepSize: 1000
height: parent.height
anchors.rightMargin: 0
Expand Down

0 comments on commit 824aa60

Please sign in to comment.