2022-02-27 20:21:14 +01:00
|
|
|
#include <linux/if.h>
|
2021-10-17 19:26:38 +02:00
|
|
|
#include <stdio.h>
|
2022-03-05 21:38:05 +01:00
|
|
|
#include <stdlib.h>
|
2022-02-27 22:01:51 +01:00
|
|
|
#include <ctype.h>
|
2024-04-27 12:22:33 +02:00
|
|
|
#include <string.h>
|
2022-02-27 22:01:51 +01:00
|
|
|
|
2021-10-17 19:26:38 +02:00
|
|
|
#include <liquid/liquid.h>
|
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
#include <sys/poll.h>
|
2022-02-27 20:21:14 +01:00
|
|
|
#include <unistd.h>
|
2022-03-05 21:38:05 +01:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <poll.h>
|
2024-01-03 22:03:19 +01:00
|
|
|
#include <signal.h>
|
2022-02-27 20:21:14 +01:00
|
|
|
|
2021-10-17 19:26:38 +02:00
|
|
|
#include "utils.h"
|
2024-03-30 21:50:54 +01:00
|
|
|
#include "options.h"
|
2024-05-05 18:09:00 +02:00
|
|
|
#include "jsonlogger.h"
|
|
|
|
#include "debug_structs.h"
|
|
|
|
|
2022-02-13 21:29:35 +01:00
|
|
|
#include "layer1/tx.h"
|
2022-02-16 20:52:46 +01:00
|
|
|
#include "layer1/rx.h"
|
2022-02-13 21:29:35 +01:00
|
|
|
|
2022-02-27 20:21:14 +01:00
|
|
|
#include "layer2/tundev.h"
|
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
#include "sdr/sdr.h"
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2022-02-13 21:29:35 +01:00
|
|
|
#define RESULT_CHECK(stmt) { \
|
|
|
|
result_t res = stmt; \
|
|
|
|
if(res != OK) { \
|
2022-04-03 18:11:52 +02:00
|
|
|
fprintf(stderr, "Error %d in %s:%d!\n", res, __FILE__, __LINE__); \
|
2022-02-13 21:29:35 +01:00
|
|
|
exit(1); \
|
|
|
|
} \
|
|
|
|
}
|
2022-02-01 21:35:43 +01:00
|
|
|
|
2022-02-27 20:21:14 +01:00
|
|
|
static int m_tunfd = -1;
|
|
|
|
static bool m_running = true;
|
|
|
|
|
2022-05-07 21:17:53 +02:00
|
|
|
static double next_tx_switch_time = 0.0;
|
|
|
|
|
2024-05-05 18:09:00 +02:00
|
|
|
static rx_stats_t m_rx_stats;
|
2022-05-07 21:17:53 +02:00
|
|
|
|
2024-01-03 22:03:19 +01:00
|
|
|
static void signal_handler(int signal, siginfo_t *info, void *ctx)
|
|
|
|
{
|
|
|
|
(void)signal;
|
|
|
|
(void)info;
|
|
|
|
(void)ctx;
|
|
|
|
|
|
|
|
fprintf(stderr, "\nGracefully shutting down on signal %d.\n", signal);
|
|
|
|
|
|
|
|
m_running = false;
|
|
|
|
}
|
|
|
|
|
2022-05-07 21:17:53 +02:00
|
|
|
static void block_tx_for(unsigned offset_ms)
|
|
|
|
{
|
|
|
|
next_tx_switch_time = get_hires_time() + (double)offset_ms * 0.001;
|
|
|
|
}
|
|
|
|
|
2022-02-03 22:18:24 +01:00
|
|
|
void print_complex_array(const char *varname, float complex const *array, size_t len)
|
|
|
|
{
|
2022-02-16 21:46:56 +01:00
|
|
|
fprintf(stderr, "%s=np.array([%f%+fj", varname, crealf(array[0]), cimagf(array[0]));
|
2022-02-03 22:18:24 +01:00
|
|
|
for(size_t k = 1; k < len; k++) {
|
2022-02-16 21:46:56 +01:00
|
|
|
fprintf(stderr, ", %f%+fj", crealf(array[k]), cimagf(array[k]));
|
2022-02-03 22:18:24 +01:00
|
|
|
}
|
2022-02-16 21:46:56 +01:00
|
|
|
fprintf(stderr, "])\n");
|
2022-02-03 22:18:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-27 22:01:51 +01:00
|
|
|
void hexdump(const uint8_t *data, size_t len)
|
|
|
|
{
|
|
|
|
static const char lut[16] = "0123456789ABCDEF";
|
|
|
|
static const size_t BYTES_PER_LINE = 16;
|
|
|
|
|
|
|
|
size_t pos = 0;
|
|
|
|
|
|
|
|
while(pos < len) {
|
|
|
|
size_t bytes_in_line = len - pos;
|
|
|
|
if(bytes_in_line > BYTES_PER_LINE) {
|
|
|
|
bytes_in_line = BYTES_PER_LINE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(size_t i = 0; i < BYTES_PER_LINE; i++) {
|
|
|
|
if(i >= bytes_in_line) {
|
|
|
|
fputs(" ", stderr);
|
|
|
|
} else {
|
|
|
|
uint8_t byte = data[pos+i];
|
|
|
|
|
|
|
|
fprintf(stderr, "%c%c ", lut[byte >> 4], lut[byte & 0x0F]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs(" ", stderr);
|
|
|
|
|
|
|
|
for(size_t i = 0; i < bytes_in_line; i++) {
|
|
|
|
uint8_t byte = data[pos+i];
|
|
|
|
|
|
|
|
if(isprint(byte)) {
|
|
|
|
putc(byte, stderr);
|
|
|
|
} else {
|
|
|
|
putc('.', stderr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
putc('\n', stderr);
|
|
|
|
pos += bytes_in_line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-16 20:52:46 +01:00
|
|
|
void cb_rx(rx_evt_t evt, uint8_t *packet_data, size_t packet_len)
|
2022-02-12 21:58:53 +01:00
|
|
|
{
|
2022-02-27 20:21:14 +01:00
|
|
|
int ret;
|
|
|
|
|
2022-02-16 20:52:46 +01:00
|
|
|
switch(evt)
|
|
|
|
{
|
|
|
|
case RX_EVT_CHECKSUM_ERROR:
|
2024-01-02 19:04:19 +01:00
|
|
|
//fprintf(stderr, "Received a message of %zu bytes, but decoding failed.\n", packet_len);
|
2022-02-27 20:21:14 +01:00
|
|
|
//fprintf(stderr, "=== FAILED PAYLOAD ===\n");
|
2022-02-27 22:01:51 +01:00
|
|
|
//hexdump(packet_data, packet_len);
|
2022-02-27 20:21:14 +01:00
|
|
|
//fprintf(stderr, "=======================\n");
|
2024-05-05 18:09:00 +02:00
|
|
|
m_rx_stats.failed_decodes++;
|
2022-02-16 20:52:46 +01:00
|
|
|
break;
|
|
|
|
|
2024-01-05 21:28:38 +01:00
|
|
|
case RX_EVT_HEADER_ERROR:
|
2024-05-05 18:09:00 +02:00
|
|
|
m_rx_stats.header_errors++;
|
2024-01-05 21:28:38 +01:00
|
|
|
break;
|
|
|
|
|
2022-02-16 20:52:46 +01:00
|
|
|
case RX_EVT_PACKET_RECEIVED:
|
2024-01-02 19:04:19 +01:00
|
|
|
//fprintf(stderr, "A message of %zu bytes was decoded successfully.\n", packet_len);
|
2022-05-07 21:17:53 +02:00
|
|
|
//fprintf(stderr, "=== DECODED PAYLOAD (%4zu bytes) ===\n", packet_len);
|
|
|
|
//hexdump(packet_data, packet_len < 64 ? packet_len : 64);
|
|
|
|
//fprintf(stderr, "====================================\n");
|
|
|
|
|
2024-05-05 18:09:00 +02:00
|
|
|
m_rx_stats.successful_decodes++;
|
2024-01-02 19:04:19 +01:00
|
|
|
|
2022-05-07 21:17:53 +02:00
|
|
|
block_tx_for(TX_SWITCH_BACKOFF_END_OF_PACKET_MS);
|
2022-02-27 20:21:14 +01:00
|
|
|
|
|
|
|
ret = write(m_tunfd, packet_data, packet_len);
|
|
|
|
if(ret < 0) {
|
|
|
|
perror("write");
|
|
|
|
}
|
2022-02-16 20:52:46 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RX_EVT_PREAMBLE_FOUND:
|
2024-01-02 19:04:19 +01:00
|
|
|
//fprintf(stderr, "Found preamble!\n");
|
2022-05-07 21:17:53 +02:00
|
|
|
block_tx_for(TX_SWITCH_BACKOFF_PREAMBLE_MS);
|
2024-05-05 18:09:00 +02:00
|
|
|
m_rx_stats.preambles_found++;
|
2022-02-16 20:52:46 +01:00
|
|
|
break;
|
|
|
|
}
|
2024-05-05 18:09:00 +02:00
|
|
|
|
|
|
|
jsonlogger_log_rx_stats(&m_rx_stats);
|
2022-02-12 21:58:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
static int debug_fd;
|
|
|
|
|
2024-04-20 00:55:39 +02:00
|
|
|
static result_t transmit(sdr_ctx_t *sdr, const float complex *samples, size_t len)
|
2022-03-05 21:38:05 +01:00
|
|
|
{
|
2024-04-20 00:55:39 +02:00
|
|
|
size_t to_transmit_rf = len * SDR_OVERSAMPLING;
|
|
|
|
float complex rf_samples[to_transmit_rf];
|
2022-03-05 21:38:05 +01:00
|
|
|
|
2024-04-20 00:55:39 +02:00
|
|
|
RESULT_CHECK(sdr_baseband_to_rf(sdr, samples, len, rf_samples, &to_transmit_rf));
|
2022-03-05 21:38:05 +01:00
|
|
|
|
2024-04-20 00:55:39 +02:00
|
|
|
result_t result = sdr_transmit(sdr, rf_samples, to_transmit_rf, 100000);
|
2022-03-05 21:38:05 +01:00
|
|
|
|
2024-04-20 00:55:39 +02:00
|
|
|
fprintf(stderr, "t");
|
|
|
|
return result;
|
2022-03-05 21:38:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-03-30 21:50:54 +01:00
|
|
|
int main(int argc, char **argv)
|
2021-10-17 19:26:38 +02:00
|
|
|
{
|
2022-02-13 21:29:35 +01:00
|
|
|
layer1_tx_t tx;
|
2022-02-27 20:21:14 +01:00
|
|
|
layer1_rx_t rx;
|
2022-02-13 21:29:35 +01:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
sdr_ctx_t sdr;
|
|
|
|
|
2024-03-30 21:50:54 +01:00
|
|
|
int parsed_options = options_parse(argc, argv);
|
|
|
|
fprintf(stderr, "%d options parsed.\n", parsed_options);
|
|
|
|
if(parsed_options < 0) {
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2024-05-05 18:09:00 +02:00
|
|
|
if(!jsonlogger_init("jsonlog.fifo")) {
|
|
|
|
fprintf(stderr, "Could not initialize JSON logger.\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2022-05-07 20:10:55 +02:00
|
|
|
bool on_air = true;
|
2022-03-05 21:38:05 +01:00
|
|
|
|
|
|
|
debug_fd = open("/tmp/dump.cf32", O_CREAT | O_WRONLY | O_TRUNC);
|
|
|
|
|
2022-02-27 20:21:14 +01:00
|
|
|
// ** Initialize **
|
2022-02-13 21:29:35 +01:00
|
|
|
|
2022-02-27 20:21:14 +01:00
|
|
|
char devname[IFNAMSIZ] = "hamnet70";
|
|
|
|
m_tunfd = tundev_open(devname);
|
2022-02-13 21:29:35 +01:00
|
|
|
|
2022-02-27 20:21:14 +01:00
|
|
|
if(m_tunfd < 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
2022-02-13 21:29:35 +01:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
RESULT_CHECK(sdr_init(&sdr));
|
|
|
|
|
2022-02-27 20:21:14 +01:00
|
|
|
RESULT_CHECK(layer1_tx_init(&tx));
|
|
|
|
RESULT_CHECK(layer1_rx_init(&rx, cb_rx));
|
2021-10-17 19:26:38 +02:00
|
|
|
|
2024-01-03 22:03:19 +01:00
|
|
|
// ** Set up signal handling
|
|
|
|
|
|
|
|
struct sigaction term_action = {0};
|
|
|
|
term_action.sa_sigaction = signal_handler;
|
|
|
|
|
|
|
|
if(sigaction(SIGTERM, &term_action, NULL) < 0) {
|
|
|
|
perror("sigaction");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(sigaction(SIGINT, &term_action, NULL) < 0) {
|
|
|
|
perror("sigaction");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2022-02-27 20:21:14 +01:00
|
|
|
// ** Process packets **
|
2021-10-17 19:26:38 +02:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
struct pollfd pfd;
|
|
|
|
memset(&pfd, 0, sizeof(pfd));
|
2021-10-17 19:26:38 +02:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
pfd.fd = m_tunfd;
|
|
|
|
pfd.events = POLLIN;
|
2022-02-27 16:59:14 +01:00
|
|
|
|
2022-05-07 20:10:55 +02:00
|
|
|
// start in TX mode to work around SoapyHackRF not setting the correct frequency.
|
|
|
|
RESULT_CHECK(sdr_start_tx(&sdr, 1));
|
2022-02-27 16:59:14 +01:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
unsigned rx_retries = 0;
|
2021-10-17 19:26:38 +02:00
|
|
|
|
2023-05-17 22:28:18 +02:00
|
|
|
double old = get_hires_time();
|
|
|
|
size_t total_samples = 0;
|
2024-01-02 19:04:19 +01:00
|
|
|
double next_stats_print_time = old + 0.5;
|
2023-05-17 22:28:18 +02:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
while(m_running) {
|
2022-05-07 21:17:53 +02:00
|
|
|
double now = get_hires_time();
|
|
|
|
|
|
|
|
if((now > next_tx_switch_time) && (on_air || !layer1_rx_is_busy(&rx))) {
|
2022-03-05 21:38:05 +01:00
|
|
|
int ret = poll(&pfd, 1, 0);
|
|
|
|
if(ret < 0) {
|
|
|
|
perror("poll");
|
|
|
|
break;
|
|
|
|
} else if(ret > 0) {
|
|
|
|
// there is a packet to be read.
|
2024-01-05 14:13:11 +01:00
|
|
|
|
|
|
|
// check free buffer space (50 ms required corresponding to 5000 baseband symbols)
|
|
|
|
size_t buffer_free_space_samples = sdr_get_tx_buffer_free_space(&sdr);
|
|
|
|
|
|
|
|
fprintf(stderr, "TX buffer free: %zu\n", buffer_free_space_samples);
|
|
|
|
|
2024-04-20 01:04:13 +02:00
|
|
|
if(buffer_free_space_samples < 400000) { // sample count for 200 ms at 2 MHz
|
2024-01-05 14:13:11 +01:00
|
|
|
// try again after a short delay
|
|
|
|
fsleep(10e-3);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
uint8_t packetbuf[2048];
|
|
|
|
ret = read(m_tunfd, packetbuf, sizeof(packetbuf));
|
|
|
|
if(ret < 0) {
|
|
|
|
perror("read");
|
|
|
|
break;
|
|
|
|
} else if(ret == 0) {
|
|
|
|
// no more data
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "Transmitting packet with %d bytes.\n", ret);
|
|
|
|
|
|
|
|
RESULT_CHECK(layer1_tx_reset(&tx));
|
|
|
|
|
|
|
|
// ** Modulate packet **
|
|
|
|
|
|
|
|
RESULT_CHECK(layer1_tx_add_packet_to_burst(&tx, packetbuf, ret));
|
|
|
|
RESULT_CHECK(layer1_tx_finalize_burst(&tx));
|
|
|
|
|
|
|
|
size_t burst_len = layer1_tx_get_sample_count(&tx);
|
|
|
|
const float complex *whole_burst = layer1_tx_get_sample_data(&tx);
|
|
|
|
|
|
|
|
dump_array_cf(whole_burst, burst_len, 1.0f, "/tmp/tx.cpx");
|
|
|
|
|
2024-01-03 00:33:54 +01:00
|
|
|
// ensure that the buffer is full before TX is turned on to avoid transmitting empty buffers
|
2024-04-20 00:55:39 +02:00
|
|
|
RESULT_CHECK(transmit(&sdr, whole_burst, burst_len));
|
2024-01-03 00:33:54 +01:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
if(!on_air) {
|
2024-04-20 00:55:39 +02:00
|
|
|
size_t buffer_used_samples = sdr_get_tx_buffer_used_space(&sdr);
|
|
|
|
const size_t min_required_samples = 4*128*1024;
|
|
|
|
|
|
|
|
int ret2 = poll(&pfd, 1, 0);
|
|
|
|
if(ret2 < 0) {
|
|
|
|
perror("poll");
|
|
|
|
break;
|
|
|
|
} else if(ret2 != 0 && (buffer_used_samples < min_required_samples)) {
|
|
|
|
// enqueue more packets before starting TX
|
|
|
|
fprintf(stderr, "Pre-buffering more packets: %zd / %zd samples.\n", buffer_used_samples, min_required_samples);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "RX -> TX\n");
|
2024-01-02 23:49:55 +01:00
|
|
|
RESULT_CHECK(sdr_stop_rx(&sdr));
|
2024-03-31 22:23:04 +02:00
|
|
|
|
|
|
|
// transmit packets on the frequency where the last packet was received.
|
|
|
|
layer1_tx_set_carrier_frequency_offset(&tx, layer1_rx_get_coarse_carrier_frequency(&rx));
|
|
|
|
|
2022-04-03 18:11:52 +02:00
|
|
|
RESULT_CHECK(sdr_start_tx(&sdr, burst_len * SDR_OVERSAMPLING));
|
2022-03-05 21:38:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
on_air = true;
|
|
|
|
} else if(on_air) { // ret == 0
|
2024-04-20 00:55:39 +02:00
|
|
|
fprintf(stderr, "TX -> RX\n");
|
2024-01-03 00:25:55 +01:00
|
|
|
RESULT_CHECK(sdr_flush_tx_buffer(&sdr));
|
2022-04-03 18:11:52 +02:00
|
|
|
|
2024-01-02 23:49:55 +01:00
|
|
|
RESULT_CHECK(sdr_stop_tx(&sdr));
|
|
|
|
RESULT_CHECK(sdr_start_rx(&sdr));
|
2022-04-03 18:11:52 +02:00
|
|
|
on_air = false;
|
2022-05-07 21:17:53 +02:00
|
|
|
|
|
|
|
block_tx_for(TX_SWITCH_BACKOFF_AFTER_RX_ON);
|
2022-03-05 21:38:05 +01:00
|
|
|
}
|
|
|
|
}
|
2022-01-30 20:05:20 +01:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
if(!on_air) {
|
|
|
|
// ** Receive signal **
|
2022-02-27 20:21:14 +01:00
|
|
|
|
2024-04-20 01:31:21 +02:00
|
|
|
const size_t CHUNKSIZE_BB = 16384;
|
|
|
|
const size_t CHUNKSIZE_RF = (CHUNKSIZE_BB * SDR_OVERSAMPLING);
|
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
float complex rf_samples[CHUNKSIZE_RF];
|
|
|
|
float complex bb_samples[CHUNKSIZE_BB];
|
2022-01-30 20:05:20 +01:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
size_t n_rf_samples = CHUNKSIZE_RF;
|
2024-01-02 23:49:55 +01:00
|
|
|
size_t n_bb_samples = CHUNKSIZE_BB;
|
2022-02-27 20:21:14 +01:00
|
|
|
|
2024-04-27 20:08:04 +02:00
|
|
|
if(sdr_receive(&sdr, rf_samples, &n_rf_samples, 100000, SDR_OVERSAMPLING) != OK) {
|
2022-03-05 21:38:05 +01:00
|
|
|
rx_retries++;
|
|
|
|
fprintf(stderr, "sdr_receive() failed %d times.\n", rx_retries);
|
|
|
|
if(rx_retries >= 3) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2022-02-27 20:21:14 +01:00
|
|
|
|
2024-01-02 23:49:55 +01:00
|
|
|
if(n_rf_samples == 0) {
|
2024-01-03 17:29:51 +01:00
|
|
|
fsleep(1e-3);
|
2024-01-02 23:49:55 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-05-17 22:28:18 +02:00
|
|
|
total_samples += n_rf_samples;
|
|
|
|
|
2023-05-20 22:01:26 +02:00
|
|
|
double new = get_hires_time();
|
2024-01-02 19:04:19 +01:00
|
|
|
if(new >= next_stats_print_time) {
|
2023-05-20 22:01:26 +02:00
|
|
|
double rate = total_samples / (new - old);
|
|
|
|
fprintf(stderr, "\nEstimated rate: %.3f MS/s\n", rate / 1e6);
|
2024-01-02 19:04:19 +01:00
|
|
|
fprintf(stderr, "Receiver statistics:\n");
|
2024-05-05 18:09:00 +02:00
|
|
|
fprintf(stderr, " Preambles found: %8zd\n", m_rx_stats.preambles_found);
|
2024-01-02 19:04:19 +01:00
|
|
|
fprintf(stderr, " Successful decodes: %8zd (%6.2f %%)\n",
|
2024-05-05 18:09:00 +02:00
|
|
|
m_rx_stats.successful_decodes, m_rx_stats.successful_decodes * 100.0f / m_rx_stats.preambles_found);
|
2024-01-05 21:28:38 +01:00
|
|
|
fprintf(stderr, " Header errors: %8zd (%6.2f %%)\n",
|
2024-05-05 18:09:00 +02:00
|
|
|
m_rx_stats.header_errors, m_rx_stats.header_errors * 100.0f / m_rx_stats.preambles_found);
|
2024-01-02 19:04:19 +01:00
|
|
|
fprintf(stderr, " Failed decodes: %8zd (%6.2f %%)\n",
|
2024-05-05 18:09:00 +02:00
|
|
|
m_rx_stats.failed_decodes, m_rx_stats.failed_decodes * 100.0f / m_rx_stats.preambles_found);
|
2024-01-02 19:04:19 +01:00
|
|
|
next_stats_print_time += 0.5;
|
2023-05-20 22:01:26 +02:00
|
|
|
|
|
|
|
total_samples = 0;
|
|
|
|
old = new;
|
|
|
|
}
|
2023-05-17 22:28:18 +02:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
rx_retries = 0;
|
2022-02-27 20:21:14 +01:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
fprintf(stderr, "r");
|
2022-02-27 20:21:14 +01:00
|
|
|
|
2024-01-02 23:49:55 +01:00
|
|
|
RESULT_CHECK(sdr_rf_to_baseband(&sdr, rf_samples, n_rf_samples, bb_samples, &n_bb_samples));
|
2022-03-05 21:38:05 +01:00
|
|
|
|
|
|
|
RESULT_CHECK(layer1_rx_process(&rx, bb_samples, n_bb_samples));
|
|
|
|
} else {
|
|
|
|
rx_retries = 0;
|
|
|
|
}
|
2022-02-27 20:21:14 +01:00
|
|
|
}
|
2021-10-17 19:26:38 +02:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
close(debug_fd);
|
2021-10-17 19:26:38 +02:00
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
// ** Cleanup **
|
2021-10-17 19:26:38 +02:00
|
|
|
|
2022-02-16 20:52:46 +01:00
|
|
|
layer1_tx_shutdown(&tx);
|
|
|
|
layer1_rx_shutdown(&rx);
|
|
|
|
|
2022-03-05 21:38:05 +01:00
|
|
|
sdr_destroy(&sdr);
|
|
|
|
|
2024-05-05 18:09:00 +02:00
|
|
|
jsonlogger_shutdown();
|
|
|
|
|
2022-02-16 21:46:56 +01:00
|
|
|
fprintf(stderr, "Done.\n");
|
2021-10-17 19:26:38 +02:00
|
|
|
}
|