Changed project structure

This commit is contained in:
AlexandreRouma
2021-10-03 16:50:36 +02:00
parent c36034dbb8
commit 73393e36c6
252 changed files with 52 additions and 52 deletions

View File

@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.13)
project(spyserver_source)
if (MSVC)
add_compile_options(/O2 /Ob2 /std:c++17 /EHsc)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-O3 -std=c++17 -Wno-unused-command-line-argument -undefined dynamic_lookup)
else ()
add_compile_options(-O3 -std=c++17)
endif ()
include_directories("src/")
file(GLOB SRC "src/*.cpp")
add_library(spyserver_source SHARED ${SRC})
target_link_libraries(spyserver_source PRIVATE sdrpp_core)
set_target_properties(spyserver_source PROPERTIES PREFIX "")
if(WIN32)
target_link_libraries(spyserver_source PRIVATE wsock32 ws2_32)
endif()
# Install directives
install(TARGETS spyserver_source DESTINATION lib/sdrpp/plugins)

View File

@ -0,0 +1,334 @@
#include <spyserver_client.h>
#include <imgui.h>
#include <spdlog/spdlog.h>
#include <module.h>
#include <gui/gui.h>
#include <signal_path/signal_path.h>
#include <core.h>
#include <gui/style.h>
#include <config.h>
#include <options.h>
#include <gui/widgets/stepped_slider.h>
#define CONCAT(a, b) ((std::string(a) + b).c_str())
SDRPP_MOD_INFO {
/* Name: */ "spyserver_source",
/* Description: */ "Airspy HF+ source module for SDR++",
/* Author: */ "Ryzerth",
/* Version: */ 0, 1, 0,
/* Max instances */ 1
};
const char* deviceTypesStr[] = {
"Unknown",
"Airspy One",
"Airspy HF+",
"RTL-SDR"
};
const char* streamFormatStr = "UInt8\0"
"Int16\0"
"Float32\0";
const SpyServerStreamFormat streamFormats[] = {
SPYSERVER_STREAM_FORMAT_UINT8,
SPYSERVER_STREAM_FORMAT_INT16,
SPYSERVER_STREAM_FORMAT_FLOAT
};
const int streamFormatsBitCount[] = {
8,
16,
32
};
ConfigManager config;
class AirspyHFSourceModule : public ModuleManager::Instance {
public:
AirspyHFSourceModule(std::string name) {
this->name = name;
config.acquire();
std::string host = config.conf["hostname"];
port = config.conf["port"];
config.release();
handler.ctx = this;
handler.selectHandler = menuSelected;
handler.deselectHandler = menuDeselected;
handler.menuHandler = menuHandler;
handler.startHandler = start;
handler.stopHandler = stop;
handler.tuneHandler = tune;
handler.stream = &stream;
strcpy(hostname, host.c_str());
sigpath::sourceManager.registerSource("SpyServer", &handler);
}
~AirspyHFSourceModule() {
stop(this);
sigpath::sourceManager.unregisterSource("SpyServer");
}
void postInit() {}
void enable() {
enabled = true;
}
void disable() {
enabled = false;
}
bool isEnabled() {
return enabled;
}
private:
std::string getBandwdithScaled(double bw) {
char buf[1024];
if (bw >= 1000000.0) {
sprintf(buf, "%.1lfMHz", bw / 1000000.0);
}
else if (bw >= 1000.0) {
sprintf(buf, "%.1lfKHz", bw / 1000.0);
}
else {
sprintf(buf, "%.1lfHz", bw);
}
return std::string(buf);
}
static void menuSelected(void* ctx) {
AirspyHFSourceModule* _this = (AirspyHFSourceModule*)ctx;
core::setInputSampleRate(_this->sampleRate);
gui::mainWindow.playButtonLocked = !(_this->client && _this->client->isOpen());
spdlog::info("AirspyHFSourceModule '{0}': Menu Select!", _this->name);
}
static void menuDeselected(void* ctx) {
AirspyHFSourceModule* _this = (AirspyHFSourceModule*)ctx;
gui::mainWindow.playButtonLocked = false;
spdlog::info("AirspyHFSourceModule '{0}': Menu Deselect!", _this->name);
}
static void start(void* ctx) {
AirspyHFSourceModule* _this = (AirspyHFSourceModule*)ctx;
if (_this->running) { return; }
int srvBits = streamFormatsBitCount[_this->iqType];
_this->client->setSetting(SPYSERVER_SETTING_IQ_FORMAT, streamFormats[_this->iqType]);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DECIMATION, _this->srId + _this->client->devInfo.MinimumIQDecimation);
_this->client->setSetting(SPYSERVER_SETTING_IQ_FREQUENCY, _this->freq);
_this->client->setSetting(SPYSERVER_SETTING_STREAMING_MODE, SPYSERVER_STREAM_MODE_IQ_ONLY);
_this->client->setSetting(SPYSERVER_SETTING_GAIN, _this->gain);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->client->computeDigitalGain(srvBits, _this->gain, _this->srId + _this->client->devInfo.MinimumIQDecimation));
_this->client->startStream();
_this->running = true;
spdlog::info("AirspyHFSourceModule '{0}': Start!", _this->name);
}
static void stop(void* ctx) {
AirspyHFSourceModule* _this = (AirspyHFSourceModule*)ctx;
if (!_this->running) { return; }
_this->client->stopStream();
_this->running = false;
spdlog::info("AirspyHFSourceModule '{0}': Stop!", _this->name);
}
static void tune(double freq, void* ctx) {
AirspyHFSourceModule* _this = (AirspyHFSourceModule*)ctx;
if (_this->running) {
_this->client->setSetting(SPYSERVER_SETTING_IQ_FREQUENCY, freq);
}
_this->freq = freq;
spdlog::info("AirspyHFSourceModule '{0}': Tune: {1}!", _this->name, freq);
}
static void menuHandler(void* ctx) {
AirspyHFSourceModule* _this = (AirspyHFSourceModule*)ctx;
float menuWidth = ImGui::GetContentRegionAvailWidth();
bool connected = (_this->client && _this->client->isOpen());
gui::mainWindow.playButtonLocked = !connected;
if (connected) { style::beginDisabled(); }
if (ImGui::InputText(CONCAT("##_rigctl_srv_host_", _this->name), _this->hostname, 1023)) {
config.acquire();
config.conf["hostname"] = _this->hostname;
config.release(true);
}
ImGui::SameLine();
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::InputInt(CONCAT("##_rigctl_srv_port_", _this->name), &_this->port, 0, 0)) {
config.acquire();
config.conf["port"] = _this->port;
config.release(true);
}
if (connected) { style::endDisabled(); }
if (_this->running) { style::beginDisabled(); }
if (!connected && ImGui::Button("Connect##spyserver_source", ImVec2(menuWidth, 0))) {
try {
_this->client = spyserver::connect(_this->hostname, _this->port, &_this->stream);
if (!_this->client->waitForDevInfo(3000)) {
spdlog::error("SpyServer didn't respond with device information");
}
else {
char buf[1024];
sprintf(buf, "%s [%08X]", deviceTypesStr[_this->client->devInfo.DeviceType], _this->client->devInfo.DeviceSerial);
_this->devRef = std::string(buf);
config.acquire();
if (!config.conf["devices"].contains(_this->devRef)) {
config.conf["devices"][_this->devRef]["sampleRateId"] = 0;
config.conf["devices"][_this->devRef]["sampleBitDepthId"] = 1;
config.conf["devices"][_this->devRef]["gainId"] = 0;
}
_this->srId = config.conf["devices"][_this->devRef]["sampleRateId"];
_this->iqType = config.conf["devices"][_this->devRef]["sampleBitDepthId"];
_this->gain = config.conf["devices"][_this->devRef]["gainId"];
config.release(true);
_this->gain = std::clamp<int>(_this->gain, 0, _this->client->devInfo.MaximumGainIndex);
// Refresh sample rates
_this->sampleRates.clear();
_this->sampleRatesTxt.clear();
for (int i = _this->client->devInfo.MinimumIQDecimation; i <= _this->client->devInfo.DecimationStageCount; i++) {
double sr = (double)_this->client->devInfo.MaximumSampleRate / ((double)(1 << i));
_this->sampleRates.push_back(sr);
_this->sampleRatesTxt += _this->getBandwdithScaled(sr);
_this->sampleRatesTxt += '\0';
}
_this->srId = std::clamp<int>(_this->srId, 0, _this->sampleRates.size()-1);
_this->sampleRate = _this->sampleRates[_this->srId];
core::setInputSampleRate(_this->sampleRate);
spdlog::info("Connected to server");
}
}
catch (std::exception e) {
spdlog::error("Could not connect to spyserver {0}", e.what());
}
}
else if (connected && ImGui::Button("Disconnect##spyserver_source", ImVec2(menuWidth, 0))) {
_this->client->close();
}
if (_this->running) { style::endDisabled(); }
if (connected) {
if (_this->running) { style::beginDisabled(); }
ImGui::LeftLabel("Samplerate");
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::Combo("##spyserver_source_sr", &_this->srId, _this->sampleRatesTxt.c_str())) {
_this->sampleRate = _this->sampleRates[_this->srId];
core::setInputSampleRate(_this->sampleRate);
config.acquire();
config.conf["devices"][_this->devRef]["sampleRateId"] = _this->srId;
config.release(true);
}
if (_this->running) { style::endDisabled(); }
ImGui::LeftLabel("Sample bit depth");
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::Combo("##spyserver_source_type", &_this->iqType, streamFormatStr)) {
int srvBits = streamFormatsBitCount[_this->iqType];
_this->client->setSetting(SPYSERVER_SETTING_IQ_FORMAT, streamFormats[_this->iqType]);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->client->computeDigitalGain(srvBits, _this->gain, _this->srId + _this->client->devInfo.MinimumIQDecimation));
config.acquire();
config.conf["devices"][_this->devRef]["sampleBitDepthId"] = _this->iqType;
config.release(true);
}
if (_this->client->devInfo.MaximumGainIndex) {
ImGui::SetNextItemWidth(menuWidth);
if (ImGui::SliderInt("##spyserver_source_gain", (int*)&_this->gain, 0, _this->client->devInfo.MaximumGainIndex)) {
int srvBits = streamFormatsBitCount[_this->iqType];
_this->client->setSetting(SPYSERVER_SETTING_GAIN, _this->gain);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->client->computeDigitalGain(srvBits, _this->gain, _this->srId + _this->client->devInfo.MinimumIQDecimation));
config.acquire();
config.conf["devices"][_this->devRef]["gainId"] = _this->gain;
config.release(true);
}
}
ImGui::Text("Status:");
ImGui::SameLine();
ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "Connected (%s)", deviceTypesStr[_this->client->devInfo.DeviceType]);
}
else {
ImGui::Text("Status:");
ImGui::SameLine();
ImGui::Text("Not connected");
}
}
std::string name;
bool enabled = true;
bool running = false;
double sampleRate = 1000000;
double freq;
char hostname[1024];
int port = 5555;
int iqType = 0;
int srId = 0;
std::vector<double> sampleRates;
std::string sampleRatesTxt;
uint32_t gain = 0;
std::string devRef = "";
dsp::stream<dsp::complex_t> stream;
SourceManager::SourceHandler handler;
spyserver::SpyServerClient client;
};
MOD_EXPORT void _INIT_() {
json def = json({});
def["hostname"] = "localhost";
def["port"] = 5555;
def["devices"] = json::object();
config.setPath(options::opts.root + "/spyserver_config.json");
config.load(def);
config.enableAutoSave();
// Check config in case a user has a very old version
config.acquire();
bool corrected = false;
if (!config.conf.contains("hostname") || !config.conf.contains("port") || !config.conf.contains("devices")) {
config.conf = def;
corrected = true;
}
config.release(corrected);
}
MOD_EXPORT ModuleManager::Instance* _CREATE_INSTANCE_(std::string name) {
return new AirspyHFSourceModule(name);
}
MOD_EXPORT void _DELETE_INSTANCE_(ModuleManager::Instance* instance) {
delete (AirspyHFSourceModule*)instance;
}
MOD_EXPORT void _END_() {
config.disableAutoSave();
config.save();
}

