forked from meshtastic/firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSerialModule.h
More file actions
84 lines (63 loc) · 2.19 KB
/
Copy pathSerialModule.h
File metadata and controls
84 lines (63 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#include "MeshModule.h"
#include "Router.h"
#include "SinglePortModule.h"
#include "concurrency/OSThread.h"
#include "configuration.h"
#include <Arduino.h>
#include <functional>
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) || defined(ARCH_STM32WL)) && \
!defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
class SerialModule : public StreamAPI, private concurrency::OSThread
{
bool firstTime = 1;
unsigned long lastNmeaTime = millis();
char outbuf[90] = "";
public:
SerialModule();
static bool isValidConfig(const meshtastic_ModuleConfig_SerialConfig &config);
protected:
virtual int32_t runOnce() override;
/// Check the current underlying physical link to see if the client is currently connected
virtual bool checkIsConnected() override;
private:
uint32_t getBaudRate();
void sendTelemetry(meshtastic_Telemetry m);
void processWXSerial();
};
extern SerialModule *serialModule;
/*
* Radio interface for SerialModule
*
*/
class SerialModuleRadio : public MeshModule
{
uint32_t lastRxID = 0;
char outbuf[90] = "";
public:
SerialModuleRadio();
/**
* Send our payload into the mesh
*/
void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false);
protected:
virtual meshtastic_MeshPacket *allocReply() override;
/** Called to handle a particular incoming message
@return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for
it
*/
virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override;
meshtastic_PortNum ourPortNum;
virtual bool wantPacket(const meshtastic_MeshPacket *p) override { return p->decoded.portnum == ourPortNum; }
meshtastic_MeshPacket *allocDataPacket()
{
// Update our local node info with our position (even if we don't decide to update anyone else)
meshtastic_MeshPacket *p = router->allocForSending();
if (!p)
return nullptr;
p->decoded.portnum = ourPortNum;
return p;
}
};
extern SerialModuleRadio *serialModuleRadio;
#endif