summaryrefslogtreecommitdiffhomepage
path: root/tracker-udp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-12-03 22:23:08 +0100
committerStanislaw Halik <sthalik@misaki.pl>2017-12-04 12:19:26 +0100
commitb256886a5cb9f2ae3ebda70a2045b19ed9f4233e (patch)
tree4fa1e46de224cf834a05824dc1eb86001bdb3300 /tracker-udp
parente89709a801e7874bc02c66848c638c6a0ccc85c1 (diff)
api: add status check for modules
Diffstat (limited to 'tracker-udp')
-rw-r--r--tracker-udp/ftnoir_tracker_udp.cpp12
-rw-r--r--tracker-udp/ftnoir_tracker_udp.h4
2 files changed, 9 insertions, 7 deletions
diff --git a/tracker-udp/ftnoir_tracker_udp.cpp b/tracker-udp/ftnoir_tracker_udp.cpp
index b3df5e60..41aa96c2 100644
--- a/tracker-udp/ftnoir_tracker_udp.cpp
+++ b/tracker-udp/ftnoir_tracker_udp.cpp
@@ -29,9 +29,6 @@ void udp::run()
QByteArray datagram;
datagram.resize(sizeof(last_recv_pose));
- if (!sock.bind(QHostAddress::Any, quint16(s.port), QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint))
- return;
-
while (!isInterruptionRequested())
{
if (sock.hasPendingDatagrams())
@@ -69,10 +66,15 @@ void udp::run()
}
}
-void udp::start_tracker(QFrame*)
+module_status udp::start_tracker(QFrame*)
{
- start();
+ if (!sock.bind(QHostAddress::Any, quint16(s.port), QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint))
+ return error(tr("Can't bind socket -- %1").arg(sock.errorString()));
+
sock.moveToThread(this);
+ start();
+
+ return status_ok();
}
void udp::data(double *data)
diff --git a/tracker-udp/ftnoir_tracker_udp.h b/tracker-udp/ftnoir_tracker_udp.h
index 0167a005..8e8a385c 100644
--- a/tracker-udp/ftnoir_tracker_udp.h
+++ b/tracker-udp/ftnoir_tracker_udp.h
@@ -19,12 +19,12 @@ struct settings : opts {
{}
};
-class udp : public ITracker, protected QThread
+class udp : protected QThread, public ITracker
{
public:
udp();
~udp() override;
- void start_tracker(QFrame *) override;
+ module_status start_tracker(QFrame *) override;
void data(double *data) override;
protected:
void run() override;