Skip to content

Commit

Permalink
Merge branch 'hotfix/2.0.2-hotfix1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Treffenstädt committed Dec 20, 2021
2 parents 6155337 + eeb3558 commit 57fcf3e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ endif()
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
add_compile_options(
-mthumb
-mthumb-interwork
-march=armv7-a
)
endif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
Expand All @@ -72,7 +71,7 @@ endif ()
set(CPACK_RESOURCE_FILE_LICENSE "${MUONDETECTOR_CONFIG_DIR}/license")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/packages")
set(CPACK_PACKAGE_VENDOR "MuonPi.org")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-hotfix1")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
Expand Down
1 change: 1 addition & 0 deletions daemon/src/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ Daemon::Daemon(configuration cfg, QObject* parent)
mqttHandler = new MuonPi::MqttHandler(cfg.station_ID, verbose - 1);
mqttHandler->moveToThread(mqttHandlerThread);
connect(mqttHandler, &MuonPi::MqttHandler::mqttConnectionStatus, this, &Daemon::sendMqttStatus);
connect(mqttHandler, &MuonPi::MqttHandler::giving_up, this, &Daemon::handleSigTerm);
connect(fileHandlerThread, &QThread::finished, mqttHandler, &MuonPi::MqttHandler::deleteLater);
connect(this, &Daemon::requestMqttConnectionStatus, mqttHandler, &MuonPi::MqttHandler::onRequestConnectionStatus);
mqttHandlerThread->start();
Expand Down
2 changes: 1 addition & 1 deletion library/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ constexpr int event_count_max_pileups { 50 };
namespace MQTT {
constexpr const char* host { "data.muonpi.org" };
constexpr int port { 1883 };
constexpr int timeout { 2000 };
constexpr int timeout { 10000 };
constexpr int qos { 1 };
constexpr int keepalive_interval { 45 };
constexpr const char* data_topic { "muonpi/data/" };
Expand Down
2 changes: 2 additions & 0 deletions library/include/mqtthandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class MUONDETECTORSHARED MqttHandler : public QObject
void request_timer_start(int);
void request_timer_restart(int);

void giving_up();


public slots:
void start(const QString& username, const QString& password);
Expand Down
15 changes: 9 additions & 6 deletions library/src/mqtthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ void MqttHandler::callback_disconnected(int result)
if (result != 0) {
qWarning() << "Mqtt disconnected unexpectedly: " + QString::number(result);
set_status(Status::Error);
m_tries = 1;
emit request_timer_start(Config::MQTT::timeout * m_tries);
} else {
set_status(Status::Disconnected);
Expand All @@ -76,6 +75,14 @@ void MqttHandler::callback_message(const mosquitto_message* message)

void MqttHandler::set_status(Status status)
{
if (status == Status::Error) {
m_tries++;
qWarning() << "Tried: "<<m_tries;
if (m_tries > s_max_tries) {
exit(0);
emit giving_up();
}
}
if (m_status != status) {
if (status == Status::Connected) {
emit mqttConnectionStatus(true);
Expand All @@ -91,13 +98,10 @@ MqttHandler::MqttHandler(const QString& station_id, const int verbosity)
, m_verbose { verbosity }
{
m_reconnect_timer.setInterval(Config::MQTT::timeout);
m_reconnect_timer.setSingleShot(true);
connect(&m_reconnect_timer, &QTimer::timeout, this, [this](){mqttConnect();});
connect(this, &MqttHandler::request_timer_stop, &m_reconnect_timer, &QTimer::stop);
connect(this, &MqttHandler::request_timer_restart, this, &MqttHandler::timer_restart);
connect(this, &MqttHandler::request_timer_start, this, &MqttHandler::timer_start);
}


MqttHandler::~MqttHandler()
{
mqttDisconnect();
Expand Down Expand Up @@ -135,7 +139,6 @@ void MqttHandler::start(const QString& username, const QString& password){

void MqttHandler::mqttConnect(){
if (connected()) {
qDebug() << "Already connected to Mqtt.";
return;
}
qDebug() << "Trying to connect to MQTT.";
Expand Down

0 comments on commit 57fcf3e

Please sign in to comment.