Skip to content

Commit

Permalink
fix string conversion functions
Browse files Browse the repository at this point in the history
  • Loading branch information
technyon committed Nov 29, 2024
1 parent 660e756 commit f0623c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#define NUKI_HUB_VERSION "9.03"
#define NUKI_HUB_BUILD "unknownbuildnr"
#define NUKI_HUB_DATE "2024-11-28"
#define NUKI_HUB_DATE "2024-11-29"

#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"
Expand Down
20 changes: 4 additions & 16 deletions src/NukiNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,31 +1126,19 @@ void NukiNetwork::publishUInt(const char* prefix, const char *topic, const unsig
void NukiNetwork::publishULong(const char* prefix, const char *topic, const unsigned long value, bool retain)
{
char str[30];
utoa(value, str, 10);
ultoa(value, str, 10);
char path[200] = {0};
buildMqttPath(path, { prefix, topic });
publish(path, str, retain);
}

void NukiNetwork::publishLongLong(const char* prefix, const char *topic, int64_t value, bool retain)
{
static char result[21] = "";
memset(&result[0], 0, sizeof(result));
char temp[21] = "";
char c;
uint8_t base = 10;

while (value)
{
int num = value % base;
value /= base;
c = '0' + num;
sprintf(temp, "%c%s", c, result);
strcpy(result, temp);
}
char str[30];
lltoa(value, str, 10);
char path[200] = {0};
buildMqttPath(path, { prefix, topic });
publish(path, result, retain);
publish(path, str, retain);
}

void NukiNetwork::publishBool(const char* prefix, const char *topic, const bool value, bool retain)
Expand Down

0 comments on commit f0623c8

Please sign in to comment.