2022-02-27 00:18:35 -08:00
|
|
|
#include "TextMessageModule.h"
|
2023-08-19 07:46:34 -05:00
|
|
|
#include "MeshService.h"
|
2020-11-28 12:10:19 +08:00
|
|
|
#include "NodeDB.h"
|
|
|
|
|
#include "PowerFSM.h"
|
2024-07-25 10:10:38 +08:00
|
|
|
#include "buzz.h"
|
2023-01-21 14:34:29 +01:00
|
|
|
#include "configuration.h"
|
2022-02-27 02:21:02 -08:00
|
|
|
TextMessageModule *textMessageModule;
|
2020-11-28 12:10:19 +08:00
|
|
|
|
2023-01-21 18:22:19 +01:00
|
|
|
ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp)
|
2020-11-28 12:10:19 +08:00
|
|
|
{
|
2023-05-13 13:33:14 +03:00
|
|
|
#ifdef DEBUG_PORT
|
2021-02-17 13:06:23 +08:00
|
|
|
auto &p = mp.decoded;
|
2022-12-30 10:27:07 -06:00
|
|
|
LOG_INFO("Received text msg from=0x%0x, id=0x%x, msg=%.*s\n", mp.from, mp.id, p.payload.size, p.payload.bytes);
|
2023-05-13 13:33:14 +03:00
|
|
|
#endif
|
2020-11-28 12:10:19 +08:00
|
|
|
// We only store/display messages destined for us.
|
|
|
|
|
// Keep a copy of the most recent text message.
|
|
|
|
|
devicestate.rx_text_message = mp;
|
|
|
|
|
devicestate.has_rx_text_message = true;
|
|
|
|
|
|
2023-05-01 16:10:27 -05:00
|
|
|
powerFSM.trigger(EVENT_RECEIVED_MSG);
|
2020-11-28 12:10:19 +08:00
|
|
|
notifyObservers(&mp);
|
|
|
|
|
|
2021-09-23 04:42:09 +03:00
|
|
|
return ProcessMessage::CONTINUE; // Let others look at this message also if they want
|
2020-11-28 12:10:19 +08:00
|
|
|
}
|
2023-08-19 07:46:34 -05:00
|
|
|
|
|
|
|
|
bool TextMessageModule::wantPacket(const meshtastic_MeshPacket *p)
|
|
|
|
|
{
|
|
|
|
|
return MeshService::isTextPayload(p);
|
|
|
|
|
}
|