hamnet70/impl/src/layer1/tx.h

104 lines
2.6 KiB
C
Raw Normal View History

#ifndef LAYER1_TX_H
#define LAYER1_TX_H
#include <complex.h>
#include <stddef.h>
#include <stdint.h>
#include "results.h"
#include "transmission.h"
#include "packet_mod.h"
typedef struct
{
float complex *samples;
size_t samples_allocated;
size_t samples_used;
transmission_ctx_t transmission;
packet_mod_ctx_t pmod;
} layer1_tx_t;
/*!
* \brief Initialize the transmitter.
*
* \param tx Pointer to the transmitter context.
* \returns The result of the initialization.
*/
result_t layer1_tx_init(layer1_tx_t *tx);
/*!
* \brief Shut the transmitter down. Frees all memory.
*
* \param tx Pointer to the transmitter context.
* \returns The result of the shutdown.
*/
result_t layer1_tx_shutdown(layer1_tx_t *tx);
/*!
* \brief Reset the transmitter.
*
* Logically removes all internal data, but does not free memory.
*
* \param tx Pointer to the transmitter context.
* \returns The result of the reset.
*/
result_t layer1_tx_reset(layer1_tx_t *tx);
/*!
* \brief Add a packet to the burst.
*
* Encodes the raw data, modulates it, applies pulse filtering and appends the
* result to the internal buffer.
*
* If the buffer is empty (after init or reset), it first generates a ramp-up
* sequence.
*
* You can add arbitrarily many packets, the only limit is the available memory.
*
* \param tx Pointer to the transmitter context.
* \param data Pointer to the packets raw data.
* \param length The number of bytes in the data array.
* \returns The result of the operation.
*/
result_t layer1_tx_add_packet_to_burst(layer1_tx_t *tx, const uint8_t *data, size_t length);
/*!
* \brief Generate the ramp-down sequence.
*
* The burst is considered complete after calling this function. You should
* retrieve the generated samples and call \ref layer1_tx_reset() before adding
* further packets.
*
* \param tx Pointer to the transmitter context.
* \returns The result of the finalization.
*/
result_t layer1_tx_finalize_burst(layer1_tx_t *tx);
/*!
* \brief Retrieve the number of generated samples.
*
* \param tx Pointer to the transmitter context.
* \returns The number of samples returned by \ref layer1_tx_get_sample_data().
*/
size_t layer1_tx_get_sample_count(const layer1_tx_t *tx);
/*!
* \brief Retrieve the generated samples.
*
* Calling this after \ref layer1_tx_finalize_burst() returns the complete burst ready for transmission.
*
* \param tx Pointer to the transmitter context.
* \returns A pointer to the generated samples.
*/
const float complex* layer1_tx_get_sample_data(const layer1_tx_t *tx);
#endif // LAYER1_TX_H