From 88145d74bae4781ae79ce69bdfd7922ebe0ccf87 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Tue, 1 Mar 2022 21:51:41 +0100 Subject: [PATCH] rx: added function to determine whether rx is busy --- impl/src/layer1/rx.c | 6 ++++++ impl/src/layer1/rx.h | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/impl/src/layer1/rx.c b/impl/src/layer1/rx.c index f85c982..062be61 100644 --- a/impl/src/layer1/rx.c +++ b/impl/src/layer1/rx.c @@ -311,3 +311,9 @@ result_t layer1_rx_shutdown(layer1_rx_t *rx) return OK; } + + +bool layer1_rx_is_busy(const layer1_rx_t *rx) +{ + return rx->state != RX_STATE_ACQUISITION; +} diff --git a/impl/src/layer1/rx.h b/impl/src/layer1/rx.h index ccb9ead..783213e 100644 --- a/impl/src/layer1/rx.h +++ b/impl/src/layer1/rx.h @@ -69,7 +69,7 @@ typedef struct /*! * \brief Initialize the receiver. * - * \param tx Pointer to the receiver context. + * \param rx Pointer to the receiver context. * \param callback Function to be called on receiver events. * \returns The result of the initialization. */ @@ -79,7 +79,7 @@ result_t layer1_rx_init(layer1_rx_t *rx, rx_callback_t callback); /*! * \brief Shut the receiver down. Frees all memory. * - * \param tx Pointer to the receiver context. + * \param rx Pointer to the receiver context. * \returns The result of the shutdown. */ result_t layer1_rx_shutdown(layer1_rx_t *rx); @@ -96,11 +96,24 @@ result_t layer1_rx_shutdown(layer1_rx_t *rx); * callback function passed to \ref layer1_rx_init() will be called. See \ref * rx_evt_t for possible events. * - * \param tx Pointer to the receiver context. + * \param rx Pointer to the receiver context. * \param samples Pointer to the samples to process. * \param sample_count Number of samples to process. * \returns The result of the shutdown. */ result_t layer1_rx_process(layer1_rx_t *rx, const float complex *samples, size_t sample_count); + +/*! + * \brief Determine whether the receiver is currently receiving a packet. + * + * This function can be used to identify idle periods where packet transmission + * is possible. Switching to TX while this function returns true will very + * probably result in a collision with packet corruption. + * + * \param rx Pointer to the receiver context. + * \returns Whether the receiver is currently receiving a packet. + */ +bool layer1_rx_is_busy(const layer1_rx_t *rx); + #endif // LAYER1_RX_H