Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bertmelis authored Jan 13, 2025
1 parent 7f9039b commit 4f44e23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Datapoint/ConversionHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ std::size_t decodeSchedule(const uint8_t* data, std::size_t len, char* output, s
hour = 0;
minutes = 0;
}
int result = snprintf(&output[pos], maxLen - pos, "%u.2:%u.2", hour, minutes);
int result = snprintf(&output[pos], maxLen - pos, "%.2u:%.2u", hour, minutes);
if (result < 0) return 0;
pos += result;
if (i < 7) {
output[pos++] = ' ';
}
}
return pos;
return pos + 1; // include 0-terminator
}

} // end namespace VitoWiFi
6 changes: 4 additions & 2 deletions src/Datapoint/ConversionHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ std::size_t encodeSchedule(const char* schedule, uint8_t* output);

/*
Decodes a byte series to a human-readable schedule consisting of time pairs.
Returns the number of characters written including 0-terminator
(will always result in 48 or 0 in case of an error)
Although passed as variables, the function fails when
- len < 8
- maxLen <
- len != 8
- maxLen < 48
*/
std::size_t decodeSchedule(const uint8_t* data, std::size_t len, char* output, std::size_t maxLen);

Expand Down

0 comments on commit 4f44e23

Please sign in to comment.