|
ESP32 Transceiver IEEE 802.15.4 Library
|
Arduino Stream interface for IEEE 802.15.4 transceiver. More...
#include <ESP32TransceiverStreamIEEE802_15_4.h>


Public Member Functions | |
| virtual int | available () override |
| Get the number of bytes available to read. | |
| int | availableForWrite () override |
| Get the number of bytes available for writing. | |
| bool | begin () |
| Initialize the stream and underlying transceiver. | |
| bool | begin (FrameControlField fcf) |
| Initialize the stream and underlying transceiver. | |
| void | end () |
| Deinitialize the stream and underlying transceiver. | |
| ESP32TransceiverStreamIEEE802_15_4 (channel_t channel, int16_t panID, Address localAdr) | |
| Construct a new ESP32TransceiverStream object with transceiver parameters. | |
| ESP32TransceiverStreamIEEE802_15_4 (ESP32TransceiverIEEE802_15_4 &transceiver) | |
| Construct a new ESP32TransceiverStream object. | |
| void | flush () override |
| Flush the transmit buffer and send its contents as a frame. | |
| uint32_t | getAckTimeoutUs () const |
| Get the current acknowledgment timeout in microseconds. | |
| channel_t | getChannel () const |
| Get the current IEEE 802.15.4 channel. | |
| FrameControlField & | getFrameControlField () |
| Get the current Frame Control Field (FCF) in use. | |
| int | getMaxMTU () const |
| Get the maximum transmission unit (MTU) size for the data content. | |
| size_t | getRxBufferSize () const |
| Get the current receive buffer size in bytes. | |
| int | getRxMessageBufferSize () const |
| Get the current message buffer size for receiving frames. | |
| int | getSendDelay () const |
| Get the delay between send retries in milliseconds. | |
| ESP32TransceiverIEEE802_15_4 & | getTransceiver () |
| Get a reference to the underlying transceiver instance. | |
| int | getTxBufferSize () const |
| Get the current transmit buffer size for the stream. | |
| int8_t | getTxPower () const |
| Get the current transmit power in dBm. | |
| bool | isAckActive () const |
| Check if acknowledgment requests are enabled for outgoing frames. | |
| bool | isCCAActive () const |
| Check if CCA (Clear Channel Assessment) is enabled. | |
| int | peek () |
| Peek at the next byte in the receive buffer (not implemented). | |
| int | read () override |
| Read a single byte from the receive buffer. | |
| size_t | readBytes (uint8_t *buffer, size_t size) |
| Read multiple bytes from the receive buffer. | |
| void | setAckActive (bool ack_active) |
| Enable or disable acknowledgment requests for outgoing frames. | |
| void | setAckTimeoutUs (uint32_t timeout_us) |
| Set the time in us to wait for the ack frame. | |
| void | setBroadcast () |
| Set the destination address to the broadcast address (0xFFFF). | |
| void | setCCAActive (bool cca_enabled) |
| Enable or disable CCA (Clear Channel Assessment). | |
| bool | setChannel (channel_t channel) |
| Set the IEEE 802.15.4 channel. | |
| bool | setCoordinatorActive (bool coordinator) |
| Set the coordinator mode for the transceiver. | |
| void | setDestinationAddress (const Address &address) |
| Set the destination address for the stream. | |
| void | setFrameControlField (const FrameControlField &fcf) |
| Set the Frame Control Field (FCF) for outgoing frames. | |
| bool | setPromiscuousModeActive (bool promiscuous) |
| Set promiscuous mode for the transceiver. | |
| void | setRxBufferSize (size_t size) |
| Set the size of the receive buffer. This defines how many bytes we can get by calling readBytes();. | |
| void | setRxMessageBufferSize (int size) |
| Set the size of the message buffer used for receiving frames. | |
| bool | setRxWhenIdleActive (bool rx_when_idle) |
| Set RX when idle mode for the transceiver. | |
| void | setSendDelay (int delay_ms) |
| Set the delay between sends or send retries. | |
| void | setSendRetryCount (int count) |
| Defines the retry count for faild send requests. | |
| bool | setTxBufferSize (int buffer_size) |
| Set the transmit buffer size for the stream. This defines how much data can be buffered for sending before it is flushed. | |
| bool | setTxPower (int power) |
| Set the transmit power in dBm. | |
| size_t | write (const uint8_t *buffer, size_t size) override |
| Write a buffer of bytes to the transceiver. | |
| size_t | write (const uint8_t byte) override |
| Write a single byte to the transceiver. | |
| ~ESP32TransceiverStreamIEEE802_15_4 () | |
| Destroy the ESP32TransceiverStream object. | |
Protected Types | |
| enum | send_confirmation_state_t { WAITING_FOR_CONFIRMATION , CONFIRMATION_RECEIVED , CONFIRMATION_ERROR } |
Protected Member Functions | |
| bool | isSendConfirmations () |
| bool | isSequenceNumbers () |
| bool | receive () |
| Internal method to receive frames and fill the receive buffer. | |
| void | sendWithConfirmations () |
| Internal method to send a frame with confirmation handling. Retries sending the frame if confirmation fails, with a delay between attempts. | |
| void | sendWithoutConfirmations () |
| Internal method to send a frame without waiting for confirmations. Adds a delay after sending to allow the transceiver to process the frame. | |
Static Protected Member Functions | |
| static void | ieee802154_transceiver_tx_done_callback (const uint8_t *frame, const uint8_t *ack, esp_ieee802154_frame_info_t *ack_frame_info, void *user_data) |
| Callback for successful frame transmission. | |
| static void | ieee802154_transceiver_tx_failed_callback (const uint8_t *frame, esp_ieee802154_tx_error_t error, void *user_data) |
| Callback for failed frame transmission. | |
Protected Attributes | |
| Frame | frame |
| bool | is_auto_flush = false |
| bool | is_open_frame = false |
| bool | is_send_confirations_enabled = false |
| int | last_seq = -1 |
| esp_ieee802154_tx_error_t | last_tx_error = ESP_IEEE802154_TX_ERR_NONE |
| bool | owns_transceiver = false |
| ESP32TransceiverIEEE802_15_4 * | p_transceiver = nullptr |
| int | receive_msg_buffer_size |
| RingBuffer | rx_buffer {1024 + MTU} |
| volatile send_confirmation_state_t | send_confirmation_state |
| int | send_delay_ms = 10 |
| Delay after sending a frame when confirmations are not used. | |
| int | send_retry_count = 2 |
| RingBuffer | tx_buffer {MTU} |
Static Protected Attributes | |
| static constexpr int | MTU = 116 |
| static constexpr const char * | TAG = "ESP32TransceiverStream" |
Arduino Stream interface for IEEE 802.15.4 transceiver.
Allows using ESP32TransceiverIEEE802_15_4 as a Stream for easy integration with Arduino APIs and libraries that expect a Stream object. Provides buffered read/write access to the transceiver.
If you want to control the creation of the individual frame segments, write data smaller than the MTU (127 bytes) and call flush() to send the frame immediately.
When you write data to the stream, that is bigger than the MTU, it is automatically split into multiple frames and sent one after another.
When you enable acknowledgment requests for outgoing frames, the stream will wait for the acknowledgment frame from the receiver before sending the next frame. If the acknowledgment is not received within the configured timeout, the stream will retry sending the frame after a delay. This process will repeat until the frame is acknowledged or a maximum number of retries is reached.
|
inline |
Construct a new ESP32TransceiverStream object.
| transceiver | Reference to the IEEE802.15.4 transceiver instance. |
|
inline |
Construct a new ESP32TransceiverStream object with transceiver parameters.
| channel | The IEEE 802.15.4 channel to use. |
| panID | The Personal Area Network Identifier to use for the transceiver. |
| localAddress | The local address for the device. |
|
inline |
Destroy the ESP32TransceiverStream object.
|
inlineoverridevirtual |
Get the number of bytes available to read.
|
inlineoverride |
Get the number of bytes available for writing.
|
inline |
Initialize the stream and underlying transceiver.
|
inline |
Initialize the stream and underlying transceiver.
|
inline |
Deinitialize the stream and underlying transceiver.
|
inlineoverride |
Flush the transmit buffer and send its contents as a frame.
Sends all buffered data via the transceiver and clears the buffer.
|
inline |
Get the current acknowledgment timeout in microseconds.
|
inline |
Get the current IEEE 802.15.4 channel.
|
inline |
Get the current Frame Control Field (FCF) in use.
|
inline |
Get the maximum transmission unit (MTU) size for the data content.
|
inline |
Get the current receive buffer size in bytes.
|
inline |
Get the current message buffer size for receiving frames.
|
inline |
Get the delay between send retries in milliseconds.
|
inline |
Get a reference to the underlying transceiver instance.
|
inline |
Get the current transmit buffer size for the stream.
|
inline |
Get the current transmit power in dBm.
|
inlinestaticprotected |
Callback for successful frame transmission.
|
inlinestaticprotected |
Callback for failed frame transmission.
|
inline |
Check if acknowledgment requests are enabled for outgoing frames.
|
inline |
Check if CCA (Clear Channel Assessment) is enabled.
|
inlineprotected |
|
inlineprotected |
|
inline |
Peek at the next byte in the receive buffer (not implemented).
|
inlineoverride |
Read a single byte from the receive buffer.
|
inline |
Read multiple bytes from the receive buffer.
| buffer | Pointer to destination buffer. |
| size | Number of bytes to read. |
|
inlineprotected |
Internal method to receive frames and fill the receive buffer.
|
inlineprotected |
Internal method to send a frame with confirmation handling. Retries sending the frame if confirmation fails, with a delay between attempts.
|
inlineprotected |
Internal method to send a frame without waiting for confirmations. Adds a delay after sending to allow the transceiver to process the frame.
|
inline |
Enable or disable acknowledgment requests for outgoing frames.
| ack_active | True to enable acknowledgment requests, false to disable. |
|
inline |
Set the time in us to wait for the ack frame.
| [in] | timeout | The time to wait for the ack frame, in us. It Should be a multiple of 16. |
|
inline |
Set the destination address to the broadcast address (0xFFFF).
|
inline |
Enable or disable CCA (Clear Channel Assessment).
| cca_enabled | True to enable CCA (Clear Channel Assessment), false to disable. |
|
inline |
Set the IEEE 802.15.4 channel.
| channel | The channel to set. |
|
inline |
Set the coordinator mode for the transceiver.
| coordinator | True to enable coordinator mode, false to disable. |
|
inline |
Set the destination address for the stream.
| address | The destination address. |
|
inline |
|
inline |
Set promiscuous mode for the transceiver.
| promiscuous | True to enable promiscuous mode, false to disable. |
|
inline |
Set the size of the receive buffer. This defines how many bytes we can get by calling readBytes();.
| size | New size of the receive buffer. |
|
inline |
Set the size of the message buffer used for receiving frames.
| size | New size of the message buffer in bytes. |
|
inline |
Set RX when idle mode for the transceiver.
| rx_when_idle | True to enable RX when idle, false to disable. |
|
inline |
Set the delay between sends or send retries.
| delay_ms | Delay in milliseconds. |
|
inline |
Defines the retry count for faild send requests.
| count | Number of retries. |
|
inline |
Set the transmit buffer size for the stream. This defines how much data can be buffered for sending before it is flushed.
| buffer_size | The desired buffer size in bytes. Must be greater than 0 but not exceed the maximum data MTU size. |
|
inline |
Set the transmit power in dBm.
| power | Transmit power value to set (in dBm). -24 dBm to +20 dBm |
|
inlineoverride |
Write a buffer of bytes to the transceiver.
| buffer | Pointer to data buffer. |
| size | Number of bytes to write. |
|
inlineoverride |
Write a single byte to the transceiver.
| byte | Byte to write. |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticconstexprprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Delay after sending a frame when confirmations are not used.
|
protected |
|
staticconstexprprotected |
|
protected |