diff --git a/README.md b/README.md index 186aaca..5769075 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,8 @@ Die SD Karte (Ordner mp3 und advert) hat sich gegenüber der Version 3.1.11 geä # Change Log -## Version 3.2.0 (28.08.2024) +## Version 3.2.0 (05.09.2024) +- [Issue 231](https://github.com/tonuino/TonUINO-TNG/issues/231): Fix logging of card data (bad order) - [Issue 229](https://github.com/tonuino/TonUINO-TNG/issues/229): playAdvertisement does not work for some DF Player - [Issue 228](https://github.com/tonuino/TonUINO-TNG/issues/228): NeoPixel for two Rings with Sleep modification card: no update on one ring - [Issue 226](https://github.com/tonuino/TonUINO-TNG/issues/226): Use MegaCoreX as Board package for Nano Every instead of Arduino megaAVR Boards diff --git a/TonUINO-TNG.ino b/TonUINO-TNG.ino index a42496a..747a555 100644 --- a/TonUINO-TNG.ino +++ b/TonUINO-TNG.ino @@ -35,7 +35,7 @@ void setup() LOG(init_log, s_error, F("TonUINO Version 3.1 - refactored by Boerge1\n")); LOG(init_log, s_error, F("created by Thorsten Voß and licensed under GNU/GPL.")); LOG(init_log, s_error, F("Information and contribution at https://tonuino.de.\n")); - LOG(init_log, s_error, F("V3.2.0 28.08.24\n")); + LOG(init_log, s_error, F("V3.2.0 05.09.24\n")); #ifdef TonUINO_Classic LOG(init_log, s_error, F("C "), lf_no); diff --git a/src/chip_card.cpp b/src/chip_card.cpp index e6cc2f0..b7a486a 100644 --- a/src/chip_card.cpp +++ b/src/chip_card.cpp @@ -24,26 +24,25 @@ const __FlashStringHelper *str_MIFARE_Write() { return F("MIFARE_Write "); } /** Helper routine to dump a byte array as hex values to Serial. */ +constexpr size_t maxBuffferLogSize = 10; +char n16_hex(uint8_t number) { + if (number >=16) + return '?'; + return (number > 9) ? (number - 10) + 'a' : number + '0'; +} void u8toa_hex(uint8_t number, char *arr) { - int pos = 0; - if (number < 16) - arr[pos++] = '0'; - do { - const int r = number % 16; - arr[pos++] = (r > 9) ? (r - 10) + 'a' : r + '0'; - number /= 16; - } while (number != 0); + arr[0] = n16_hex(number/16); + arr[1] = n16_hex(number%16); } const char* dump_byte_array(byte * buffer, uint8_t bufferSize) { - static char ret[3*10+1]; - ret[0] = '\0'; - if (bufferSize > 10) - return ret; + static char ret[3*maxBuffferLogSize+1]; + if (bufferSize > maxBuffferLogSize) + bufferSize = maxBuffferLogSize; uint8_t pos = 0; for (uint8_t i = 0; i < bufferSize; ++i) { - ret[pos++] = ' '; u8toa_hex(buffer[i], &ret[pos]); pos +=2; + ret[pos++] = ' '; } ret[pos] = '\0'; return ret;