-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDefinitions.h
More file actions
232 lines (201 loc) · 9.36 KB
/
Definitions.h
File metadata and controls
232 lines (201 loc) · 9.36 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#ifndef LIB_AGRIROUTERCLIENT_INC_DEFINITIONS_H_
#define LIB_AGRIROUTERCLIENT_INC_DEFINITIONS_H_
#include "commons/chunk.pb.h"
#include "commons/message.pb.h"
#include "messaging/request/request.pb.h"
#include "messaging/response/response.pb.h"
#include "messaging/request/payload/account/endpoints.pb.h"
#include "messaging/request/payload/efdi/grpc-efdi.pb.h"
#include "messaging/request/payload/endpoint/capabilities.pb.h"
#include "messaging/request/payload/endpoint/subscription.pb.h"
#include "messaging/request/payload/feed/feed-requests.pb.h"
#include "messaging/response/payload/account/endpoints.pb.h"
#include "messaging/response/payload/feed/feed-response.pb.h"
#include "messaging/response/payload/feed/push-notification.pb.h"
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/util/json_util.h>
#include <list>
#include <string>
#define CAPABILITIES 1
#define SUBSCRIPTIONS 2
#define DEVICE_DESCRIPTION 3
#define LIST_ENDPOINTS_FILTERED 4
#define LIST_ENDPOINTS_UNFILTERED 5
#define QUERY_HEADERS 6
#define QUERY_MESSAGES 8
#define NON_TELEMETRY 9
#define MESSAGE_CONFIRM 10
#define MESSAGE_DELETE 11
#define GET_MESSAGES 12
#define TIMELOG 13
#define MG_PARAMETER_BASE 100
#define MG_PARAMETER_AUTH_USERNAME (MG_PARAMETER_BASE + 1)
#define MG_PARAMETER_AUTH_PASSWORD (MG_PARAMETER_BASE + 2)
#define MG_PARAMETER_ACCOUNT_ID (MG_PARAMETER_BASE + 3)
#define MG_PARAMETER_APPLICATION_ID (MG_PARAMETER_BASE + 4)
#define MG_PARAMETER_CERTIFICATION_VERSION_ID (MG_PARAMETER_BASE + 5)
#define MG_PARAMETER_ONBOARD_ID (MG_PARAMETER_BASE + 6)
#define MG_PARAMETER_GATEWAY_ID (MG_PARAMETER_BASE + 7)
#define MG_PARAMETER_CERTIFICATE_TYPE (MG_PARAMETER_BASE + 8)
#define MG_PARAMETER_CERTIFICATE (MG_PARAMETER_BASE + 9)
#define MG_PARAMETER_CERTIFICATE_PATH (MG_PARAMETER_BASE + 10)
#define MG_PARAMETER_PRIVATE_KEY (MG_PARAMETER_BASE + 11)
#define MG_PARAMETER_PRIVATE_KEY_PATH (MG_PARAMETER_BASE + 12)
#define MG_PARAMETER_PRIVATE_KEY_PASSPHRASE (MG_PARAMETER_BASE + 13)
#define MG_PARAMETER_ENCODING_TYPE (MG_PARAMETER_BASE + 14)
#define MG_PARAMETER_CONNECTION_PARAMETERS (MG_PARAMETER_BASE + 15)
#define MG_PARAMETER_CONNECTION_PARAMETERS_PATH (MG_PARAMETER_BASE + 16)
#define MG_PARAMETER_CONNECTION_TYPE (MG_PARAMETER_BASE + 17)
#define MG_PARAMETER_POLLING_INTERVAL (MG_PARAMETER_BASE + 18)
#define MG_PARAMETER_POLLING_MAX_TIME (MG_PARAMETER_BASE + 19)
#define MG_PARAMETER_MQTT_KEEP_ALIVE_TIME (MG_PARAMETER_BASE + 20)
#define MG_EV_BASE 200
#define MG_EV_CAPABILITIES (MG_EV_BASE + CAPABILITIES)
#define MG_EV_SUBSCRIPTIONS (MG_EV_BASE + SUBSCRIPTIONS)
#define MG_EV_DEVICE_DESCRIPTION (MG_EV_BASE + DEVICE_DESCRIPTION)
#define MG_EV_LIST_ENDPOINTS_FILTERED (MG_EV_BASE + LIST_ENDPOINTS_FILTERED)
#define MG_EV_LIST_ENDPOINTS_UNFILTERED (MG_EV_BASE + LIST_ENDPOINTS_UNFILTERED)
#define MG_EV_QUERY_HEADERS (MG_EV_BASE + QUERY_HEADERS)
#define MG_EV_QUERY_MESSAGES (MG_EV_BASE + QUERY_MESSAGES)
#define MG_EV_NON_TELEMETRY (MG_EV_BASE + NON_TELEMETRY)
#define MG_EV_MESSAGE_CONFIRM (MG_EV_BASE + MESSAGE_CONFIRM)
#define MG_EV_MESSAGE_DELETE (MG_EV_BASE + MESSAGE_DELETE)
#define MG_EV_GET_MESSAGES (MG_EV_BASE + GET_MESSAGES)
#define MG_EV_TIMELOG (MG_EV_BASE + TIMELOG)
// error messages
#define MG_ERROR_BASE 300
#define MG_ERROR_MISSING_ENDPOINT (MG_ERROR_BASE + 1)
#define MG_ERROR_MISSING_OR_EXPIRED_CERTIFICATE (MG_ERROR_BASE + 2)
#define MG_ERROR_MISSING_OR_EXPIRED_CA_CERTIFICATE (MG_ERROR_BASE + 3)
#define MG_ERROR_NOT_VALID_TOPIC (MG_ERROR_BASE + 4)
// message types
#define MESSAGE_TYPE_TASK_DATA "iso:11783:-10:taskdata:zip"
#define MESSAGE_TYPE_TIME_LOG "iso:11783:-10:time_log:protobuf"
#define MESSAGE_TYPE_DEVICE_DESCRIPTION "iso:11783:-10:device_description:protobuf"
// loglevel
#define MG_LFL_CRI 1 // critical
#define MG_LFL_ERR 2 // error
#define MG_LFL_WRN 3 // warning
#define MG_LFL_MSG 4 // message
#define MG_LFL_NTC 5 // notice
#define MG_LFL_TRC 6 // trace
#define MG_LFL_DBG 7 // debug
// Other definitions
#define DEFAULT_CHUNK_SIZE 300000 // 0,3 MB
#define DEFAULT_KEEP_ALIVE_TIME 240 // 240 s
// Protobuf typedefs
typedef agrirouter::request::RequestEnvelope RequestEnvelope;
typedef agrirouter::request::RequestPayloadWrapper RequestPayloadWrapper;
typedef agrirouter::response::ResponseEnvelope ResponseEnvelope;
typedef agrirouter::response::ResponsePayloadWrapper ResponsePayloadWrapper;
typedef agrirouter::request::payload::endpoint::CapabilitySpecification CapabilitySpecification;
typedef agrirouter::request::payload::endpoint::CapabilitySpecification_Capability Capability;
typedef agrirouter::request::payload::endpoint::Subscription Subscription;
typedef agrirouter::request::payload::endpoint::CapabilitySpecification_Direction CapabilitySpecification_Direction;
typedef agrirouter::request::payload::endpoint::Subscription_MessageTypeSubscriptionItem MessageTypeSubscriptionItem;
typedef agrirouter::request::payload::account::ListEndpointsQuery ListEndpointsQuery;
typedef agrirouter::request::payload::account::ListEndpointsQuery_Direction ListEndpointsQuery_Direction;
typedef agrirouter::response::payload::account::ListEndpointsResponse ListEndpointsResponse;
typedef agrirouter::response::payload::account::ListEndpointsResponse_MessageType MessageType;
typedef agrirouter::response::payload::account::ListEndpointsResponse_Endpoint Endpoint;
typedef agrirouter::response::payload::account::ListEndpointsResponse_Direction Direction;
typedef agrirouter::feed::request::MessageConfirm MessageConfirm;
typedef agrirouter::feed::request::MessageDelete MessageDelete;
typedef agrirouter::feed::request::MessageQuery MessageQuery;
typedef agrirouter::feed::request::ValidityPeriod ValidityPeriod;
typedef agrirouter::feed::response::QueryMetrics QueryMetrics;
typedef agrirouter::feed::response::HeaderQueryResponse HeaderQueryResponse;
typedef agrirouter::feed::response::MessageQueryResponse MessageQueryResponse;
typedef agrirouter::feed::response::FailedMessageQueryResponse FailedMessageQueryResponse;
typedef agrirouter::feed::push::notification::PushNotification PushNotification;
typedef agrirouter::commons::Message CommonsMessage;
typedef agrirouter::commons::Messages CommonsMessages;
typedef agrirouter::commons::ChunkComponent ChunkComponent;
typedef efdi::ISO11783_TaskData ISO11783_TaskData;
typedef efdi::TimeLog TimeLog;
typedef efdi::Time Time;
typedef efdi::Task Task;
typedef efdi::DataLogValue DataLogValue;
typedef efdi::Position Position;
typedef google::protobuf::Any Any;
typedef google::protobuf::Timestamp Timestamp;
typedef google::protobuf::Message Message;
typedef google::protobuf::MessageLite MessageLite;
typedef google::protobuf::io::ZeroCopyInputStream ZeroCopyInputStream;
typedef google::protobuf::io::ZeroCopyOutputStream ZeroCopyOutputStream;
typedef google::protobuf::io::CodedInputStream CodedInputStream;
typedef google::protobuf::io::CodedOutputStream CodedOutputStream;
typedef google::protobuf::io::StringOutputStream StringOutputStream;
// Error struct for callback functions
typedef struct Error
{
std::string code = "";
std::string message = "";
std::string applicationMessageId = "";
} Error;
// Struct for connection parameters received in onboard reponse
typedef struct ConnectionParameters
{
std::string deviceAlternateId = "";
std::string capabilityAlternateId = "";
std::string sensorAlternateId = "";
std::string certificateType = "";
std::string secret = "";
std::string measuresUrl = "";
std::string commandsUrl = "";
std::string gatewayId = "";
std::string host = "";
uint16_t port = 0;
std::string clientId = "";
} ConnectionParameters;
// Struct for message parameters used for communication
typedef struct MessageParameters
{
int event = 0;
std::string applicationMessageId = "";
void *member = nullptr;
} MessageParameters;
// Struct for evaluating the mode. DIRECT: with recipients, PUBLISH: without
// recipients, PUBLISH_WITH_DIRECT: with recipients
typedef struct Addressing
{
RequestEnvelope::Mode mode = RequestEnvelope::Mode::RequestEnvelope_Mode_DIRECT;
std::list<std::string> recipients = std::list<std::string>();
} Addressing;
// Struct for application settings
typedef struct ApplicationSettings
{
std::string applicationId = "";
std::string certificationVersionId = "";
std::string externalId = "";
std::string locationCertsAndIds = "";
std::string teamsetContextId = "";
std::string connectionType = "";
bool acceptSelfSignedCertificate = false;
} ApplicationSettings;
// Struct for agrirouter settings
typedef struct AgrirouterSettings
{
std::string registrationServicePath = "";
std::string landscape = "";
std::string cfHost = "";
std::string apiPrefix = "";
std::string registrationUrl = "";
} AgrirouterSettings;
// Struct for handling binary data
typedef struct BinaryData
{
unsigned char* data = nullptr;
int size = 0;
} BinaryData;
// Function pointer for callback functions
typedef size_t (*TokenCallback) (std::string token, Error error);
typedef size_t (*GetMessagesCallback) ( google::protobuf::RepeatedPtrField<CommonsMessage>, Error error);
const static std::string logLevelTexts[8] = {"", "CRITICAL", "ERROR ", "WARNING ", "MESSAGE ", "NOTICE ", "TRACE ", "DEBUG "};
static inline std::string getLogLevelText(int logLevel)
{
return logLevelTexts[logLevel];
}
#endif // LIB_AGRIROUTERCLIENT_INC_DEFINITIONS_H_