Replaced Logger usage with LOG_x (#548)
This commit is contained in:
committed by
GitHub
parent
ecad2248d9
commit
9d5993930d
@@ -8,18 +8,18 @@
|
||||
#include <Tactility/app/chat/ChatProtocol.h>
|
||||
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/lvgl_icon_shared.h>
|
||||
#include <vector>
|
||||
|
||||
namespace tt::app::chat {
|
||||
|
||||
static const auto LOGGER = Logger("ChatApp");
|
||||
constexpr auto* TAG = "ChatApp";
|
||||
static constexpr uint8_t BROADCAST_ADDRESS[ESP_NOW_ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
|
||||
void ChatApp::enableEspNow() {
|
||||
@@ -98,12 +98,12 @@ void ChatApp::sendMessage(const std::string& text) {
|
||||
|
||||
std::vector<uint8_t> wireMsg;
|
||||
if (!serializeTextMessage(settings.senderId, BROADCAST_ID, nickname, channel, text, wireMsg)) {
|
||||
LOGGER.error("Failed to serialize message");
|
||||
LOG_E(TAG, "Failed to serialize message");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!service::espnow::send(BROADCAST_ADDRESS, wireMsg.data(), wireMsg.size())) {
|
||||
LOGGER.error("Failed to send message");
|
||||
LOG_E(TAG, "Failed to send message");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ void ChatApp::applySettings(const std::string& nickname, const std::string& keyH
|
||||
}
|
||||
settings.hasEncryptionKey = true;
|
||||
} else {
|
||||
LOGGER.warn("Invalid hex characters in encryption key");
|
||||
LOG_W(TAG, "Invalid hex characters in encryption key");
|
||||
}
|
||||
} else if (keyHex.empty()) {
|
||||
if (settings.hasEncryptionKey) {
|
||||
@@ -153,7 +153,7 @@ void ChatApp::applySettings(const std::string& nickname, const std::string& keyH
|
||||
needRestart = true;
|
||||
}
|
||||
} else {
|
||||
LOGGER.warn("Key must be exactly {} hex characters, got {}", ESP_NOW_KEY_LEN * 2, keyHex.size());
|
||||
LOG_W(TAG, "Key must be exactly %d hex characters, got %d", (int)(ESP_NOW_KEY_LEN * 2), (int)keyHex.size());
|
||||
}
|
||||
|
||||
state.setLocalNickname(settings.nickname);
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <Tactility/crypt/Crypt.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/Paths.h>
|
||||
|
||||
#include <esp_random.h>
|
||||
@@ -20,11 +19,12 @@
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <tactility/log.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace tt::app::chat {
|
||||
|
||||
static const auto LOGGER = Logger("ChatSettings");
|
||||
constexpr auto* TAG = "ChatSettings";
|
||||
|
||||
static std::string getSettingsFilePath() {
|
||||
return getUserDataPath() + "/settings/chat.properties";
|
||||
@@ -52,7 +52,7 @@ static std::string toHexString(const uint8_t* data, size_t length) {
|
||||
|
||||
static bool readHex(const std::string& input, uint8_t* buffer, size_t length) {
|
||||
if (input.size() != length * 2) {
|
||||
LOGGER.error("readHex() length mismatch");
|
||||
LOG_E(TAG, "readHex() length mismatch");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ static bool readHex(const std::string& input, uint8_t* buffer, size_t length) {
|
||||
char* endptr;
|
||||
unsigned long val = strtoul(hex, &endptr, 16);
|
||||
if (endptr != hex + 2) {
|
||||
LOGGER.error("readHex() invalid hex character");
|
||||
LOG_E(TAG, "readHex() invalid hex character");
|
||||
return false;
|
||||
}
|
||||
buffer[i] = static_cast<uint8_t>(val);
|
||||
@@ -77,7 +77,7 @@ static bool encryptKey(const uint8_t key[ESP_NOW_KEY_LEN], std::string& hexOutpu
|
||||
|
||||
uint8_t encrypted[ESP_NOW_KEY_LEN];
|
||||
if (crypt::encrypt(iv, key, encrypted, ESP_NOW_KEY_LEN) != 0) {
|
||||
LOGGER.error("Failed to encrypt key");
|
||||
LOG_E(TAG, "Failed to encrypt key");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ static bool decryptKey(const std::string& hexInput, uint8_t key[ESP_NOW_KEY_LEN]
|
||||
crypt::getIv(IV_SEED, std::strlen(IV_SEED), iv);
|
||||
|
||||
if (crypt::decrypt(iv, encrypted, key, ESP_NOW_KEY_LEN) != 0) {
|
||||
LOGGER.error("Failed to decrypt key");
|
||||
LOG_E(TAG, "Failed to decrypt key");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -188,7 +188,7 @@ bool saveSettings(const ChatSettingsData& settings) {
|
||||
|
||||
auto settings_path = getSettingsFilePath();
|
||||
if (!file::findOrCreateParentDirectory(settings_path, 0755)) {
|
||||
LOGGER.error("Failed to create parent dir for {}", settings_path);
|
||||
LOG_E(TAG, "Failed to create parent dir for %s", settings_path.c_str());
|
||||
return false;
|
||||
}
|
||||
return file::savePropertiesFile(settings_path, map);
|
||||
|
||||
Reference in New Issue
Block a user