Skip to content

Commit

Permalink
Build message in printBytes, to not spam BLE log (#4843)
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-bennett authored Sep 24, 2024
1 parent 428a567 commit c39d270
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/meshUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
for (size_t i = 0; i < numbytes; i++)
LOG_DEBUG("%02x ", p[i]);
LOG_DEBUG("\n");
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++)
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)
Expand Down

0 comments on commit c39d270

Please sign in to comment.