/* * This program source code file is part of SystemK, a library in the KTag project. * * 🛡️ 🃞 * * Copyright © 2025 Joseph P. Kearney and the KTag developers. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * There should be a copy of the GNU Affero General Public License in the LICENSE * file in the root of this repository. If not, see . */ #include #include #include //! Converts a 6-byte Bluetooth Low Energy address to a human-readable string (for logging). /*! * \param bd_addr The Bluetooth address as a 6-byte array * \return Pointer to a static string containing the formatted address * * Output format: "XX:XX:XX:XX:XX:XX" where XX are uppercase hexadecimal values * \note This function is not reentrant as it uses a static buffer! */ const char *BLE_ADDR_To_Str(const uint8_t bd_addr[6]) { static char str_addr[18]; // 17 characters + null terminator // Convert each byte and add separating colons. for (int i = 0; i < 6; i++) { snprintf(&str_addr[i * 3], sizeof(str_addr) - (i * 3), "%02X", bd_addr[5-i]); // Add colon separator except after the last byte. if (i < 5) { str_addr[(i * 3) + 2] = ':'; } } str_addr[17] = '\0'; // Ensure null termination. return str_addr; }