spyserver_protocol.h
Go to the documentation of this file.
/*
SPY Server protocol structures and constants
Copyright (C) 2017 Youssef Touil youssef@live.com
*/
#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 DeviceType
{
DEVICE_INVALID = 0,
DEVICE_AIRSPY_ONE = 1,
DEVICE_AIRSPY_HF = 2,
DEVICE_RTLSDR = 3,
};
enum CommandType
{
CMD_HELLO = 0,
CMD_GET_SETTING = 1,
CMD_SET_SETTING = 2,
CMD_PING = 3,
};
enum SettingType
{
SETTING_STREAMING_MODE = 0,
SETTING_STREAMING_ENABLED = 1,
SETTING_GAIN = 2,
SETTING_IQ_FORMAT = 100,
SETTING_IQ_FREQUENCY = 101,
SETTING_IQ_DECIMATION = 102,
SETTING_IQ_DIGITAL_GAIN = 103,
SETTING_FFT_FORMAT = 200,
SETTING_FFT_FREQUENCY = 201,
SETTING_FFT_DECIMATION = 202,
SETTING_FFT_DB_OFFSET = 203,
SETTING_FFT_DB_RANGE = 204,
SETTING_FFT_DISPLAY_PIXELS = 205,
};
enum StreamType
{
STREAM_TYPE_STATUS = 0,
STREAM_TYPE_IQ = 1,
STREAM_TYPE_AF = 2,
STREAM_TYPE_FFT = 4,
};
enum StreamingMode
{
STREAM_MODE_IQ_ONLY = STREAM_TYPE_IQ,
STREAM_MODE_AF_ONLY = STREAM_TYPE_AF,
STREAM_MODE_FFT_ONLY = STREAM_TYPE_FFT,
STREAM_MODE_FFT_IQ = STREAM_TYPE_FFT | STREAM_TYPE_IQ,
STREAM_MODE_FFT_AF = STREAM_TYPE_FFT | STREAM_TYPE_AF,
};
enum StreamFormat
{
STREAM_FORMAT_INVALID = 0,
STREAM_FORMAT_UINT8 = 1,
STREAM_FORMAT_INT16 = 2,
STREAM_FORMAT_INT24 = 3,
STREAM_FORMAT_FLOAT = 4,
STREAM_FORMAT_DINT4 = 5,
};
enum MessageType
{
MSG_TYPE_DEVICE_INFO = 0,
MSG_TYPE_CLIENT_SYNC = 1,
MSG_TYPE_PONG = 2,
MSG_TYPE_READ_SETTING = 3,
MSG_TYPE_UINT8_IQ = 100,
MSG_TYPE_INT16_IQ = 101,
MSG_TYPE_INT24_IQ = 102,
MSG_TYPE_FLOAT_IQ = 103,
MSG_TYPE_UINT8_AF = 200,
MSG_TYPE_INT16_AF = 201,
MSG_TYPE_INT24_AF = 202,
MSG_TYPE_FLOAT_AF = 203,
MSG_TYPE_DINT4_FFT = 300,
MSG_TYPE_UINT8_FFT = 301,
};
struct ClientHandshake
{
uint32_t ProtocolVersion;
uint32_t ClientNameLength;
};
struct CommandHeader
{
uint32_t CommandType;
uint32_t BodySize;
};
struct SettingTarget
{
uint32_t StreamType;
uint32_t SettingType;
};
struct MessageHeader
{
uint32_t ProtocolID;
uint32_t MessageType;
uint32_t StreamType;
uint32_t SequenceNumber;
uint32_t BodySize;
};
struct DeviceInfo
{
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 ClientSync
{
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;
};
struct ComplexInt16
{
int16_t real;
int16_t imag;
};
struct ComplexUInt8
{
uint8_t real;
uint8_t imag;
};
enum ParserPhase {
AcquiringHeader,
ReadingData
};
CommandType
CommandType
Definition: spyserver_protocol.h:33
CMD_PING
@ CMD_PING
Definition: spyserver_protocol.h:37
CMD_SET_SETTING
@ CMD_SET_SETTING
Definition: spyserver_protocol.h:36
CMD_HELLO
@ CMD_HELLO
Definition: spyserver_protocol.h:34
CMD_GET_SETTING
@ CMD_GET_SETTING
Definition: spyserver_protocol.h:35
StreamFormat
StreamFormat
Definition: spyserver_protocol.h:78
STREAM_FORMAT_FLOAT
@ STREAM_FORMAT_FLOAT
Definition: spyserver_protocol.h:83
STREAM_FORMAT_INT24
@ STREAM_FORMAT_INT24
Definition: spyserver_protocol.h:82
STREAM_FORMAT_INT16
@ STREAM_FORMAT_INT16
Definition: spyserver_protocol.h:81
STREAM_FORMAT_UINT8
@ STREAM_FORMAT_UINT8
Definition: spyserver_protocol.h:80
STREAM_FORMAT_INVALID
@ STREAM_FORMAT_INVALID
Definition: spyserver_protocol.h:79
STREAM_FORMAT_DINT4
@ STREAM_FORMAT_DINT4
Definition: spyserver_protocol.h:84
ParserPhase
ParserPhase
Definition: spyserver_protocol.h:176
ReadingData
@ ReadingData
Definition: spyserver_protocol.h:178
AcquiringHeader
@ AcquiringHeader
Definition: spyserver_protocol.h:177
StreamType
StreamType
Definition: spyserver_protocol.h:60
STREAM_TYPE_IQ
@ STREAM_TYPE_IQ
Definition: spyserver_protocol.h:62
STREAM_TYPE_STATUS
@ STREAM_TYPE_STATUS
Definition: spyserver_protocol.h:61
STREAM_TYPE_FFT
@ STREAM_TYPE_FFT
Definition: spyserver_protocol.h:64
STREAM_TYPE_AF
@ STREAM_TYPE_AF
Definition: spyserver_protocol.h:63
SettingType
SettingType
Definition: spyserver_protocol.h:41
SETTING_GAIN
@ SETTING_GAIN
Definition: spyserver_protocol.h:44
SETTING_FFT_FORMAT
@ SETTING_FFT_FORMAT
Definition: spyserver_protocol.h:51
SETTING_FFT_DB_OFFSET
@ SETTING_FFT_DB_OFFSET
Definition: spyserver_protocol.h:54
SETTING_STREAMING_MODE
@ SETTING_STREAMING_MODE
Definition: spyserver_protocol.h:42
SETTING_IQ_FREQUENCY
@ SETTING_IQ_FREQUENCY
Definition: spyserver_protocol.h:47
SETTING_IQ_DIGITAL_GAIN
@ SETTING_IQ_DIGITAL_GAIN
Definition: spyserver_protocol.h:49
SETTING_FFT_DB_RANGE
@ SETTING_FFT_DB_RANGE
Definition: spyserver_protocol.h:55
SETTING_FFT_FREQUENCY
@ SETTING_FFT_FREQUENCY
Definition: spyserver_protocol.h:52
SETTING_IQ_DECIMATION
@ SETTING_IQ_DECIMATION
Definition: spyserver_protocol.h:48
SETTING_IQ_FORMAT
@ SETTING_IQ_FORMAT
Definition: spyserver_protocol.h:46
SETTING_STREAMING_ENABLED
@ SETTING_STREAMING_ENABLED
Definition: spyserver_protocol.h:43
SETTING_FFT_DECIMATION
@ SETTING_FFT_DECIMATION
Definition: spyserver_protocol.h:53
SETTING_FFT_DISPLAY_PIXELS
@ SETTING_FFT_DISPLAY_PIXELS
Definition: spyserver_protocol.h:56
MessageType
MessageType
Definition: spyserver_protocol.h:88
MSG_TYPE_DEVICE_INFO
@ MSG_TYPE_DEVICE_INFO
Definition: spyserver_protocol.h:89
MSG_TYPE_INT16_IQ
@ MSG_TYPE_INT16_IQ
Definition: spyserver_protocol.h:95
MSG_TYPE_FLOAT_IQ
@ MSG_TYPE_FLOAT_IQ
Definition: spyserver_protocol.h:97
MSG_TYPE_UINT8_IQ
@ MSG_TYPE_UINT8_IQ
Definition: spyserver_protocol.h:94
MSG_TYPE_FLOAT_AF
@ MSG_TYPE_FLOAT_AF
Definition: spyserver_protocol.h:102
MSG_TYPE_READ_SETTING
@ MSG_TYPE_READ_SETTING
Definition: spyserver_protocol.h:92
MSG_TYPE_INT24_AF
@ MSG_TYPE_INT24_AF
Definition: spyserver_protocol.h:101
MSG_TYPE_DINT4_FFT
@ MSG_TYPE_DINT4_FFT
Definition: spyserver_protocol.h:104
MSG_TYPE_PONG
@ MSG_TYPE_PONG
Definition: spyserver_protocol.h:91
MSG_TYPE_CLIENT_SYNC
@ MSG_TYPE_CLIENT_SYNC
Definition: spyserver_protocol.h:90
MSG_TYPE_UINT8_FFT
@ MSG_TYPE_UINT8_FFT
Definition: spyserver_protocol.h:105
MSG_TYPE_INT16_AF
@ MSG_TYPE_INT16_AF
Definition: spyserver_protocol.h:100
MSG_TYPE_INT24_IQ
@ MSG_TYPE_INT24_IQ
Definition: spyserver_protocol.h:96
MSG_TYPE_UINT8_AF
@ MSG_TYPE_UINT8_AF
Definition: spyserver_protocol.h:99
DeviceType
DeviceType
Definition: spyserver_protocol.h:25
DEVICE_AIRSPY_ONE
@ DEVICE_AIRSPY_ONE
Definition: spyserver_protocol.h:27
DEVICE_RTLSDR
@ DEVICE_RTLSDR
Definition: spyserver_protocol.h:29
DEVICE_INVALID
@ DEVICE_INVALID
Definition: spyserver_protocol.h:26
DEVICE_AIRSPY_HF
@ DEVICE_AIRSPY_HF
Definition: spyserver_protocol.h:28
StreamingMode
StreamingMode
Definition: spyserver_protocol.h:69
STREAM_MODE_AF_ONLY
@ STREAM_MODE_AF_ONLY
Definition: spyserver_protocol.h:71
STREAM_MODE_FFT_ONLY
@ STREAM_MODE_FFT_ONLY
Definition: spyserver_protocol.h:72
STREAM_MODE_FFT_AF
@ STREAM_MODE_FFT_AF
Definition: spyserver_protocol.h:74
STREAM_MODE_IQ_ONLY
@ STREAM_MODE_IQ_ONLY
Definition: spyserver_protocol.h:70
STREAM_MODE_FFT_IQ
@ STREAM_MODE_FFT_IQ
Definition: spyserver_protocol.h:73
ClientHandshake
Definition: spyserver_protocol.h:109
ClientHandshake::ProtocolVersion
uint32_t ProtocolVersion
Definition: spyserver_protocol.h:110
ClientHandshake::ClientNameLength
uint32_t ClientNameLength
Definition: spyserver_protocol.h:111
ClientSync
Definition: spyserver_protocol.h:152
ClientSync::DeviceCenterFrequency
uint32_t DeviceCenterFrequency
Definition: spyserver_protocol.h:155
ClientSync::MinimumFFTCenterFrequency
uint32_t MinimumFFTCenterFrequency
Definition: spyserver_protocol.h:160
ClientSync::Gain
uint32_t Gain
Definition: spyserver_protocol.h:154
ClientSync::FFTCenterFrequency
uint32_t FFTCenterFrequency
Definition: spyserver_protocol.h:157
ClientSync::IQCenterFrequency
uint32_t IQCenterFrequency
Definition: spyserver_protocol.h:156
ClientSync::MaximumFFTCenterFrequency
uint32_t MaximumFFTCenterFrequency
Definition: spyserver_protocol.h:161
ClientSync::MinimumIQCenterFrequency
uint32_t MinimumIQCenterFrequency
Definition: spyserver_protocol.h:158
ClientSync::CanControl
uint32_t CanControl
Definition: spyserver_protocol.h:153
ClientSync::MaximumIQCenterFrequency
uint32_t MaximumIQCenterFrequency
Definition: spyserver_protocol.h:159
CommandHeader
Definition: spyserver_protocol.h:115
CommandHeader::CommandType
uint32_t CommandType
Definition: spyserver_protocol.h:116
CommandHeader::BodySize
uint32_t BodySize
Definition: spyserver_protocol.h:117
ComplexInt16
Definition: spyserver_protocol.h:165
ComplexInt16::real
int16_t real
Definition: spyserver_protocol.h:166
ComplexInt16::imag
int16_t imag
Definition: spyserver_protocol.h:167
ComplexUInt8
Definition: spyserver_protocol.h:171
ComplexUInt8::imag
uint8_t imag
Definition: spyserver_protocol.h:173
ComplexUInt8::real
uint8_t real
Definition: spyserver_protocol.h:172
DeviceInfo
Definition: spyserver_protocol.h:136
DeviceInfo::Resolution
uint32_t Resolution
Definition: spyserver_protocol.h:146
DeviceInfo::MaximumGainIndex
uint32_t MaximumGainIndex
Definition: spyserver_protocol.h:143
DeviceInfo::ForcedIQFormat
uint32_t ForcedIQFormat
Definition: spyserver_protocol.h:148
DeviceInfo::GainStageCount
uint32_t GainStageCount
Definition: spyserver_protocol.h:142
DeviceInfo::MaximumSampleRate
uint32_t MaximumSampleRate
Definition: spyserver_protocol.h:139
DeviceInfo::MinimumFrequency
uint32_t MinimumFrequency
Definition: spyserver_protocol.h:144
DeviceInfo::MaximumFrequency
uint32_t MaximumFrequency
Definition: spyserver_protocol.h:145
DeviceInfo::MinimumIQDecimation
uint32_t MinimumIQDecimation
Definition: spyserver_protocol.h:147
DeviceInfo::DecimationStageCount
uint32_t DecimationStageCount
Definition: spyserver_protocol.h:141
DeviceInfo::DeviceSerial
uint32_t DeviceSerial
Definition: spyserver_protocol.h:138
DeviceInfo::DeviceType
uint32_t DeviceType
Definition: spyserver_protocol.h:137
DeviceInfo::MaximumBandwidth
uint32_t MaximumBandwidth
Definition: spyserver_protocol.h:140
MessageHeader
Definition: spyserver_protocol.h:127
MessageHeader::StreamType
uint32_t StreamType
Definition: spyserver_protocol.h:130
MessageHeader::SequenceNumber
uint32_t SequenceNumber
Definition: spyserver_protocol.h:131
MessageHeader::MessageType
uint32_t MessageType
Definition: spyserver_protocol.h:129
MessageHeader::ProtocolID
uint32_t ProtocolID
Definition: spyserver_protocol.h:128
MessageHeader::BodySize
uint32_t BodySize
Definition: spyserver_protocol.h:132
SettingTarget
Definition: spyserver_protocol.h:121
SettingTarget::SettingType
uint32_t SettingType
Definition: spyserver_protocol.h:123
SettingTarget::StreamType
uint32_t StreamType
Definition: spyserver_protocol.h:122