From 126d3d83ba99a4bc337a0cfc1a8766d9b67fb214 Mon Sep 17 00:00:00 2001 From: Mooneer Salem Date: Sun, 8 Dec 2024 10:03:49 -0800 Subject: [PATCH] Reformat code to make it easier to read. --- src/pipeline/rade_text.c | 471 ++++++++++++++++++++------------------- src/pipeline/rade_text.h | 40 ++-- 2 files changed, 264 insertions(+), 247 deletions(-) diff --git a/src/pipeline/rade_text.c b/src/pipeline/rade_text.c index 92c792f0..d1f19c9d 100644 --- a/src/pipeline/rade_text.c +++ b/src/pipeline/rade_text.c @@ -24,10 +24,10 @@ #include #include +#include #include #include #include -#include #include "gp_interleaver.h" #include "ldpc_codes.h" @@ -38,26 +38,26 @@ #define RADE_TEXT_MAX_LENGTH (8) #define RADE_TEXT_CRC_LENGTH (1) -#define RADE_TEXT_MAX_RAW_LENGTH \ - (RADE_TEXT_MAX_LENGTH + RADE_TEXT_CRC_LENGTH) +#define RADE_TEXT_MAX_RAW_LENGTH (RADE_TEXT_MAX_LENGTH + RADE_TEXT_CRC_LENGTH) /* Two bytes of text/CRC equal four bytes of LDPC(112,56). */ #define RADE_TEXT_BYTES_PER_ENCODED_SEGMENT (8) /* Internal definition of rade_text_t. */ -typedef struct { - on_text_rx_t text_rx_callback; - void* callback_state; +typedef struct +{ + on_text_rx_t text_rx_callback; + void *callback_state; - char tx_text[LDPC_TOTAL_SIZE_BITS]; - int tx_text_index; - int tx_text_length; + char tx_text[LDPC_TOTAL_SIZE_BITS]; + int tx_text_index; + int tx_text_length; - COMP inbound_pending_syms[LDPC_TOTAL_SIZE_BITS / 2]; - float inbound_pending_amps[LDPC_TOTAL_SIZE_BITS / 2]; - float incomingData[LDPC_TOTAL_SIZE_BITS]; + COMP inbound_pending_syms[LDPC_TOTAL_SIZE_BITS / 2]; + float inbound_pending_amps[LDPC_TOTAL_SIZE_BITS / 2]; + float incomingData[LDPC_TOTAL_SIZE_BITS]; - struct LDPC ldpc; + struct LDPC ldpc; } rade_text_impl_t; // 6 bit character set for text field use: @@ -66,148 +66,170 @@ typedef struct { // 10-19: ASCII '0'-'9' // 20-46: ASCII 'A'-'Z' // 47: ASCII ' ' -static void convert_callsign_to_ota_string_(const char* input, char* output, - int maxLength) { - assert(input != NULL); - assert(output != NULL); - assert(maxLength >= 0); - - int outidx = 0; - for (size_t index = 0; index < maxLength; index++) { - if (input[index] == 0) break; - - if (input[index] >= 38 && input[index] <= 47) { - output[outidx++] = input[index] - 37; - } else if (input[index] >= '0' && input[index] <= '9') { - output[outidx++] = input[index] - '0' + 10; - } else if (input[index] >= 'A' && input[index] <= 'Z') { - output[outidx++] = input[index] - 'A' + 20; - } else if (input[index] >= 'a' && input[index] <= 'z') { - output[outidx++] = toupper(input[index]) - 'A' + 20; - } - } - output[outidx] = 0; -} +static void convert_callsign_to_ota_string_(const char *input, char *output, int maxLength) +{ + assert(input != NULL); + assert(output != NULL); + assert(maxLength >= 0); -static void convert_ota_string_to_callsign_(const char* input, char* output, - int maxLength) { - assert(input != NULL); - assert(output != NULL); - assert(maxLength >= 0); - - int outidx = 0; - for (size_t index = 0; index < maxLength; index++) { - if (input[index] == 0) break; - - if (input[index] >= 1 && input[index] <= 9) { - output[outidx++] = input[index] + 37; - } else if (input[index] >= 10 && input[index] <= 19) { - output[outidx++] = input[index] - 10 + '0'; - } else if (input[index] >= 20 && input[index] <= 46) { - output[outidx++] = input[index] - 20 + 'A'; + int outidx = 0; + for (size_t index = 0; index < maxLength; index++) + { + if (input[index] == 0) + break; + + if (input[index] >= 38 && input[index] <= 47) + { + output[outidx++] = input[index] - 37; + } + else if (input[index] >= '0' && input[index] <= '9') + { + output[outidx++] = input[index] - '0' + 10; + } + else if (input[index] >= 'A' && input[index] <= 'Z') + { + output[outidx++] = input[index] - 'A' + 20; + } + else if (input[index] >= 'a' && input[index] <= 'z') + { + output[outidx++] = toupper(input[index]) - 'A' + 20; + } } - } - output[outidx] = 0; + output[outidx] = 0; } -static char calculateCRC8_(char* input, int length) { - assert(input != NULL); - assert(length >= 0); +static void convert_ota_string_to_callsign_(const char *input, char *output, int maxLength) +{ + assert(input != NULL); + assert(output != NULL); + assert(maxLength >= 0); - unsigned char generator = 0x1D; - unsigned char crc = 0x00; /* start with 0 so first byte can be 'xored' in */ + int outidx = 0; + for (size_t index = 0; index < maxLength; index++) + { + if (input[index] == 0) + break; - while (length > 0) { - unsigned char ch = *input++; - length--; + if (input[index] >= 1 && input[index] <= 9) + { + output[outidx++] = input[index] + 37; + } + else if (input[index] >= 10 && input[index] <= 19) + { + output[outidx++] = input[index] - 10 + '0'; + } + else if (input[index] >= 20 && input[index] <= 46) + { + output[outidx++] = input[index] - 20 + 'A'; + } + } + output[outidx] = 0; +} - // Break out if we see a null. - if (ch == 0) break; +static char calculateCRC8_(char *input, int length) +{ + assert(input != NULL); + assert(length >= 0); - crc ^= ch; /* XOR-in the next input byte */ + unsigned char generator = 0x1D; + unsigned char crc = 0x00; /* start with 0 so first byte can be 'xored' in */ - for (int i = 0; i < 8; i++) { - if ((crc & 0x80) != 0) { - crc = (unsigned char)((crc << 1) ^ generator); - } else { - crc <<= 1; - } + while (length > 0) + { + unsigned char ch = *input++; + length--; + + // Break out if we see a null. + if (ch == 0) + break; + + crc ^= ch; /* XOR-in the next input byte */ + + for (int i = 0; i < 8; i++) + { + if ((crc & 0x80) != 0) + { + crc = (unsigned char)((crc << 1) ^ generator); + } + else + { + crc <<= 1; + } + } } - } - return crc; + return crc; } -static int rade_text_ldpc_decode(rade_text_impl_t* obj, char* dest, float meanAmplitude) { - assert(obj != NULL); - assert(dest != NULL); +static int rade_text_ldpc_decode(rade_text_impl_t *obj, char *dest, float meanAmplitude) +{ + assert(obj != NULL); + assert(dest != NULL); - float llr[LDPC_TOTAL_SIZE_BITS]; - unsigned char output[LDPC_TOTAL_SIZE_BITS]; - int parityCheckCount = 0; + float llr[LDPC_TOTAL_SIZE_BITS]; + unsigned char output[LDPC_TOTAL_SIZE_BITS]; + int parityCheckCount = 0; - // Use soft decision for the LDPC decoder. - int Npayloadsymsperpacket = LDPC_TOTAL_SIZE_BITS / 2; - float EsNo = 3.0; // note: constant from freedv_700.c - log_info("mean amplitude: %f", meanAmplitude); + // Use soft decision for the LDPC decoder. + int Npayloadsymsperpacket = LDPC_TOTAL_SIZE_BITS / 2; + float EsNo = 3.0; // note: constant from freedv_700.c + log_info("mean amplitude: %f", meanAmplitude); - symbols_to_llrs(llr, (COMP*)obj->inbound_pending_syms, obj->inbound_pending_amps, EsNo, - meanAmplitude, Npayloadsymsperpacket); - run_ldpc_decoder(&obj->ldpc, output, llr, &parityCheckCount); + symbols_to_llrs(llr, (COMP *)obj->inbound_pending_syms, obj->inbound_pending_amps, EsNo, meanAmplitude, + Npayloadsymsperpacket); + run_ldpc_decoder(&obj->ldpc, output, llr, &parityCheckCount); - // Data is valid if BER < 0.2 - float ber_est = (float)(obj->ldpc.NumberParityBits - parityCheckCount) / - obj->ldpc.NumberParityBits; - int result = (ber_est < 0.2); + // Data is valid if BER < 0.2 + float ber_est = (float)(obj->ldpc.NumberParityBits - parityCheckCount) / obj->ldpc.NumberParityBits; + int result = (ber_est < 0.2); - log_info("BER est: %f", ber_est); - if (result) { - memset(dest, 0, RADE_TEXT_BYTES_PER_ENCODED_SEGMENT); + log_info("BER est: %f", ber_est); + if (result) + { + memset(dest, 0, RADE_TEXT_BYTES_PER_ENCODED_SEGMENT); - for (int bitIndex = 0; bitIndex < 8; bitIndex++) { - if (output[bitIndex]) dest[0] |= 1 << bitIndex; - } - for (int bitIndex = 8; bitIndex < (LDPC_TOTAL_SIZE_BITS / 2); bitIndex++) { - int bitsSinceCrc = bitIndex - 8; - if (output[bitIndex]) - dest[1 + (bitsSinceCrc / 6)] |= (1 << (bitsSinceCrc % 6)); + for (int bitIndex = 0; bitIndex < 8; bitIndex++) + { + if (output[bitIndex]) + dest[0] |= 1 << bitIndex; + } + for (int bitIndex = 8; bitIndex < (LDPC_TOTAL_SIZE_BITS / 2); bitIndex++) + { + int bitsSinceCrc = bitIndex - 8; + if (output[bitIndex]) + dest[1 + (bitsSinceCrc / 6)] |= (1 << (bitsSinceCrc % 6)); + } } - } - return result; + return result; } /* Decode received symbols from RADE decoder. */ -void rade_text_rx(rade_text_t ptr, float* syms, int symSize) +void rade_text_rx(rade_text_t ptr, float *syms, int symSize) { - rade_text_impl_t* obj = (rade_text_impl_t*)ptr; + rade_text_impl_t *obj = (rade_text_impl_t *)ptr; assert(obj != NULL); - gp_deinterleave_comp( - (COMP*)obj->inbound_pending_syms, - (COMP*)syms, - LDPC_TOTAL_SIZE_BITS / 2); + gp_deinterleave_comp((COMP *)obj->inbound_pending_syms, (COMP *)syms, LDPC_TOTAL_SIZE_BITS / 2); // Calculate RMS of all symbols float rms = 0; for (int index = 0; index < symSize; index++) { - COMP* sym = (COMP*)&obj->inbound_pending_syms[index]; + COMP *sym = (COMP *)&obj->inbound_pending_syms[index]; rms += sym->real * sym->real + sym->imag * sym->imag; } - rms = sqrt(rms/symSize); + rms = sqrt(rms / symSize); // Copy over symbols prior to decode. for (int index = 0; index < LDPC_TOTAL_SIZE_BITS / 2; index++) { - COMP* sym = (COMP*)&obj->inbound_pending_syms[index]; + COMP *sym = (COMP *)&obj->inbound_pending_syms[index]; log_debug("RX symbol: %f, %f", sym->real, sym->imag); - obj->inbound_pending_amps[index] = rms; - log_debug("RX symbol rotated: %f, %f, amp: %f", - obj->inbound_pending_syms[index].real, - obj->inbound_pending_syms[index].imag, - obj->inbound_pending_amps[index]); + obj->inbound_pending_amps[index] = rms; + log_debug("RX symbol rotated: %f, %f, amp: %f", obj->inbound_pending_syms[index].real, + obj->inbound_pending_syms[index].imag, obj->inbound_pending_amps[index]); } // We have all the bits we need, so we're ready to decode. @@ -216,145 +238,142 @@ void rade_text_rx(rade_text_t ptr, float* syms, int symSize) memset(rawStr, 0, RADE_TEXT_MAX_RAW_LENGTH + 1); memset(decodedStr, 0, RADE_TEXT_MAX_RAW_LENGTH + 1); - if (rade_text_ldpc_decode(obj, rawStr, rms) != 0) { + if (rade_text_ldpc_decode(obj, rawStr, rms) != 0) + { // BER is under limits. - convert_ota_string_to_callsign_(&rawStr[RADE_TEXT_CRC_LENGTH], - &decodedStr[RADE_TEXT_CRC_LENGTH], + convert_ota_string_to_callsign_(&rawStr[RADE_TEXT_CRC_LENGTH], &decodedStr[RADE_TEXT_CRC_LENGTH], RADE_TEXT_MAX_LENGTH); - decodedStr[0] = rawStr[0]; // CRC + decodedStr[0] = rawStr[0]; // CRC // Get expected and actual CRC. unsigned char receivedCRC = decodedStr[0]; - unsigned char calcCRC = calculateCRC8_( - &rawStr[RADE_TEXT_CRC_LENGTH], RADE_TEXT_MAX_LENGTH); + unsigned char calcCRC = calculateCRC8_(&rawStr[RADE_TEXT_CRC_LENGTH], RADE_TEXT_MAX_LENGTH); - log_info("rxCRC: %d, calcCRC: %d, decodedStr: %s", - receivedCRC, calcCRC, &decodedStr[RADE_TEXT_CRC_LENGTH]); + log_info("rxCRC: %d, calcCRC: %d, decodedStr: %s", receivedCRC, calcCRC, &decodedStr[RADE_TEXT_CRC_LENGTH]); - if (receivedCRC == calcCRC && obj->text_rx_callback) { - // We got a valid string. Call assigned callback. - obj->text_rx_callback(obj, &decodedStr[RADE_TEXT_CRC_LENGTH], - strlen(&decodedStr[RADE_TEXT_CRC_LENGTH]), - obj->callback_state); + if (receivedCRC == calcCRC && obj->text_rx_callback) + { + // We got a valid string. Call assigned callback. + obj->text_rx_callback(obj, &decodedStr[RADE_TEXT_CRC_LENGTH], strlen(&decodedStr[RADE_TEXT_CRC_LENGTH]), + obj->callback_state); } - } + } } -rade_text_t rade_text_create() { - rade_text_impl_t* ret = calloc(1, sizeof(rade_text_impl_t)); - assert(ret != NULL); +rade_text_t rade_text_create() +{ + rade_text_impl_t *ret = calloc(1, sizeof(rade_text_impl_t)); + assert(ret != NULL); - // Load LDPC code into memory. - int code_index = ldpc_codes_find("HRA_56_56"); - memcpy(&ret->ldpc, &ldpc_codes[code_index], sizeof(struct LDPC)); + // Load LDPC code into memory. + int code_index = ldpc_codes_find("HRA_56_56"); + memcpy(&ret->ldpc, &ldpc_codes[code_index], sizeof(struct LDPC)); - return (rade_text_t)ret; + return (rade_text_t)ret; } -void rade_text_destroy(rade_text_t ptr) { - assert(ptr != NULL); - free(ptr); +void rade_text_destroy(rade_text_t ptr) +{ + assert(ptr != NULL); + free(ptr); } -void rade_text_generate_tx_string( - rade_text_t ptr, const char* str, int strlength, - float* syms) +void rade_text_generate_tx_string(rade_text_t ptr, const char *str, int strlength, float *syms) { - rade_text_impl_t* impl = (rade_text_impl_t*)ptr; - assert(impl != NULL); - - char tmp[RADE_TEXT_MAX_RAW_LENGTH + 1]; - memset(tmp, 0, RADE_TEXT_MAX_RAW_LENGTH + 1); - - convert_callsign_to_ota_string_(str, &tmp[RADE_TEXT_CRC_LENGTH], - strlength < RADE_TEXT_MAX_LENGTH - ? strlength - : RADE_TEXT_MAX_LENGTH); - - int txt_length = strlen(&tmp[RADE_TEXT_CRC_LENGTH]); - if (txt_length >= RADE_TEXT_MAX_LENGTH) { - txt_length = RADE_TEXT_MAX_LENGTH; - } - impl->tx_text_length = LDPC_TOTAL_SIZE_BITS; - impl->tx_text_index = 0; - unsigned char crc = - calculateCRC8_(&tmp[RADE_TEXT_CRC_LENGTH], txt_length); - tmp[0] = crc; - - // Encode block of text using LDPC(112,56). - unsigned char ibits[LDPC_TOTAL_SIZE_BITS / 2]; - unsigned char pbits[LDPC_TOTAL_SIZE_BITS / 2]; - memset(ibits, 0, LDPC_TOTAL_SIZE_BITS / 2); - memset(pbits, 0, LDPC_TOTAL_SIZE_BITS / 2); - for (int index = 0; index < 8; index++) { - if (tmp[0] & (1 << index)) ibits[index] = 1; - } - - // Pack 6 bit characters into single LDPC block. - for (int ibitsBitIndex = 8; ibitsBitIndex < (LDPC_TOTAL_SIZE_BITS / 2); - ibitsBitIndex++) { - int bitsFromCrc = ibitsBitIndex - 8; - unsigned int byte = tmp[RADE_TEXT_CRC_LENGTH + bitsFromCrc / 6]; - unsigned int bitToCheck = bitsFromCrc % 6; - // fprintf(stderr, "bit index: %d, byte: %x, bit to check: %d, result: - // %d\n", ibitsBitIndex, byte, bitToCheck, (byte & (1 << bitToCheck)) != 0); - - if (byte & (1 << bitToCheck)) { - ibits[ibitsBitIndex] = 1; - } - } - - encode(&impl->ldpc, ibits, pbits); - - // Split LDPC encoded bits into individual bits, with the first - // RADE_TEXT_UW_LENGTH_BITS being UW. - char tmpbits[LDPC_TOTAL_SIZE_BITS]; - - memset(impl->tx_text, 0, LDPC_TOTAL_SIZE_BITS); - memcpy(&tmpbits[0], &ibits[0], LDPC_TOTAL_SIZE_BITS / 2); - memcpy(&tmpbits[LDPC_TOTAL_SIZE_BITS / 2], &pbits[0], - LDPC_TOTAL_SIZE_BITS / 2); - - // Interleave the bits together to enhance fading performance. - memcpy(impl->tx_text, tmpbits, LDPC_TOTAL_SIZE_BITS); - gp_interleave_bits(&impl->tx_text[0], tmpbits, - LDPC_TOTAL_SIZE_BITS / 2); - - // Generate floats based on the bits. - char debugString[256]; - for (int index = 0; index < LDPC_TOTAL_SIZE_BITS / 2; index++) - { - char* ptr = &impl->tx_text[2 * index]; - if (*ptr == 0 && *(ptr + 1) == 0) + rade_text_impl_t *impl = (rade_text_impl_t *)ptr; + assert(impl != NULL); + + char tmp[RADE_TEXT_MAX_RAW_LENGTH + 1]; + memset(tmp, 0, RADE_TEXT_MAX_RAW_LENGTH + 1); + + convert_callsign_to_ota_string_(str, &tmp[RADE_TEXT_CRC_LENGTH], + strlength < RADE_TEXT_MAX_LENGTH ? strlength : RADE_TEXT_MAX_LENGTH); + + int txt_length = strlen(&tmp[RADE_TEXT_CRC_LENGTH]); + if (txt_length >= RADE_TEXT_MAX_LENGTH) { - syms[2*index] = 1; - syms[2*index + 1] = 0; + txt_length = RADE_TEXT_MAX_LENGTH; } - else if (*ptr == 0 && *(ptr + 1) == 1) + impl->tx_text_length = LDPC_TOTAL_SIZE_BITS; + impl->tx_text_index = 0; + unsigned char crc = calculateCRC8_(&tmp[RADE_TEXT_CRC_LENGTH], txt_length); + tmp[0] = crc; + + // Encode block of text using LDPC(112,56). + unsigned char ibits[LDPC_TOTAL_SIZE_BITS / 2]; + unsigned char pbits[LDPC_TOTAL_SIZE_BITS / 2]; + memset(ibits, 0, LDPC_TOTAL_SIZE_BITS / 2); + memset(pbits, 0, LDPC_TOTAL_SIZE_BITS / 2); + for (int index = 0; index < 8; index++) { - syms[2*index] = 0; - syms[2*index + 1] = 1; + if (tmp[0] & (1 << index)) + ibits[index] = 1; } - else if (*ptr == 1 && *(ptr + 1) == 0) + + // Pack 6 bit characters into single LDPC block. + for (int ibitsBitIndex = 8; ibitsBitIndex < (LDPC_TOTAL_SIZE_BITS / 2); ibitsBitIndex++) { - syms[2*index] = 0; - syms[2*index + 1] = -1; + int bitsFromCrc = ibitsBitIndex - 8; + unsigned int byte = tmp[RADE_TEXT_CRC_LENGTH + bitsFromCrc / 6]; + unsigned int bitToCheck = bitsFromCrc % 6; + // fprintf(stderr, "bit index: %d, byte: %x, bit to check: %d, result: + // %d\n", ibitsBitIndex, byte, bitToCheck, (byte & (1 << bitToCheck)) != 0); + + if (byte & (1 << bitToCheck)) + { + ibits[ibitsBitIndex] = 1; + } } - else if (*ptr == 1 && *(ptr + 1) == 1) + + encode(&impl->ldpc, ibits, pbits); + + // Split LDPC encoded bits into individual bits, with the first + // RADE_TEXT_UW_LENGTH_BITS being UW. + char tmpbits[LDPC_TOTAL_SIZE_BITS]; + + memset(impl->tx_text, 0, LDPC_TOTAL_SIZE_BITS); + memcpy(&tmpbits[0], &ibits[0], LDPC_TOTAL_SIZE_BITS / 2); + memcpy(&tmpbits[LDPC_TOTAL_SIZE_BITS / 2], &pbits[0], LDPC_TOTAL_SIZE_BITS / 2); + + // Interleave the bits together to enhance fading performance. + memcpy(impl->tx_text, tmpbits, LDPC_TOTAL_SIZE_BITS); + gp_interleave_bits(&impl->tx_text[0], tmpbits, LDPC_TOTAL_SIZE_BITS / 2); + + // Generate floats based on the bits. + char debugString[256]; + for (int index = 0; index < LDPC_TOTAL_SIZE_BITS / 2; index++) { - syms[2*index] = -1; - syms[2*index + 1] = 0; + char *ptr = &impl->tx_text[2 * index]; + if (*ptr == 0 && *(ptr + 1) == 0) + { + syms[2 * index] = 1; + syms[2 * index + 1] = 0; + } + else if (*ptr == 0 && *(ptr + 1) == 1) + { + syms[2 * index] = 0; + syms[2 * index + 1] = 1; + } + else if (*ptr == 1 && *(ptr + 1) == 0) + { + syms[2 * index] = 0; + syms[2 * index + 1] = -1; + } + else if (*ptr == 1 && *(ptr + 1) == 1) + { + syms[2 * index] = -1; + syms[2 * index + 1] = 0; + } + debugString[2 * index] = impl->tx_text[2 * index] ? '1' : '0'; + debugString[2 * index + 1] = impl->tx_text[2 * index + 1] ? '1' : '0'; } - debugString[2*index] = impl->tx_text[2*index] ? '1' : '0'; - debugString[2*index + 1] = impl->tx_text[2*index + 1] ? '1' : '0'; - } - debugString[LDPC_TOTAL_SIZE_BITS] = 0; - log_debug("generated bits: %s", debugString); + debugString[LDPC_TOTAL_SIZE_BITS] = 0; + log_debug("generated bits: %s", debugString); } -void rade_text_set_rx_callback(rade_text_t ptr, on_text_rx_t text_rx_fn, void* state) +void rade_text_set_rx_callback(rade_text_t ptr, on_text_rx_t text_rx_fn, void *state) { - rade_text_impl_t* impl = (rade_text_impl_t*)ptr; + rade_text_impl_t *impl = (rade_text_impl_t *)ptr; assert(impl != NULL); impl->text_rx_callback = text_rx_fn; diff --git a/src/pipeline/rade_text.h b/src/pipeline/rade_text.h index 28c8cfa9..85ad16f6 100644 --- a/src/pipeline/rade_text.h +++ b/src/pipeline/rade_text.h @@ -24,35 +24,33 @@ #define RADE_TEXT_H #ifdef __cplusplus -extern "C" { -#endif // __cplusplus +extern "C" +{ +#endif // __cplusplus -/* Hide internals of rade_text_t. */ -typedef void* rade_text_t; + /* Hide internals of rade_text_t. */ + typedef void *rade_text_t; -/* Function type for callback (when full reliable text has been received). */ -typedef void (*on_text_rx_t)(rade_text_t rt, const char* txt_ptr, - int length, void* state); + /* Function type for callback (when full reliable text has been received). */ + typedef void (*on_text_rx_t)(rade_text_t rt, const char *txt_ptr, int length, void *state); -/* Allocate rade_text object. */ -rade_text_t rade_text_create(); + /* Allocate rade_text object. */ + rade_text_t rade_text_create(); -/* Destroy rade_text object. */ -void rade_text_destroy(rade_text_t ptr); + /* Destroy rade_text object. */ + void rade_text_destroy(rade_text_t ptr); -/* Generates float array for use with RADE EOO functions. */ -void rade_text_generate_tx_string( - rade_text_t ptr, const char* str, int strlength, - float* syms); + /* Generates float array for use with RADE EOO functions. */ + void rade_text_generate_tx_string(rade_text_t ptr, const char *str, int strlength, float *syms); -/* Set text RX callback. */ -void rade_text_set_rx_callback(rade_text_t ptr, on_text_rx_t text_rx_fn, void* state); + /* Set text RX callback. */ + void rade_text_set_rx_callback(rade_text_t ptr, on_text_rx_t text_rx_fn, void *state); -/* Decode received symbols from RADE decoder. */ -void rade_text_rx(rade_text_t ptr, float* syms, int symSize); + /* Decode received symbols from RADE decoder. */ + void rade_text_rx(rade_text_t ptr, float *syms, int symSize); #ifdef __cplusplus } -#endif // __cplusplus +#endif // __cplusplus -#endif // RADE_TEXT_H \ No newline at end of file +#endif // RADE_TEXT_H \ No newline at end of file