M5Unit-RF433 0.1.0 git rev:5415b86
Loading...
Searching...
No Matches
m5_codec.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
13#ifndef M5_UNIT_RF433_CODEC_M5_CODEC_HPP
14#define M5_UNIT_RF433_CODEC_M5_CODEC_HPP
15
16#include "protocol_codec.hpp"
17#include <m5_utility/crc.hpp>
18
19namespace m5 {
20namespace unit {
21namespace rf433 {
22
29class M5Codec : public ProtocolCodec {
30public:
31 M5Codec() : ProtocolCodec(CodecType::M5RF433)
32 {
33 }
34
41 item_container_type encode(const uint8_t* payload, uint32_t payload_len) override;
42
52 bool decode(const gpio::m5_rmt_item_t* items, uint32_t num, uint8_t* work_buf, uint16_t work_buf_size,
53 DecodeResult& result) override;
54
59 uint8_t overhead() const override
60 {
61 // CRC8(1) + ID(1) + Count(1) + Length(1) = 4
62 return 4;
63 }
64
67
72 {
73 return _comm_id;
74 }
80 {
81 _comm_id = id;
82 }
84
85private:
87 uint8_t _send_count{};
88};
89
90} // namespace rf433
91} // namespace unit
92} // namespace m5
93#endif
M5Unit-RF433 original protocol codec.
Definition m5_codec.hpp:29
uint8_t overhead() const override
Get protocol overhead in bytes.
Definition m5_codec.hpp:59
void setCommunicationIdentifier(communication_identifier_t id)
Set the communication identifier.
Definition m5_codec.hpp:79
communication_identifier_t communicationIdentifier() const
Get the communication identifier.
Definition m5_codec.hpp:71
bool decode(const gpio::m5_rmt_item_t *items, uint32_t num, uint8_t *work_buf, uint16_t work_buf_size, DecodeResult &result) override
Decode RMT items into payload data.
Definition m5_codec.cpp:77
item_container_type encode(const uint8_t *payload, uint32_t payload_len) override
Encode payload into RMT items with M5 protocol framing.
Definition m5_codec.cpp:36
Abstract base class for RF433 protocol encoding/decoding.
Definition protocol_codec.hpp:49
Top level namespace of M5Stack.
Unit-related namespace.
Protocol codec base class for RF433.
uint8_t communication_identifier_t
Communication identifier (0-255)
Definition rmt_item_types.hpp:29
std::vector< gpio::m5_rmt_item_t > item_container_type
Item container.
Definition rmt_item_types.hpp:28
Result of decoding a received frame.
Definition protocol_codec.hpp:23