Chat app update, EspNow v2 & GPS Info (#460)

This commit is contained in:
Shadowtrance
2026-01-27 02:32:57 +10:00
committed by GitHub
parent dfe2c865d1
commit 10381b10cd
18 changed files with 1547 additions and 124 deletions
+60
View File
@@ -0,0 +1,60 @@
#ifdef ESP_PLATFORM
#include <sdkconfig.h>
#endif
#if defined(CONFIG_SOC_WIFI_SUPPORTED) && !defined(CONFIG_SLAVE_SOC_WIFI_SUPPORTED)
#include <Tactility/app/chat/ChatState.h>
namespace tt::app::chat {
void ChatState::setLocalNickname(const std::string& nickname) {
auto lock = mutex.asScopedLock();
lock.lock();
localNickname = nickname;
}
std::string ChatState::getLocalNickname() const {
auto lock = mutex.asScopedLock();
lock.lock();
return localNickname;
}
void ChatState::setCurrentChannel(const std::string& channel) {
auto lock = mutex.asScopedLock();
lock.lock();
currentChannel = channel;
}
std::string ChatState::getCurrentChannel() const {
auto lock = mutex.asScopedLock();
lock.lock();
return currentChannel;
}
void ChatState::addMessage(const StoredMessage& msg) {
auto lock = mutex.asScopedLock();
lock.lock();
if (messages.size() >= MAX_MESSAGES) {
messages.pop_front();
}
messages.push_back(msg);
}
std::vector<StoredMessage> ChatState::getFilteredMessages() const {
auto lock = mutex.asScopedLock();
lock.lock();
std::vector<StoredMessage> result;
result.reserve(messages.size()); // Avoid reallocations; may over-allocate slightly
for (const auto& msg : messages) {
// Show if broadcast (empty target) or matches current channel
if (msg.target.empty() || msg.target == currentChannel) {
result.push_back(msg);
}
}
return result;
}
} // namespace tt::app::chat
#endif // CONFIG_SOC_WIFI_SUPPORTED && !CONFIG_SLAVE_SOC_WIFI_SUPPORTED