static void test_fmt_bytes_hex(void) { char out[15] = "--------------"; uint8_t val[7] = { 0xAA, 9, 8, 7, 6, 0xA8, 0xEF}; uint8_t bytes = 0; bytes = fmt_bytes_hex(out, val, 0); out[bytes] = '\0'; TEST_ASSERT_EQUAL_INT(0, bytes); TEST_ASSERT_EQUAL_STRING("", (char *) out); bytes = fmt_bytes_hex(out, val, 1); out[bytes] = '\0'; TEST_ASSERT_EQUAL_INT(2, bytes); TEST_ASSERT_EQUAL_STRING("AA", (char *) out); bytes = fmt_bytes_hex(out, val, 2); out[bytes] = '\0'; TEST_ASSERT_EQUAL_INT(4, bytes); TEST_ASSERT_EQUAL_STRING("AA09", (char *) out); bytes = fmt_bytes_hex(out, val, 3); out[bytes] = '\0'; TEST_ASSERT_EQUAL_INT(6, bytes); TEST_ASSERT_EQUAL_STRING("AA0908", (char *) out); bytes = fmt_bytes_hex(out, val, 4); out[bytes] = '\0'; TEST_ASSERT_EQUAL_INT(8, bytes); TEST_ASSERT_EQUAL_STRING("AA090807", (char *) out); bytes = fmt_bytes_hex(out, val, 5); out[bytes] = '\0'; TEST_ASSERT_EQUAL_INT(10, bytes); TEST_ASSERT_EQUAL_STRING("AA09080706", (char *) out); bytes = fmt_bytes_hex(out, val, 6); out[bytes] = '\0'; TEST_ASSERT_EQUAL_INT(12, bytes); TEST_ASSERT_EQUAL_STRING("AA09080706A8", (char *) out); bytes = fmt_bytes_hex(out, val, 7); out[bytes] = '\0'; TEST_ASSERT_EQUAL_INT(14, bytes); TEST_ASSERT_EQUAL_STRING("AA09080706A8EF", (char *) out); }
void cord_common_init(void) { #ifdef CORD_EP memcpy(cord_common_ep, CORD_EP, BUFSIZE); #else uint8_t luid[CORD_EP_SUFFIX_LEN / 2]; if (PREFIX_LEN > 1) { memcpy(cord_common_ep, CORD_EP_PREFIX, (PREFIX_LEN - 1)); } luid_get(luid, sizeof(luid)); fmt_bytes_hex(&cord_common_ep[PREFIX_LEN - 1], luid, sizeof(luid)); cord_common_ep[BUFSIZE - 1] = '\0'; #endif }