mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-19 01:02:36 +00:00
44 lines
1.4 KiB
C++
44 lines
1.4 KiB
C++
#include "TextMessageModule.h"
|
|
#include "MeshService.h"
|
|
#include "MessageStore.h"
|
|
#include "NodeDB.h"
|
|
#include "PowerFSM.h"
|
|
#include "buzz.h"
|
|
#include "configuration.h"
|
|
#include "graphics/Screen.h"
|
|
#include "graphics/draw/MessageRenderer.h"
|
|
TextMessageModule *textMessageModule;
|
|
|
|
ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp)
|
|
{
|
|
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
|
|
auto &p = mp.decoded;
|
|
LOG_INFO("Received text msg from=0x%0x, id=0x%x, msg=%.*s", mp.from, mp.id, p.payload.size, p.payload.bytes);
|
|
#endif
|
|
|
|
// We only store/display messages destined for us.
|
|
devicestate.rx_text_message = mp;
|
|
devicestate.has_rx_text_message = true;
|
|
#if HAS_SCREEN
|
|
// Store in the central message history
|
|
const StoredMessage &sm = messageStore.addFromPacket(mp);
|
|
|
|
// Pass message to renderer (banner + thread switching + scroll reset)
|
|
graphics::MessageRenderer::handleNewMessage(sm, mp);
|
|
#endif
|
|
// Only trigger screen wake if configuration allows it
|
|
if (shouldWakeOnReceivedMessage()) {
|
|
powerFSM.trigger(EVENT_RECEIVED_MSG);
|
|
}
|
|
|
|
// Notify any observers (e.g. external modules that care about packets)
|
|
notifyObservers(&mp);
|
|
|
|
return ProcessMessage::CONTINUE; // Let others look at this message also if they want
|
|
}
|
|
|
|
bool TextMessageModule::wantPacket(const meshtastic_MeshPacket *p)
|
|
{
|
|
return MeshService::isTextPayload(p);
|
|
}
|