Skip to content

Commit

Permalink
Add support for Smartport telemetry
Browse files Browse the repository at this point in the history
Not tested with a real telemetry source yet.

This does not require any setting to change the telemetry protocol
in use, because the ground station uses different ports already, we
just listen on each of them in the different telemetry classes and
everything will just work.

Ref: #17
  • Loading branch information
steveatinfincia committed Apr 2, 2020
1 parent 8764206 commit 918473d
Show file tree
Hide file tree
Showing 5 changed files with 374 additions and 0 deletions.
2 changes: 2 additions & 0 deletions QOpenHD.pro
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ SOURCES += \
src/openhdtelemetry.cpp \
src/powermicroservice.cpp \
src/qopenhdlink.cpp \
src/smartporttelemetry.cpp \
src/util.cpp \
src/vectortelemetry.cpp

Expand All @@ -93,6 +94,7 @@ HEADERS += \
inc/openhdsettings.h \
inc/openhdtelemetry.h \
inc/qopenhdlink.h \
inc/smartporttelemetry.h \
inc/util.h \
inc/vectortelemetry.h \
inc/wifibroadcast.h \
Expand Down
59 changes: 59 additions & 0 deletions inc/smartporttelemetry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef SMARTPORTTELEMETRY_H
#define SMARTPORTTELEMETRY_H

#include <QObject>
#include <QtQuick>

#include "constants.h"


typedef struct {
uint16_t id;
union {
uint32_t u32;
int32_t i32;
uint16_t u16;
int16_t i16;
uint8_t u8;
uint8_t b[4];
int8_t i8;
float f;
} data;
uint8_t crc;
} tSPortData;


class QUdpSocket;

class SmartportTelemetry: public QObject {
Q_OBJECT

public:
explicit SmartportTelemetry(QObject *parent = nullptr);


Q_PROPERTY(QString last_heartbeat MEMBER m_last_heartbeat WRITE set_last_heartbeat NOTIFY last_heartbeat_changed)
void set_last_heartbeat(QString last_heartbeat);

signals:
void last_heartbeat_changed(QString last_heartbeat);


private slots:
void processSmartportDatagrams();

private:
void init();
void smartport_read(uint8_t *buf, int buflen);
uint8_t u8CheckCrcSPORT(uint8_t *t);

void processSmartportMessage(uint8_t *b);

QUdpSocket *smartportSocket = nullptr;

QString m_last_heartbeat = "N/A";
qint64 last_heartbeat_timestamp;

};

#endif //SMARTPORTTELEMETRY_H
4 changes: 4 additions & 0 deletions qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ ApplicationWindow {
// id: mspTelemetry
//}

SmartportTelemetry {
id: smartportTelemetry
}

LTMTelemetry {
id: ltmTelemetry
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const QVector<QString> permissions({"android.permission.INTERNET",
#include "msptelemetry.h"
#include "ltmtelemetry.h"
#include "vectortelemetry.h"
#include "smartporttelemetry.h"

#include "qopenhdlink.h"

Expand Down Expand Up @@ -137,6 +138,7 @@ int main(int argc, char *argv[]) {
qmlRegisterType<MSPTelemetry>("OpenHD", 1, 0, "MSPTelemetry");
qmlRegisterType<LTMTelemetry>("OpenHD", 1, 0, "LTMTelemetry");
qmlRegisterType<VectorTelemetry>("OpenHD", 1, 0, "VectorTelemetry");
qmlRegisterType<SmartportTelemetry>("OpenHD", 1, 0, "SmartportTelemetry");

qmlRegisterType<OpenHDRC>("OpenHD", 1, 0, "OpenHDRC");

Expand Down
Loading

0 comments on commit 918473d

Please sign in to comment.