Browse Source

Thermostat: add broker infos in settings

master
Richard Genoud 4 years ago
parent
commit
2145002f34
4 changed files with 13 additions and 1 deletions
  1. +4
    -0
      soft/thermostat/Thermostat.conf
  2. +6
    -0
      soft/thermostat/inc/settings.h
  3. +1
    -1
      soft/thermostat/src/mainwindow.cpp
  4. +2
    -0
      soft/thermostat/src/settings.cpp

+ 4
- 0
soft/thermostat/Thermostat.conf View File

@ -1,6 +1,10 @@
# This file should be in:
# $HOME/.config/Sorico/Thermostat.conf
[broker]
address=192.168.1.2
port=1883
[rooms]
1\heaters\1\control_topic=chauffage/chambre_so
1\heaters\size=1


+ 6
- 0
soft/thermostat/inc/settings.h View File

@ -25,6 +25,11 @@ struct Room {
QVector<struct Heater> heaters;
};
struct Brocker {
QString address;
int port;
};
class Settings : public QSettings
{
Q_OBJECT
@ -33,6 +38,7 @@ public:
int nbZones();
QVector<struct Room> m_rooms;
struct Brocker m_broker;
private:
Settings();


+ 1
- 1
soft/thermostat/src/mainwindow.cpp View File

@ -24,7 +24,7 @@ MainWindow::MainWindow(QWidget *parent) :
Settings *s = Settings::getInstance();
mqttclient = new MQTTSubcriber(QHostAddress("192.168.1.2"), 1883);
mqttclient = new MQTTSubcriber(QHostAddress(s->m_broker.address), s->m_broker.port);
for (int i = 0; i < s->nbZones(); i++) {
zone = new ZoneItem(s->m_rooms.at(i).name, this);


+ 2
- 0
soft/thermostat/src/settings.cpp View File

@ -41,6 +41,8 @@ Settings::Settings()
m_rooms << room;
}
s.endArray();
m_broker.address = s.value("broker/address", "localhost").toString();
m_broker.port = s.value("broker/port", 1883).toInt();
}
int Settings::nbZones(void)


Loading…
Cancel
Save