RMT related definition and function for RF433.
More...
#include <M5UnitComponent.hpp>
Go to the source code of this file.
|
| namespace | m5 |
| | Top level namespace of M5Stack.
|
| |
|
|
using | m5::unit::rf433::container_type = std::vector<uint8_t> |
| | Container.
|
| |
|
using | m5::unit::rf433::item_container_type = std::vector<gpio::m5_rmt_item_t> |
| | Item container.
|
| |
|
using | m5::unit::rf433::communication_identifier_t = uint8_t |
| | Communication identifier (0-255)
|
| |
|
|
constexpr uint8_t | m5::unit::rf433::ProtocolOverhead = 4 |
| | Protocol overhead in bytes: CRC8(1) + ID(1) + Count(1) + Length(1) = 4.
|
| |
| constexpr uint16_t | m5::unit::rf433::RmtRxMaxItems = 6 * 64 |
| | Maximum RMT items receivable in a single frame per platform.
|
| |
| constexpr uint8_t | m5::unit::rf433::MaxPayloadSize |
| | Theoretical maximum payload size in bytes for the current platform.
|
| |
RMT related definition and function for RF433.
◆ calculateRingBufferSize()
| uint32_t m5::unit::rf433::calculateRingBufferSize |
( |
const uint32_t | payload_size | ) |
|
|
constexpr |
Calculate the minimum ring buffer size required to receive the given payload size.
- Parameters
-
| payload_size | Payload size in bytes |
- Returns
- Required ring buffer size in bytes
◆ decodeManchester()
| uint16_t m5::unit::rf433::decodeManchester |
( |
uint8_t * | buf, |
|
|
const uint16_t | buf_size, |
|
|
const m5::unit::gpio::m5_rmt_item_t * | data, |
|
|
const uint32_t | num, |
|
|
const bool | MSB = true ) |
Decode manchester.
- Parameters
-
| buf | Output buffer |
| buf_size | Output buffer size |
| data | RMT data (exclude SOF) |
| num | Number of the RMT items |
| MSB | Process from MSB if true |
- Returns
- Decoded count
◆ encodeManchester()
| item_container_type m5::unit::rf433::encodeManchester |
( |
const uint8_t * | data, |
|
|
const uint32_t | len, |
|
|
const bool | MSB = true ) |
Encode manchester.
- Parameters
-
| data | Input buffer |
| len | Length of input buffer |
| MSB | Process from MSB if true |
- Returns
- Encoded container
◆ MaxPayloadSize
| uint8_t m5::unit::rf433::MaxPayloadSize |
|
constexpr |
Initial value:=
static_cast<uint8_t
>((
RmtRxMaxItems - 1 ) / 8 - ProtocolOverhead)
constexpr uint16_t RmtRxMaxItems
Maximum RMT items receivable in a single frame per platform.
Definition rmt_item_types.hpp:51
Theoretical maximum payload size in bytes for the current platform.
Calculated from RmtRxMaxItems with protocol overhead (4 bytes). This is the theoretical limit based on RMT hardware memory. In practice, AGC noise from the SYN531R receiver consumes RMT items, reducing the usable capacity. Theoretical values:
- ESP32: 43 bytes (practical safe limit ~23 bytes)
- ESP32-S3: 43 bytes (1 mem_block + threshold ISR wrapping; practical safe limit ~23 bytes)
- ESP-IDF 5.x (RMT v2): 255 bytes
- Warning
- When communicating between RMT v1 (ESP-IDF 4.x) and RMT v2 (ESP-IDF 5.x) devices, the payload size must not exceed the receiver's limit. A v2 transmitter can send up to 255 bytes, but a v1 receiver's capacity is much smaller and varies depending on AGC noise conditions. Always limit the payload to the receiver's max_payload_size.
- See also
- UnitSYN531R::config_t::max_payload_size for the configurable runtime limit
◆ RmtRxMaxItems
| uint16_t m5::unit::rf433::RmtRxMaxItems = 6 * 64 |
|
constexpr |
Maximum RMT items receivable in a single frame per platform.
- ESP32 (RMT v1): 6 mem_blocks x 64 = 384 items
- ESP32-S3 (RMT v1): 1 mem_block x 48 = 48 items (threshold ISR wrapping)
- ESP-IDF 5.x (RMT v2): ping-pong/DMA, limited by user buffer only
- Note
- RF433 ASK receivers (SYN531R) generate AGC noise before the SOF, consuming part of the RMT memory. The maximum payload must fit within a single RMT hardware frame to avoid truncation.
- Warning
- ESP32-S3 + ESP-IDF 4.x has a known RMT RX ping-pong bug that may cause memory corruption and crash in noisy RF environments. See https://github.com/espressif/esp-idf/issues/13419 Recommended to use ESP-IDF 5.x (pioarduino) for ESP32-S3. ESP32: 8ch x 64 items, use 6 = 384