Refactor official Nuki MQTT support. Move offical-specific code into sepereate class. (#470)
* move offical related members to seperate class * remove static references * add buildMqttPath and comparePrefixedPath methods to NukiOfficial * make offMqttPath private * fix references and syntax errors * move nuki official publish state update check to NukiNetworkLock * make _disableNonJSON private * make NukiOfficial members private * move _offCommand to NukiWrapper * make offCommandExecutedTs private * make offTopics privte * fix nuki publisher reference not set * use NukiPublisher in NukiNetworkOpener * fix build updater * fix pl_off and stat_off strings
This commit is contained in:
59
src/NukiPublisher.cpp
Normal file
59
src/NukiPublisher.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include "NukiPublisher.h"
|
||||
|
||||
|
||||
NukiPublisher::NukiPublisher(NukiNetwork *network, const char* mqttPath)
|
||||
: _network(network),
|
||||
_mqttPath(mqttPath)
|
||||
{
|
||||
}
|
||||
|
||||
void NukiPublisher::publishFloat(const char *topic, const float value, bool retain, const uint8_t precision)
|
||||
{
|
||||
_network->publishFloat(_mqttPath, topic, value, retain, precision);
|
||||
}
|
||||
|
||||
void NukiPublisher::publishInt(const char *topic, const int value, bool retain)
|
||||
{
|
||||
_network->publishInt(_mqttPath, topic, value, retain);
|
||||
}
|
||||
|
||||
void NukiPublisher::publishUInt(const char *topic, const unsigned int value, bool retain)
|
||||
{
|
||||
_network->publishUInt(_mqttPath, topic, value, retain);
|
||||
}
|
||||
|
||||
void NukiPublisher::publishBool(const char *topic, const bool value, bool retain)
|
||||
{
|
||||
_network->publishBool(_mqttPath, topic, value, retain);
|
||||
}
|
||||
|
||||
bool NukiPublisher::publishString(const char *topic, const String &value, bool retain)
|
||||
{
|
||||
char str[value.length() + 1];
|
||||
memset(str, 0, sizeof(str));
|
||||
memcpy(str, value.begin(), value.length());
|
||||
return publishString(topic, str, retain);
|
||||
}
|
||||
|
||||
bool NukiPublisher::publishString(const char *topic, const std::string &value, bool retain)
|
||||
{
|
||||
char str[value.size() + 1];
|
||||
memset(str, 0, sizeof(str));
|
||||
memcpy(str, value.data(), value.length());
|
||||
return publishString(topic, str, retain);
|
||||
}
|
||||
|
||||
bool NukiPublisher::publishString(const char *topic, const char *value, bool retain)
|
||||
{
|
||||
return _network->publishString(_mqttPath, topic, value, retain);
|
||||
}
|
||||
|
||||
void NukiPublisher::publishULong(const char *topic, const unsigned long value, bool retain)
|
||||
{
|
||||
return _network->publishULong(_mqttPath, topic, value, retain);
|
||||
}
|
||||
|
||||
void NukiPublisher::publishLongLong(const char *topic, int64_t value, bool retain)
|
||||
{
|
||||
return _network->publishLongLong(_mqttPath, topic, value, retain);
|
||||
}
|
||||
Reference in New Issue
Block a user