| 91 | } |
| 92 | |
| 93 | void ChatApp::sendMessage(const std::string& text) { |
| 94 | if (text.empty()) return; |
| 95 | |
| 96 | std::string nickname = state.getLocalNickname(); |
| 97 | std::string channel = state.getCurrentChannel(); |
| 98 | |
| 99 | std::vector<uint8_t> wireMsg; |
| 100 | if (!serializeTextMessage(settings.senderId, BROADCAST_ID, nickname, channel, text, wireMsg)) { |
| 101 | LOGGER.error("Failed to serialize message"); |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | if (!service::espnow::send(BROADCAST_ADDRESS, wireMsg.data(), wireMsg.size())) { |
| 106 | LOGGER.error("Failed to send message"); |
| 107 | return; |
| 108 | } |
| 109 | |
| 110 | StoredMessage msg; |
| 111 | msg.displayText = nickname + ": " + text; |
| 112 | msg.target = channel; |
| 113 | msg.isOwn = true; |
| 114 | |
| 115 | state.addMessage(msg); |
| 116 | |
| 117 | { |
| 118 | auto lock = lvgl::getSyncLock()->asScopedLock(); |
| 119 | lock.lock(); |
| 120 | view.displayMessage(msg); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | void ChatApp::applySettings(const std::string& nickname, const std::string& keyHex) { |
| 125 | bool needRestart = false; |
no test coverage detected