View File

@ -0,0 +1,172 @@
#include <spyserver_client.h>
#include <volk/volk.h>
#include <cstring>
using namespace std::chrono_literals;
namespace spyserver {
SpyServerClientClass::SpyServerClientClass(net::Conn conn, dsp::stream<dsp::complex_t>* out) {
readBuf = new uint8_t[SPYSERVER_MAX_MESSAGE_BODY_SIZE];
writeBuf = new uint8_t[SPYSERVER_MAX_MESSAGE_BODY_SIZE];
client = std::move(conn);
output = out;
output->clearWriteStop();
sendHandshake("SDR++");
client->readAsync(sizeof(SpyServerMessageHeader), (uint8_t*)&receivedHeader, dataHandler, this);
}
SpyServerClientClass::~SpyServerClientClass() {
close();
delete[] readBuf;
delete[] writeBuf;
}
void SpyServerClientClass::startStream() {
output->clearWriteStop();
setSetting(SPYSERVER_SETTING_STREAMING_ENABLED, true);
}
void SpyServerClientClass::stopStream() {
output->stopWriter();
setSetting(SPYSERVER_SETTING_STREAMING_ENABLED, false);
}
void SpyServerClientClass::close() {
output->stopWriter();
client->close();
}
bool SpyServerClientClass::isOpen() {
return client->isOpen();
}
int SpyServerClientClass::computeDigitalGain(int serverBits, int deviceGain, int decimationId) {
if (devInfo.DeviceType == SPYSERVER_DEVICE_AIRSPY_ONE) {
return (devInfo.MaximumGainIndex - deviceGain) + (decimationId * 3.01f);
}
else if (devInfo.DeviceType == SPYSERVER_DEVICE_AIRSPY_HF) {
return decimationId * 3.01f;
}
else if (devInfo.DeviceType == SPYSERVER_DEVICE_RTLSDR) {
return decimationId * 3.01f;
}
else {
// Error, unknown device
return -1;
}
}
bool SpyServerClientClass::waitForDevInfo(int timeoutMS) {
std::unique_lock lck(deviceInfoMtx);
auto now = std::chrono::system_clock::now();
deviceInfoCnd.wait_until(lck, now + (timeoutMS*1ms), [this](){ return deviceInfoAvailable; });
return deviceInfoAvailable;
}
void SpyServerClientClass::sendCommand(uint32_t command, void* data, int len) {
SpyServerCommandHeader* hdr = (SpyServerCommandHeader*)writeBuf;
hdr->CommandType = command;
hdr->BodySize = len;
memcpy(&writeBuf[sizeof(SpyServerCommandHeader)], data, len);
client->write(sizeof(SpyServerCommandHeader) + len, writeBuf);
}
void SpyServerClientClass::sendHandshake(std::string appName) {
int totSize = sizeof(SpyServerClientHandshake) + appName.size();
uint8_t* buf = new uint8_t[totSize];
SpyServerClientHandshake* cmdHandshake = (SpyServerClientHandshake*)buf;
cmdHandshake->ProtocolVersion = SPYSERVER_PROTOCOL_VERSION;
memcpy(&buf[sizeof(SpyServerClientHandshake)], appName.c_str(), appName.size());
sendCommand(SPYSERVER_CMD_HELLO, buf, totSize);
delete[] buf;
}
void SpyServerClientClass::setSetting(uint32_t setting, uint32_t arg) {
SpyServerSettingTarget target;
target.Setting = setting;
target.Value = arg;
sendCommand(SPYSERVER_CMD_SET_SETTING, &target, sizeof(SpyServerSettingTarget));
}
int SpyServerClientClass::readSize(int count, uint8_t* buffer) {
int read = 0;
int len = 0;
while (read < count) {
len = client->read(count - read, &buffer[read]);
if (len <= 0) { return len; }
read += len;
}
return read;
}
void SpyServerClientClass::dataHandler(int count, uint8_t* buf, void* ctx) {
SpyServerClientClass* _this = (SpyServerClientClass*)ctx;
if (count < sizeof(SpyServerMessageHeader)) {
_this->readSize(sizeof(SpyServerMessageHeader)-count, &buf[count]);
}
int size = _this->readSize(_this->receivedHeader.BodySize, _this->readBuf);
if (size <= 0) {
printf("ERROR: Disconnected\n");
return;
}
//printf("MSG Proto: 0x%08X, MsgType: 0x%08X, StreamType: 0x%08X, Seq: 0x%08X, Size: %d\n", _this->receivedHeader.ProtocolID, _this->receivedHeader.MessageType, _this->receivedHeader.StreamType, _this->receivedHeader.SequenceNumber, _this->receivedHeader.BodySize);
int mtype = _this->receivedHeader.MessageType & 0xFFFF;
int mflags = (_this->receivedHeader.MessageType & 0xFFFF0000) >> 16;
if (mtype == SPYSERVER_MSG_TYPE_DEVICE_INFO) {
{
std::lock_guard lck(_this->deviceInfoMtx);
SpyServerDeviceInfo* _devInfo = (SpyServerDeviceInfo*)_this->readBuf;
_this->devInfo = *_devInfo;
_this->deviceInfoAvailable = true;
}
_this->deviceInfoCnd.notify_all();
}
else if (mtype == SPYSERVER_MSG_TYPE_UINT8_IQ) {
int sampCount = _this->receivedHeader.BodySize / (sizeof(uint8_t)*2);
float gain = pow(10, (double)mflags / 20.0);
float scale = 1.0f / (gain * 128.0f);
for (int i = 0; i < sampCount; i++) {
_this->output->writeBuf[i].re = ((float)_this->readBuf[(2*i)] - 128.0f) * scale;
_this->output->writeBuf[i].im = ((float)_this->readBuf[(2*i)+1] - 128.0f) * scale;
}
_this->output->swap(sampCount);
}
else if (mtype == SPYSERVER_MSG_TYPE_INT16_IQ) {
int sampCount = _this->receivedHeader.BodySize / (sizeof(int16_t)*2);
float gain = pow(10, (double)mflags / 20.0);
volk_16i_s32f_convert_32f((float*)_this->output->writeBuf, (int16_t*)_this->readBuf, 32768.0 * gain, sampCount*2);
_this->output->swap(sampCount);
}
else if (mtype == SPYSERVER_MSG_TYPE_INT24_IQ) {
printf("ERROR: IQ format not supported\n");
return;
}
else if (mtype == SPYSERVER_MSG_TYPE_FLOAT_IQ) {
int sampCount = _this->receivedHeader.BodySize / sizeof(dsp::complex_t);
float gain = pow(10, (double)mflags / 20.0);
volk_32f_s32f_multiply_32f((float*)_this->output->writeBuf, (float*)_this->readBuf, gain, sampCount*2);
_this->output->swap(sampCount);
}
_this->client->readAsync(sizeof(SpyServerMessageHeader), (uint8_t*)&_this->receivedHeader, dataHandler, _this);
}
SpyServerClient connect(std::string host, uint16_t port, dsp::stream<dsp::complex_t>* out) {
net::Conn conn = net::connect(host, port);
if (!conn) {
return NULL;
}
return SpyServerClient(new SpyServerClientClass(std::move(conn), out));
}
}

