nrf24_rs/
error.rs

1//! Errors that can occur when sending and receiving data with the nRF24L01 transceiver.
2//!
3//! This module provides a comprehensive error type that encapsulates all possible
4//! failure modes when interacting with the nRF24L01 module, including SPI communication
5//! errors, GPIO control errors, and transceiver-specific error conditions.
6
7/// Represents all possible errors that can occur when using the nRF24L01 transceiver.
8///
9/// This error type is generic over the underlying SPI and CE pin error types.
10#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11#[derive(Debug)]
12pub enum TransceiverError<SpiErr, CeErr> {
13    /// An error occurred during SPI communication.
14    ///
15    /// This typically represents a failure in the hardware communication layer,
16    /// such as bus contention or device disconnection.
17    Spi(SpiErr),
18
19    /// An error occurred when controlling the Chip Enable (CE) pin.
20    ///
21    /// This could happen if the GPIO pin controlling the CE line encounters
22    /// a hardware failure or configuration issue.
23    Ce(CeErr),
24
25    /// A communication error occurred with the nRF24L01 module.
26    ///
27    /// The wrapped value is a status byte from the device that indicates
28    /// the specific nature of the communication failure.
29    Comm(u8),
30
31    /// The maximum number of retransmit attempts was reached without receiving an ACK.
32    ///
33    /// This occurs when auto-acknowledgement is enabled and the receiver does not
34    /// acknowledge receipt of the transmitted packet after the configured number of retries.
35    MaxRetries,
36
37    /// The provided buffer is too small for the requested operation.
38    ///
39    /// This error includes information about the required buffer size and the
40    /// actual size that was provided.
41    BufferTooSmall {
42        /// The required buffer size in bytes
43        required: u8,
44        /// The actual buffer size that was provided
45        actual: u8,
46    },
47}