better fix for presence detection
This commit is contained in:
18
Network.cpp
18
Network.cpp
@@ -205,7 +205,12 @@ void Network::update()
|
||||
|
||||
if(_presenceCsv != nullptr && strlen(_presenceCsv) > 0)
|
||||
{
|
||||
publishString_P(mqtt_topic_presence, _presenceCsv);
|
||||
bool success = publishString(mqtt_topic_presence, _presenceCsv);
|
||||
if(!success)
|
||||
{
|
||||
Serial.println(F("Failed to publish presence CSV data."));
|
||||
Serial.println(_presenceCsv);
|
||||
}
|
||||
_presenceCsv = nullptr;
|
||||
}
|
||||
|
||||
@@ -387,18 +392,11 @@ void Network::publishBool(const char *topic, const bool value)
|
||||
_device->mqttClient()->publish(path, str);
|
||||
}
|
||||
|
||||
void Network::publishString(const char *topic, const char *value)
|
||||
bool Network::publishString(const char *topic, const char *value)
|
||||
{
|
||||
char path[200] = {0};
|
||||
buildMqttPath(topic, path);
|
||||
_device->mqttClient()->publish(path, value);
|
||||
}
|
||||
|
||||
void Network::publishString_P(const char *topic, const char *value)
|
||||
{
|
||||
char path[200] = {0};
|
||||
buildMqttPath(topic, path);
|
||||
_device->mqttClient()->publish_P(path, value, true);
|
||||
return _device->mqttClient()->publish(path, value);
|
||||
}
|
||||
|
||||
bool Network::isMqttConnected()
|
||||
|
||||
@@ -54,8 +54,7 @@ private:
|
||||
void publishInt(const char* topic, const int value);
|
||||
void publishUInt(const char* topic, const unsigned int value);
|
||||
void publishBool(const char* topic, const bool value);
|
||||
void publishString(const char* topic, const char* value);
|
||||
void publishString_P(const char* topic, const char* value);
|
||||
bool publishString(const char* topic, const char* value);
|
||||
|
||||
void buildMqttPath(const char* path, char* outPath);
|
||||
void subscribe(const char* path);
|
||||
|
||||
2
main.cpp
2
main.cpp
@@ -87,7 +87,7 @@ void setupTasks()
|
||||
{
|
||||
// configMAX_PRIORITIES is 25
|
||||
|
||||
xTaskCreate(networkTask, "ntw", 32768, NULL, 3, NULL);
|
||||
xTaskCreate(networkTask, "ntw", 65536, NULL, 3, NULL);
|
||||
xTaskCreate(nukiTask, "nuki", 8192, NULL, 2, NULL);
|
||||
xTaskCreate(presenceDetectionTask, "prdet", 1024, NULL, 5, NULL);
|
||||
xTaskCreate(checkMillisTask, "mlchk", 512, NULL, 1, NULL);
|
||||
|
||||
@@ -20,5 +20,6 @@ public:
|
||||
virtual bool isConnected() = 0;
|
||||
|
||||
protected:
|
||||
const uint16_t _mqttMaxBufferSize = 16384;
|
||||
const String _hostname;
|
||||
};
|
||||
@@ -38,6 +38,7 @@ void W5500Device::initialize()
|
||||
Ethernet.init(ETHERNET_CS_PIN);
|
||||
_ethClient = new EthernetClient();
|
||||
_mqttClient = new PubSubClient(*_ethClient);
|
||||
_mqttClient->setBufferSize(_mqttMaxBufferSize);
|
||||
|
||||
reconnect();
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ void WifiDevice::initialize()
|
||||
Serial.print(F("WiFi connected: "));
|
||||
Serial.println(WiFi.localIP().toString());
|
||||
}
|
||||
|
||||
_mqttClient.setBufferSize(_mqttMaxBufferSize);
|
||||
}
|
||||
|
||||
void WifiDevice::reconfigure()
|
||||
|
||||
Reference in New Issue
Block a user