View File

@ -0,0 +1,54 @@
#pragma once
#include <utils/networking.h>
#include <spyserver_protocol.h>
#include <dsp/stream.h>
#include <dsp/types.h>
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();
int computeDigitalGain(int serverBits, int deviceGain, int decimationId);
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;
};
typedef std::unique_ptr<SpyServerClientClass> SpyServerClient;
SpyServerClient connect(std::string host, uint16_t port, dsp::stream<dsp::complex_t>* out);
}

View File

@ -0,0 +1,148 @@
/*
SPY Server protocol structures and constants
Copyright (C) 2017 Youssef Touil youssef@live.com
Corrections by Ryzerth.
*/
#pragma once
#include <stdint.h>
#include <limits.h>
#define SPYSERVER_PROTOCOL_VERSION (((2) << 24) | ((0) << 16) | (1700))
#define SPYSERVER_MAX_COMMAND_BODY_SIZE (256)
#define SPYSERVER_MAX_MESSAGE_BODY_SIZE (1 << 20)
#define SPYSERVER_MAX_DISPLAY_PIXELS (1 << 15)
#define SPYSERVER_MIN_DISPLAY_PIXELS (100)
#define SPYSERVER_MAX_FFT_DB_RANGE (150)
#define SPYSERVER_MIN_FFT_DB_RANGE (10)
#define SPYSERVER_MAX_FFT_DB_OFFSET (100)
enum SpyServerDeviceType {
SPYSERVER_DEVICE_INVALID = 0,
SPYSERVER_DEVICE_AIRSPY_ONE = 1,
SPYSERVER_DEVICE_AIRSPY_HF = 2,
SPYSERVER_DEVICE_RTLSDR = 3,
};
enum SpyServerCommandType {
SPYSERVER_CMD_HELLO = 0,
SPYSERVER_CMD_SET_SETTING = 2,
SPYSERVER_CMD_PING = 3,
};
enum SpyServerSettingType {
SPYSERVER_SETTING_STREAMING_MODE = 0,
SPYSERVER_SETTING_STREAMING_ENABLED = 1,
SPYSERVER_SETTING_GAIN = 2,
SPYSERVER_SETTING_IQ_FORMAT = 100, // 0x64
SPYSERVER_SETTING_IQ_FREQUENCY = 101, // 0x65
SPYSERVER_SETTING_IQ_DECIMATION = 102, // 0x66
SPYSERVER_SETTING_IQ_DIGITAL_GAIN = 103, // 0x67
SPYSERVER_SETTING_FFT_FORMAT = 200, // 0xc8
SPYSERVER_SETTING_FFT_FREQUENCY = 201, // 0xc9
SPYSERVER_SETTING_FFT_DECIMATION = 202, // 0xca
SPYSERVER_SETTING_FFT_DB_OFFSET = 203, // 0xcb
SPYSERVER_SETTING_FFT_DB_RANGE = 204, // 0xcc
SPYSERVER_SETTING_FFT_DISPLAY_PIXELS = 205, // 0xcd
};
enum SpyServerStreamType {
SPYSERVER_STREAM_TYPE_STATUS = 0,
SPYSERVER_STREAM_TYPE_IQ = 1,
SPYSERVER_STREAM_TYPE_AF = 2,
SPYSERVER_STREAM_TYPE_FFT = 4,
};
enum SpyServerStreamingMode {
SPYSERVER_STREAM_MODE_IQ_ONLY = SPYSERVER_STREAM_TYPE_IQ, // 0x01
SPYSERVER_STREAM_MODE_AF_ONLY = SPYSERVER_STREAM_TYPE_AF, // 0x02
SPYSERVER_STREAM_MODE_FFT_ONLY = SPYSERVER_STREAM_TYPE_FFT, // 0x04
SPYSERVER_STREAM_MODE_FFT_IQ = SPYSERVER_STREAM_TYPE_FFT | SPYSERVER_STREAM_TYPE_IQ, // 0x05
SPYSERVER_STREAM_MODE_FFT_AF = SPYSERVER_STREAM_TYPE_FFT | SPYSERVER_STREAM_TYPE_AF, // 0x06
};
enum SpyServerStreamFormat {
SPYSERVER_STREAM_FORMAT_INVALID = 0,
SPYSERVER_STREAM_FORMAT_UINT8 = 1,
SPYSERVER_STREAM_FORMAT_INT16 = 2,
SPYSERVER_STREAM_FORMAT_INT24 = 3,
SPYSERVER_STREAM_FORMAT_FLOAT = 4,
SPYSERVER_STREAM_FORMAT_DINT4 = 5,
};
enum SpyServerMessageType {
SPYSERVER_MSG_TYPE_DEVICE_INFO = 0,
SPYSERVER_MSG_TYPE_CLIENT_SYNC = 1,
SPYSERVER_MSG_TYPE_PONG = 2,
SPYSERVER_MSG_TYPE_READ_SETTING = 3,
SPYSERVER_MSG_TYPE_UINT8_IQ = 100, // 0x64
SPYSERVER_MSG_TYPE_INT16_IQ = 101, // 0x65
SPYSERVER_MSG_TYPE_INT24_IQ = 102, // 0x66
SPYSERVER_MSG_TYPE_FLOAT_IQ = 103, // 0x67
SPYSERVER_MSG_TYPE_UINT8_AF = 200, // 0xc8
SPYSERVER_MSG_TYPE_INT16_AF = 201, // 0xc9
SPYSERVER_MSG_TYPE_INT24_AF = 202, // 0xca
SPYSERVER_MSG_TYPE_FLOAT_AF = 203, // 0xcb
SPYSERVER_MSG_TYPE_DINT4_FFT = 300, //0x12C
SPYSERVER_MSG_TYPE_UINT8_FFT = 301, //0x12D
};
struct SpyServerClientHandshake {
uint32_t ProtocolVersion;
};
struct SpyServerCommandHeader {
uint32_t CommandType;
uint32_t BodySize;
};
struct SpyServerSettingTarget {
uint32_t Setting;
uint32_t Value;
};
struct SpyServerMessageHeader {
uint32_t ProtocolID;
uint32_t MessageType;
uint32_t StreamType;
uint32_t SequenceNumber;
uint32_t BodySize;
};
struct SpyServerDeviceInfo {
uint32_t DeviceType;
uint32_t DeviceSerial;
uint32_t MaximumSampleRate;
uint32_t MaximumBandwidth;
uint32_t DecimationStageCount;
uint32_t GainStageCount;
uint32_t MaximumGainIndex;
uint32_t MinimumFrequency;
uint32_t MaximumFrequency;
uint32_t Resolution;
uint32_t MinimumIQDecimation;
uint32_t ForcedIQFormat;
};
struct SpyServerClientSync {
uint32_t CanControl;
uint32_t Gain;
uint32_t DeviceCenterFrequency;
uint32_t IQCenterFrequency;
uint32_t FFTCenterFrequency;
uint32_t MinimumIQCenterFrequency;
uint32_t MaximumIQCenterFrequency;
uint32_t MinimumFFTCenterFrequency;
uint32_t MaximumFFTCenterFrequency;
};