move code to build mqtt path into publish()
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
#define NUKI_HUB_VERSION "9.03"
|
||||
#define NUKI_HUB_BUILD "unknownbuildnr"
|
||||
#define NUKI_HUB_DATE "2024-11-29"
|
||||
#define NUKI_HUB_DATE "2024-11-30"
|
||||
|
||||
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
|
||||
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"
|
||||
|
||||
@@ -1100,66 +1100,59 @@ void NukiNetwork::publishFloat(const char* prefix, const char* topic, const floa
|
||||
{
|
||||
char str[30];
|
||||
dtostrf(value, 0, precision, str);
|
||||
char path[200] = {0};
|
||||
buildMqttPath(path, { prefix, topic });
|
||||
publish(path, str, retain);
|
||||
publish(prefix, topic, str, retain);
|
||||
}
|
||||
|
||||
void NukiNetwork::publishInt(const char* prefix, const char *topic, const int value, bool retain)
|
||||
{
|
||||
char str[30];
|
||||
itoa(value, str, 10);
|
||||
char path[200] = {0};
|
||||
buildMqttPath(path, { prefix, topic });
|
||||
publish(path, str, retain);
|
||||
publish(prefix, topic, str, retain);
|
||||
}
|
||||
|
||||
void NukiNetwork::publishUInt(const char* prefix, const char *topic, const unsigned int value, bool retain)
|
||||
{
|
||||
char str[30];
|
||||
utoa(value, str, 10);
|
||||
char path[200] = {0};
|
||||
buildMqttPath(path, { prefix, topic });
|
||||
publish(path, str, retain);
|
||||
publish(prefix, topic, str, retain);
|
||||
}
|
||||
|
||||
void NukiNetwork::publishULong(const char* prefix, const char *topic, const unsigned long value, bool retain)
|
||||
{
|
||||
char str[30];
|
||||
ultoa(value, str, 10);
|
||||
char path[200] = {0};
|
||||
buildMqttPath(path, { prefix, topic });
|
||||
publish(path, str, retain);
|
||||
publish(prefix, topic, str, retain);
|
||||
}
|
||||
|
||||
void NukiNetwork::publishLongLong(const char* prefix, const char *topic, int64_t value, bool retain)
|
||||
{
|
||||
char str[30];
|
||||
lltoa(value, str, 10);
|
||||
char path[200] = {0};
|
||||
buildMqttPath(path, { prefix, topic });
|
||||
publish(path, str, retain);
|
||||
publish(prefix, topic, str, retain);
|
||||
}
|
||||
|
||||
void NukiNetwork::publishBool(const char* prefix, const char *topic, const bool value, bool retain)
|
||||
{
|
||||
char str[2] = {0};
|
||||
str[0] = value ? '1' : '0';
|
||||
char path[200] = {0};
|
||||
buildMqttPath(path, { prefix, topic });
|
||||
publish(path, str, retain);
|
||||
publish(prefix, topic, str, retain);
|
||||
}
|
||||
|
||||
void NukiNetwork::publishString(const char* prefix, const char *topic, const char *value, bool retain)
|
||||
{
|
||||
char path[200] = {0};
|
||||
buildMqttPath(path, { prefix, topic });
|
||||
publish(path, value, retain);
|
||||
publish(prefix, topic, value, retain);
|
||||
}
|
||||
|
||||
void NukiNetwork::publish(const char *topic, const char *value, bool retain)
|
||||
void NukiNetwork::publish(const char* prefix, const char *topic, const char *value, bool retain)
|
||||
{
|
||||
_device->mqttPublish(topic, MQTT_QOS_LEVEL, retain, value);
|
||||
char path[200] = {0};
|
||||
buildMqttPath(path, { prefix, topic });
|
||||
_device->mqttPublish(path, MQTT_QOS_LEVEL, retain, value);
|
||||
}
|
||||
|
||||
void NukiNetwork::publish(const char* path, const char *value, bool retain)
|
||||
{
|
||||
_device->mqttPublish(path, MQTT_QOS_LEVEL, retain, value);
|
||||
}
|
||||
|
||||
void NukiNetwork::removeTopic(const String& mqttPath, const String& mqttTopic)
|
||||
|
||||
@@ -57,7 +57,8 @@ public:
|
||||
void publishLongLong(const char* prefix, const char* topic, int64_t value, bool retain);
|
||||
void publishBool(const char* prefix, const char* topic, const bool value, bool retain);
|
||||
void publishString(const char* prefix, const char* topic, const char* value, bool retain);
|
||||
void publish(const char *topic, const char *value, bool retain);
|
||||
void publish(const char* prefix, const char *topic, const char *value, bool retain);
|
||||
void publish(const char* path, const char *value, bool retain);
|
||||
void removeTopic(const String& mqttPath, const String& mqttTopic);
|
||||
void batteryTypeToString(const Nuki::BatteryType battype, char* str);
|
||||
void advertisingModeToString(const Nuki::AdvertisingMode advmode, char* str);
|
||||
|
||||
Reference in New Issue
Block a user