Build message in printBytes, to not spam BLE log (#4843)

This commit is contained in:
Jonathan Bennett 2024-09-23 23:41:28 -05:00 committed by GitHub
parent 428a567078
commit c39d270f40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,10 +60,17 @@ char *strnstr(const char *s, const char *find, size_t slen)
void printBytes(const char *label, const uint8_t *p, size_t numbytes)
{
LOG_DEBUG("%s: ", label);
char *messageBuffer;
int labelSize = strlen(label);
if (labelSize < 100 && numbytes < 64) {
messageBuffer = new char[labelSize + (numbytes * 3) + 2];
strncpy(messageBuffer, label, labelSize);
for (size_t i = 0; i < numbytes; i++)
LOG_DEBUG("%02x ", p[i]);
LOG_DEBUG("\n");
snprintf(messageBuffer + labelSize + i * 3, 4, " %02x", p[i]);
strcpy(messageBuffer + labelSize + numbytes * 3, "\n");
LOG_DEBUG(messageBuffer);
delete messageBuffer;
}
}
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes)