-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathSDRSoapy.h
More file actions
109 lines (79 loc) · 2.94 KB
/
Copy pathSDRSoapy.h
File metadata and controls
109 lines (79 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* Copyright (C) 2015,2016,2017,2018,2020,2021,2025,2026 by Jonathan Naylor G4KLX
* Copyright (C) 2026 by Shawn Chain BG5HHP
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(SDR_SOAPY_H)
#define SDR_SOAPY_H
#if defined(USE_SOAPY)
#include "IO.h"
#include "SDRDevice.h"
#include "DelayBuffer.h"
#include "RingBuffer.h"
#include "Socket.h"
#include "FDUDC.h"
#include <cstdint>
#include <vector>
#include <SoapySDR/Device.hpp>
#include <SoapySDR/Logger.hpp>
class CSDRSoapy : public ISDRDevice {
public:
CSDRSoapy();
virtual ~CSDRSoapy();
bool start(bool trace);
void process();
void stop();
void write(MMDVM_STATE mode, const q15_t* samples, uint16_t length, const uint8_t* control = nullptr);
int read(MMDVM_STATE mode, q15_t* samples, uint16_t* rssi, uint8_t* control);
uint16_t getSpace() const;
void setDeviceInfo(const std::string& type, const std::string& uri, unsigned int rxGain, unsigned int txGain);
uint8_t setFrequency(uint8_t power, uint32_t txFreq, uint32_t rxFreq, uint32_t pocsagFreq);
uint8_t setParameters();
private:
bool m_trace = false;
bool m_started = false;
CRingBuffer<RXSample> m_rxBuffer;
CRingBuffer<TXSample> m_txBuffer;
float m_power;
uint32_t m_txFreq;
uint32_t m_rxFreq;
uint32_t m_pocsagFreq;
float m_rxGain;
float m_txGain;
// Frequencies as used by SoapySDR
double m_soapyTXFreq;
double m_soapyRXFreq;
double m_soapyPocsagFreq;
bool m_soapyInit;
bool m_timestamped;
long long m_latencyNs;
uint32_t m_phase;
std::complex<float> m_prevRXIQSample;
CDelayBuffer<TXSample>* m_delayedTXBuffer;
std::vector<std::complex<float>> m_buffer;
CFDUDC* m_fdudc;
std::string m_soapyDeviceType;
std::string m_soapyDeviceURI;
SoapySDR::Device* m_device;
SoapySDR::Stream* m_rxStream;
SoapySDR::Stream* m_txStream;
bool m_pocsag;
void processIQBlock();
bool writeTXBlock(const std::vector<std::complex<float>>& samples, int flags = 0, long long timeNs = 0LL);
void setTXFrequency(bool pocsag);
};
#endif
#endif