mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-28 13:27:51 +02:00
Formatted the entire codebase and added a CI check for formatting
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "spyserver_source",
|
||||
/* Description: */ "SpyServer source module for SDR++",
|
||||
/* Author: */ "Ryzerth",
|
||||
@ -29,8 +29,8 @@ const char* deviceTypesStr[] = {
|
||||
};
|
||||
|
||||
const char* streamFormatStr = "UInt8\0"
|
||||
"Int16\0"
|
||||
"Float32\0";
|
||||
"Int16\0"
|
||||
"Float32\0";
|
||||
|
||||
const SpyServerStreamFormat streamFormats[] = {
|
||||
SPYSERVER_STREAM_FORMAT_UINT8,
|
||||
@ -116,7 +116,7 @@ private:
|
||||
gui::mainWindow.playButtonLocked = false;
|
||||
spdlog::info("SpyServerSourceModule '{0}': Menu Deselect!", _this->name);
|
||||
}
|
||||
|
||||
|
||||
static void start(void* ctx) {
|
||||
SpyServerSourceModule* _this = (SpyServerSourceModule*)ctx;
|
||||
if (_this->running) { return; }
|
||||
@ -133,17 +133,17 @@ private:
|
||||
_this->running = true;
|
||||
spdlog::info("SpyServerSourceModule '{0}': Start!", _this->name);
|
||||
}
|
||||
|
||||
|
||||
static void stop(void* ctx) {
|
||||
SpyServerSourceModule* _this = (SpyServerSourceModule*)ctx;
|
||||
if (!_this->running) { return; }
|
||||
|
||||
|
||||
_this->client->stopStream();
|
||||
|
||||
_this->running = false;
|
||||
spdlog::info("SpyServerSourceModule '{0}': Stop!", _this->name);
|
||||
}
|
||||
|
||||
|
||||
static void tune(double freq, void* ctx) {
|
||||
SpyServerSourceModule* _this = (SpyServerSourceModule*)ctx;
|
||||
if (_this->running) {
|
||||
@ -152,7 +152,7 @@ private:
|
||||
_this->freq = freq;
|
||||
spdlog::info("SpyServerSourceModule '{0}': Tune: {1}!", _this->name, freq);
|
||||
}
|
||||
|
||||
|
||||
static void menuHandler(void* ctx) {
|
||||
SpyServerSourceModule* _this = (SpyServerSourceModule*)ctx;
|
||||
float menuWidth = ImGui::GetContentRegionAvailWidth();
|
||||
@ -211,7 +211,7 @@ private:
|
||||
_this->sampleRatesTxt += '\0';
|
||||
}
|
||||
|
||||
_this->srId = std::clamp<int>(_this->srId, 0, _this->sampleRates.size()-1);
|
||||
_this->srId = std::clamp<int>(_this->srId, 0, _this->sampleRates.size() - 1);
|
||||
|
||||
_this->sampleRate = _this->sampleRates[_this->srId];
|
||||
core::setInputSampleRate(_this->sampleRate);
|
||||
@ -227,7 +227,6 @@ private:
|
||||
}
|
||||
if (_this->running) { style::endDisabled(); }
|
||||
|
||||
|
||||
|
||||
if (connected) {
|
||||
if (_this->running) { style::beginDisabled(); }
|
||||
@ -248,7 +247,7 @@ private:
|
||||
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);
|
||||
|
@ -62,7 +62,7 @@ namespace spyserver {
|
||||
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; });
|
||||
deviceInfoCnd.wait_until(lck, now + (timeoutMS * 1ms), [this]() { return deviceInfoAvailable; });
|
||||
return deviceInfoAvailable;
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ namespace spyserver {
|
||||
SpyServerClientClass* _this = (SpyServerClientClass*)ctx;
|
||||
|
||||
if (count < sizeof(SpyServerMessageHeader)) {
|
||||
_this->readSize(sizeof(SpyServerMessageHeader)-count, &buf[count]);
|
||||
_this->readSize(sizeof(SpyServerMessageHeader) - count, &buf[count]);
|
||||
}
|
||||
|
||||
int size = _this->readSize(_this->receivedHeader.BodySize, _this->readBuf);
|
||||
@ -133,19 +133,19 @@ namespace spyserver {
|
||||
_this->deviceInfoCnd.notify_all();
|
||||
}
|
||||
else if (mtype == SPYSERVER_MSG_TYPE_UINT8_IQ) {
|
||||
int sampCount = _this->receivedHeader.BodySize / (sizeof(uint8_t)*2);
|
||||
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->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);
|
||||
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);
|
||||
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) {
|
||||
@ -155,7 +155,7 @@ namespace spyserver {
|
||||
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);
|
||||
volk_32f_s32f_multiply_32f((float*)_this->output->writeBuf, (float*)_this->readBuf, gain, sampCount * 2);
|
||||
_this->output->swap(sampCount);
|
||||
}
|
||||
|
||||
|
@ -44,11 +44,10 @@ namespace spyserver {
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,85 +17,85 @@ Corrections by Ryzerth.
|
||||
|
||||
#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)
|
||||
#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,
|
||||
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,
|
||||
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_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_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
|
||||
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,
|
||||
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
|
||||
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,
|
||||
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_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_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_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
|
||||
SPYSERVER_MSG_TYPE_DINT4_FFT = 300, //0x12C
|
||||
SPYSERVER_MSG_TYPE_UINT8_FFT = 301, //0x12D
|
||||
};
|
||||
|
||||
struct SpyServerClientHandshake {
|
||||
|
Reference in New Issue
Block a user