1#include "main-header.h"
9void bufToHex(
char *target,
const byte *source,
int size) {
13 for (i = 0; i < size; i++) {
14 snprintf(target + (i * 3), 20,
"%x ", source[i]);
17int charToHex(
char c) {
18 if ((c >=
'0') && (c <=
'9')) {
21 if ((c >=
'a') && (c <=
'f')) {
24 if ((c >=
'A') && (c <=
'F')) {
29void ltoh(
const long i,
char *s) {
36 for (x = 7; x >= 0; x--) {
41 s[x] =
'A' + (y - 10);
49int startsWith(
const char *c1,
const char *c2) {
52 if ((c1 == NULL) || (c2 == NULL)) {
55 if (strlen(c1) < strlen(c2)) {
58 for (i = 0; i < strlen(c2); i++) {
67void printHex(
const char *prefix,
const uint8_t *buf,
const int size) {
72 printf(
"******* hexdump (%i bytes) **** \r\n", size);
74 for (i = 0; i < size; i++) {
75 printf(
"%x ", buf[i]);
77 if ((i != (size - 1)) && ((i % MAX_PER_ROW) == (MAX_PER_ROW - 1))) {
79 printf(
"\r\n%s", prefix);
85 printf(
"******* end hexdump\r\n");