mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Refactor bridge packet handling to use common magic number and size constants
This commit is contained in:
parent
7fca20475a
commit
1d25c87c57
6 changed files with 40 additions and 37 deletions
|
|
@ -21,6 +21,26 @@ class BridgeBase : public AbstractBridge {
|
|||
public:
|
||||
virtual ~BridgeBase() = default;
|
||||
|
||||
/**
|
||||
* @brief Common magic number used by all bridge implementations for packet identification
|
||||
*
|
||||
* This magic number is placed at the beginning of bridge packets to identify
|
||||
* them as mesh bridge packets and provide frame synchronization.
|
||||
*/
|
||||
static constexpr uint16_t BRIDGE_PACKET_MAGIC = 0xC03E;
|
||||
|
||||
/**
|
||||
* @brief Common field sizes used by bridge implementations
|
||||
*
|
||||
* These constants define the size of common packet fields used across bridges.
|
||||
* BRIDGE_MAGIC_SIZE is used by all bridges for packet identification.
|
||||
* BRIDGE_LENGTH_SIZE is used by bridges that need explicit length fields (like RS232).
|
||||
* BRIDGE_CHECKSUM_SIZE is used by all bridges for Fletcher-16 checksums.
|
||||
*/
|
||||
static constexpr uint16_t BRIDGE_MAGIC_SIZE = sizeof(BRIDGE_PACKET_MAGIC);
|
||||
static constexpr uint16_t BRIDGE_LENGTH_SIZE = sizeof(uint16_t);
|
||||
static constexpr uint16_t BRIDGE_CHECKSUM_SIZE = sizeof(uint16_t);
|
||||
|
||||
protected:
|
||||
/** Packet manager for allocating and queuing mesh packets */
|
||||
mesh::PacketManager *_mgr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue