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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
#ifndef AOREMOTE__FORMAT_H
#define AOREMOTE__FORMAT_H
#include <stdint.h>
#include <string>
#define AO_REMOTE_PROTOCOL_VERSION 1
namespace aoRemote {
enum BlockId
{
InitialId = 0x414F , // letters 'AO'
InitialResponseId = 2,
RequestId = 3,
GenericReadResponseHeaderId = 10
};
enum ErrorCode {
NoError = 0,
UnexpectedExceptionOccured = 1,
ProtocolNotUnderstoodError = 10,
CouldNotOpenMeasurementSetError = 20,
CouldNotOpenTableError = 21
} ;
struct ErrorStr
{
static std::string GetStr(enum ErrorCode errorCode)
{
switch(errorCode)
{
case NoError: return "No error";
break;
case UnexpectedExceptionOccured: return "Unexpected exception occured";
break;
case ProtocolNotUnderstoodError: return "Protocol not understood";
break;
case CouldNotOpenMeasurementSetError: return "Could not open measurement set";
break;
case CouldNotOpenTableError: return "Could not open requested table";
break;
default: return "Unknown error code";
break;
}
}
static std::string GetStr(int16_t errorCode)
{
return GetStr((enum ErrorCode) errorCode);
}
};
enum RequestType {
StopClientRequest = 0,
ReadQualityTablesRequest = 1,
ReadAntennaTablesRequest = 2,
ReadBandTableRequest = 3,
ReadDataRowsRequest = 4,
WriteDataRowsRequest = 5
};
struct InitialBlock
{
int16_t blockSize;
int16_t blockIdentifier;
int16_t protocolVersion;
int16_t options;
};
struct InitialResponseBlock
{
int16_t blockSize;
int16_t blockIdentifier;
int16_t negotiatedProtocolVersion;
int16_t errorCode;
int16_t hostNameSize;
// std::string hostname will follow
};
struct RequestBlock
{
int16_t blockSize;
int16_t blockIdentifier;
int16_t request;
int16_t dataSize;
};
struct GenericReadResponseHeader
{
int16_t blockSize;
int16_t blockIdentifier;
int16_t errorCode;
int64_t dataSize;
};
#define READ_QTABLES_OPTION_COLLECT_IF_REQUIRED 0x0001
#define READ_QTABLES_OPTION_SAVE_COLLECTED 0x0002
struct ReadQualityTablesRequestOptions
{
int32_t flags;
std::string msFilename;
};
struct ReadAntennaTablesRequestOptions
{
int32_t flags;
std::string msFilename;
};
struct ReadBandTableRequestOptions
{
int32_t flags;
std::string msFilename;
};
struct ReadDataRowsRequestOptions
{
int32_t flags;
std::string msFilename;
uint64_t startRow;
uint64_t rowCount;
};
struct WriteDataRowsRequestOptions
{
int32_t flags;
std::string msFilename;
uint64_t startRow;
uint64_t rowCount;
uint64_t dataSize;
};
}
#endif
|