Skip to content

Commit 33e38b1

Browse files
Neil HorneThomasKuehne
Neil Horne
authored andcommitted
fix(cpn): multi protocol and sd card updates (EdgeTX#4774)
1 parent c1c5d7a commit 33e38b1

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

companion/src/updates/repo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Repo::~Repo()
4141

4242
bool Repo::getJson(const QString filename, QJsonDocument * json)
4343
{
44-
m_network->downloadJson(m_releases->urlContent(filename), json);
44+
m_network->downloadJsonContent(m_releases->urlContent(filename), json);
4545

4646
if (!m_network->isSuccess()) {
4747
m_status->reportProgress("Unable to download json data", QtDebugMsg);

companion/src/updates/repoassets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void RepoAssets::dumpItemModel(const QString modelName, const QAbstractItemModel
153153

154154
bool RepoAssets::getJson(QJsonDocument * json)
155155
{
156-
network()->downloadJson(urlAsset(id()), json);
156+
network()->downloadJsonAsset(urlAsset(id()), json);
157157

158158
if (!network()->isSuccess()) {
159159
status()->reportProgress("Unable to download json data", QtDebugMsg);

companion/src/updates/updatemultiprotocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ UpdateMultiProtocol::UpdateMultiProtocol(QWidget * parent) :
2525
UpdateInterface(parent, CID_MultiProtocol, tr("Multiprotocol"))
2626
{
2727
// GitHub REST API default ResultsPerPage = 30
28-
init(QString(GH_API_REPOS).append("/pascallanger/DIY-Multiprotocol-TX-Module"), "", 50);
28+
init(QString(GH_API_REPOS).append("/pascallanger/DIY-Multiprotocol-TX-Module"), "", 100);
2929
}
3030

3131
void UpdateMultiProtocol::assetSettingsInit()

companion/src/updates/updatenetwork.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
#include <QtNetwork/QNetworkProxyFactory>
2727

2828
constexpr char GH_API_VERSION[] {"2022-11-28"};
29-
constexpr char GH_ACCEPT_HEADER_CONTENT[] {"application/octet-stream"};
29+
constexpr char GH_ACCEPT_HEADER_CONTENT[] {"application/octet-stream"};
3030
constexpr char GH_ACCEPT_HEADER_METADATA[] {"application/vnd.github+json"};
31-
// constexpr char GH_ACCEPT_HEADER_RAW[] {"application/vnd.github.raw"};
31+
constexpr char GH_ACCEPT_HEADER_RAW[] {"application/vnd.github.raw+json"};
3232

3333
UpdateNetwork::UpdateNetwork(QObject * parent, UpdateStatus * status) :
3434
QObject(parent),
@@ -59,6 +59,8 @@ QString UpdateNetwork::downloadDataTypeToString(const DownloadDataType val)
5959
return "Content";
6060
case DDT_MetaData:
6161
return "Meta Data";
62+
case DDT_Raw:
63+
return "Raw";
6264
default:
6365
return CPN_STR_UNKNOWN_ITEM;
6466
}
@@ -78,10 +80,28 @@ void UpdateNetwork::downloadJson(const QString & url, QJsonDocument * json)
7880
convertBufferToJson(json);
7981
}
8082

83+
void UpdateNetwork::downloadJsonAsset(const QString & url, QJsonDocument * json)
84+
{
85+
downloadToBuffer(DDT_Content, url);
86+
if (m_success)
87+
convertBufferToJson(json);
88+
}
89+
90+
void UpdateNetwork::downloadJsonContent(const QString & url, QJsonDocument * json)
91+
{
92+
downloadToBuffer(DDT_Raw, url);
93+
if (m_success)
94+
convertBufferToJson(json);
95+
}
96+
8197
void UpdateNetwork::downloadToBuffer(const DownloadDataType type, const QString & url)
8298
{
8399
m_success = false;
84-
download(type, url, type == DDT_MetaData ? GH_ACCEPT_HEADER_METADATA : GH_ACCEPT_HEADER_CONTENT, QString());
100+
download(type,
101+
url,
102+
type == DDT_MetaData ? GH_ACCEPT_HEADER_METADATA :
103+
type == DDT_Raw ? GH_ACCEPT_HEADER_RAW : GH_ACCEPT_HEADER_CONTENT,
104+
QString());
85105
}
86106

87107
void UpdateNetwork::downloadToFile(const QString & url, const QString & filePath)

companion/src/updates/updatenetwork.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class UpdateNetwork : public QObject
3939
DDT_Content,
4040
DDT_SaveToFile,
4141
DDT_MetaData,
42+
DDT_Raw,
4243
};
4344
Q_ENUM(DownloadDataType)
4445

@@ -48,6 +49,8 @@ class UpdateNetwork : public QObject
4849
void convertBufferToJson(QJsonDocument * json);
4950
void downloadMetaData(const QString & url, QJsonDocument * json);
5051
void downloadJson(const QString & url, QJsonDocument * json);
52+
void downloadJsonAsset(const QString & url, QJsonDocument * json);
53+
void downloadJsonContent(const QString & url, QJsonDocument * json);
5154
void downloadToFile(const QString & url, const QString & filePath);
5255
void downloadToBuffer(const DownloadDataType type, const QString & url);
5356
void download(const DownloadDataType type, const QString & urlStr, const char * header, const QString & filePath);

0 commit comments

Comments
 (0)