SDRPlusPlus/source_modules/spyserver_source/src/spyserver_client.h

54 lines
1.3 KiB
C
Raw Normal View History

2020-12-22 14:50:26 +01:00
#pragma once
2021-07-19 04:52:13 +02:00
#include <utils/networking.h>
2020-12-22 14:50:26 +01:00
#include <spyserver_protocol.h>
#include <dsp/stream.h>
#include <dsp/types.h>
2021-07-19 04:52:13 +02:00
namespace spyserver {
class SpyServerClientClass {
public:
SpyServerClientClass(net::Conn conn, dsp::stream<dsp::complex_t>* out);
~SpyServerClientClass();
bool waitForDevInfo(int timeoutMS);
void startStream();
void stopStream();
void setSetting(uint32_t setting, uint32_t arg);
void close();
bool isOpen();
2021-07-20 03:03:22 +02:00
int computeDigitalGain(int serverBits, int deviceGain, int decimationId);
2021-07-19 04:52:13 +02:00
SpyServerDeviceInfo devInfo;
private:
void sendCommand(uint32_t command, void* data, int len);
void sendHandshake(std::string appName);
int readSize(int count, uint8_t* buffer);
static void dataHandler(int count, uint8_t* buf, void* ctx);
net::Conn client;
uint8_t* readBuf;
uint8_t* writeBuf;
bool deviceInfoAvailable = false;
std::mutex deviceInfoMtx;
std::condition_variable deviceInfoCnd;
SpyServerMessageHeader receivedHeader;
dsp::stream<dsp::complex_t>* output;
};
2021-07-19 04:52:13 +02:00
typedef std::unique_ptr<SpyServerClientClass> SpyServerClient;
SpyServerClient connect(std::string host, uint16_t port, dsp::stream<dsp::complex_t>* out);
2021-07-19 04:52:13 +02:00
}