fix setting hostname and clean sessions
This commit is contained in:
4
Config.h
4
Config.h
@@ -2,5 +2,5 @@
|
||||
|
||||
#define NUKI_HUB_VERSION "7.3"
|
||||
|
||||
#define MQTT_QOS_LEVEL 0
|
||||
#define MQTT_CLEAN_SESSIONS true
|
||||
#define MQTT_QOS_LEVEL 1
|
||||
#define MQTT_CLEAN_SESSIONS false
|
||||
@@ -83,6 +83,8 @@ void Network::initialize()
|
||||
_restartOnDisconnect = _preferences->getBool(preference_restart_on_disconnect);
|
||||
_rssiPublishInterval = _preferences->getInt(preference_rssi_publish_interval);
|
||||
|
||||
_hostname = _preferences->getString(preference_hostname);
|
||||
|
||||
if(_hostname == "")
|
||||
{
|
||||
_hostname = "nukihub";
|
||||
@@ -93,6 +95,7 @@ void Network::initialize()
|
||||
_rssiPublishInterval = -1;
|
||||
_preferences->putInt(preference_rssi_publish_interval, _rssiPublishInterval);
|
||||
}
|
||||
strcpy(_hostnameArr, _hostname.c_str());
|
||||
_device->initialize();
|
||||
|
||||
Log->print(F("Host name: "));
|
||||
@@ -133,8 +136,8 @@ void Network::initialize()
|
||||
Log->print(F(":"));
|
||||
Log->println(port);
|
||||
|
||||
// TODO
|
||||
// _device->mqttClient()->setId(_preferences->getString(preference_hostname));
|
||||
_device->mqttClient()->setClientId(_hostnameArr);
|
||||
_device->mqttClient()->setCleanSession(MQTT_CLEAN_SESSIONS);
|
||||
|
||||
_networkTimeout = _preferences->getInt(preference_network_timeout);
|
||||
if(_networkTimeout == 0)
|
||||
|
||||
@@ -59,6 +59,7 @@ private:
|
||||
static Network* _inst;
|
||||
Preferences* _preferences;
|
||||
String _hostname;
|
||||
char _hostnameArr[101] = {0};
|
||||
NetworkDevice* _device = nullptr;
|
||||
int _mqttConnectionState = 0;
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@ void NetworkOpener::onMqttDataReceived(const char* topic, byte* payload, const u
|
||||
|
||||
if(processActions && comparePrefixedPath(topic, mqtt_topic_lock_action))
|
||||
{
|
||||
Serial.println(value);
|
||||
if(strcmp((char*)payload, "") == 0 || strcmp(value, "--") == 0 || strcmp(value, "ack") == 0 || strcmp(value, "unknown_action") == 0) return;
|
||||
|
||||
Log->print(F("Opener lock action received: "));
|
||||
|
||||
Reference in New Issue
Block a user