-
Notifications
You must be signed in to change notification settings - Fork 84
/
gateway.proto
360 lines (271 loc) · 9.29 KB
/
gateway.proto
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
syntax = "proto3";
package api;
option go_package = "github.com/brocaar/chirpstack-api/go/v3/as/external/api";
option java_package = "io.chirpstack.api.as.external.api";
option java_multiple_files = true;
option java_outer_classname = "GatewayProto";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
import "common/common.proto";
import "as/external/api/frameLog.proto";
// GatewayService is the service managing the gateways.
service GatewayService {
// Create creates the given gateway.
rpc Create(CreateGatewayRequest) returns (google.protobuf.Empty) {
option(google.api.http) = {
post: "/api/gateways"
body: "*"
};
}
// Get returns the gateway for the requested mac address.
rpc Get(GetGatewayRequest) returns (GetGatewayResponse) {
option (google.api.http) = {
get: "/api/gateways/{id}"
};
}
// Update updates the gateway matching the given mac address.
rpc Update(UpdateGatewayRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
put: "/api/gateways/{gateway.id}"
body: "*"
};
}
// Delete deletes the gateway matching the given mac address.
rpc Delete(DeleteGatewayRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/api/gateways/{id}"
};
}
// List lists the gateways.
rpc List(ListGatewayRequest) returns (ListGatewayResponse) {
option (google.api.http) = {
get: "/api/gateways"
};
}
// GetStats lists the gateway stats given the query parameters.
rpc GetStats(GetGatewayStatsRequest) returns (GetGatewayStatsResponse) {
option (google.api.http) = {
get: "/api/gateways/{gateway_id}/stats"
};
}
// GetLastPing returns the last emitted ping and gateways receiving this ping.
rpc GetLastPing(GetLastPingRequest) returns (GetLastPingResponse) {
option (google.api.http) = {
get: "/api/gateways/{gateway_id}/pings/last"
};
}
// GenerateGatewayClientCertificate returns TLS certificate gateway authentication / authorization.
// This endpoint can ony be used when ChirpStack Network Server is configured with a gateway
// CA certificate and key, which is used for signing the TLS certificate. The returned TLS
// certificate will have the Gateway ID as Common Name.
rpc GenerateGatewayClientCertificate(GenerateGatewayClientCertificateRequest) returns (GenerateGatewayClientCertificateResponse) {
option(google.api.http) = {
post: "/api/gateways/{gateway_id}/generate-certificate"
};
}
// StreamFrameLogs streams the uplink and downlink frame-logs for the given gateway ID.
// Notes:
// * These are the raw LoRaWAN frames and this endpoint is intended for debugging only.
// * This endpoint does not work from a web-browser.
rpc StreamFrameLogs(StreamGatewayFrameLogsRequest) returns (stream StreamGatewayFrameLogsResponse) {
option (google.api.http) = {
get: "/api/gateways/{gateway_id}/frames"
};
}
}
message Gateway {
// Gateway ID (HEX encoded).
string id = 1;
// Gateway name.
string name = 2;
// Gateway description.
string description = 3;
// Gateway location.
common.Location location = 4;
// Organization ID to which the gateway belongs.
// This can't be changed after creating the gateway.
int64 organization_id = 5 [json_name = "organizationID"];
// Set to true to enable gateway discovery.
bool discovery_enabled = 6;
// Network-server ID on which the gateway is provisioned.
int64 network_server_id = 7 [json_name = "networkServerID"];
// Gateway-profile ID (UUID string, optional).
string gateway_profile_id = 8 [json_name = "gatewayProfileID"];
// Gateway boards configuration (optional).
// This is (currently) only needed when the gateway supports the fine-timestamp
// and you you would like to add the FPGA ID to the gateway meta-data or would
// like ChirpStack Network Server to decrypt the fine-timestamp.
repeated GatewayBoard boards = 9;
// Tags (user defined).
map<string, string> tags = 10;
// Metadata (provided by the gateway).
map<string, string> metadata = 11;
// Service-profile ID (UUID string, optional).
string service_profile_id = 12 [json_name = "serviceProfileID"];
}
message GatewayBoard {
// FPGA ID of the gateway (HEX encoded) (optional).
string fpga_id = 1 [json_name = "fpgaID"];
// Fine-timestamp AES decryption key (HEX encoded) (optional).
string fine_timestamp_key = 2;
}
message CreateGatewayRequest {
// Gateway object to create.
Gateway gateway = 1;
}
message GetGatewayRequest {
// Gateway ID (HEX encoded).
string id = 1;
}
message GetGatewayResponse {
// Gateway object.
Gateway gateway = 1;
// Created at timestamp.
google.protobuf.Timestamp created_at = 2;
// Last update timestamp.
google.protobuf.Timestamp updated_at = 3;
// First seen at timestamp.
google.protobuf.Timestamp first_seen_at = 4;
// Last seen at timestamp.
google.protobuf.Timestamp last_seen_at = 5;
};
message DeleteGatewayRequest {
// Gateway ID (HEX encoded).
string id = 1;
}
message GenerateGatewayClientCertificateRequest {
// Gateway ID (HEX encoded).
string gateway_id = 1;
}
message GenerateGatewayClientCertificateResponse {
// TLS certificate.
string tls_cert = 1;
// TLS key.
string tls_key = 2;
// CA certificate.
string ca_cert = 3;
// Expires at defines the expiration date of the certificate.
google.protobuf.Timestamp expires_at = 4;
}
message ListGatewayRequest {
// Max number of nodes to return in the result-set.
int32 limit = 1;
// Offset of the result-set (for pagination).
int32 offset = 2;
// ID of the organization for which to filter on, when left blank the
// response will return all gateways to which the user has access to.
int64 organization_id = 3 [json_name = "organizationID"];
// Search on name or gateway MAC (optional).
string search = 4;
}
message GatewayListItem {
// Gateway ID (HEX encoded).
string id = 1;
// A name for the gateway
string name = 2;
// A description for the gateway
string description = 3;
// Create timestamp.
google.protobuf.Timestamp created_at = 4;
// Last update timestamp.
google.protobuf.Timestamp updated_at = 5;
// First seen timestamp.
google.protobuf.Timestamp first_seen_at = 8;
// Last seen timestamp.
google.protobuf.Timestamp last_seen_at = 9;
// Organization ID.
int64 organization_id = 6 [json_name = "organizationID"];
// Network-server ID.
int64 network_server_id = 7 [json_name = "networkServerID"];
// Location.
common.Location location = 10;
// Network-server name.
string network_server_name = 11;
}
message ListGatewayResponse {
// Total number of nodes available within the result-set.
int64 total_count = 1;
// Nodes within this result-set.
repeated GatewayListItem result = 2;
}
message UpdateGatewayRequest {
// Gateway object to update.
Gateway gateway = 1;
}
message GatewayStats {
// Timestamp of the (aggregated) measurement.
google.protobuf.Timestamp timestamp = 1;
// Packets received by the gateway.
int32 rx_packets_received = 2;
// Packets received by the gateway that passed the CRC check.
int32 rx_packets_received_ok = 3 [json_name = "rxPacketsReceivedOK"];
// Packets received by the gateway for transmission.
int32 tx_packets_received = 4;
// Packets transmitted by the gateway.
int32 tx_packets_emitted = 5;
// Tx packets per frequency.
map<uint32, uint32> tx_packets_per_frequency = 6;
// Rx packets per frequency.
map<uint32, uint32> rx_packets_per_frequency = 7;
// Tx packets per DR.
map<uint32, uint32> tx_packets_per_dr = 8;
// Rx packets per DR.
map<uint32, uint32> rx_packets_per_dr = 9;
// Tx packets per status.
map<string, uint32> tx_packets_per_status = 10;
}
message GetGatewayStatsRequest {
// Gateway ID (HEX encoded).
string gateway_id = 1 [json_name = "gatewayID"];
// Aggregation interval. One of "second", "minute", "hour", "day", "week",
// "month", "quarter", "year". Case insensitive.
string interval = 2;
// Timestamp to start from.
google.protobuf.Timestamp start_timestamp = 3;
// Timestamp until to get from.
google.protobuf.Timestamp end_timestamp = 4;
}
message GetGatewayStatsResponse {
repeated GatewayStats result = 1;
}
message PingRX {
// Gateway ID (HEX encoded).
string gateway_id = 1 [json_name = "gatewayID"];
// RSSI.
int32 rssi = 2;
// LoRa SNR.
double lora_snr = 3 [json_name = "loRaSNR"];
// Latitude of the gateway -90.0 to 90.0.
double latitude = 4;
// Longitude of the gateway -180.0 to 180.0.
double longitude = 5;
// Altitude of the gateway in meters.
double altitude = 6;
}
message GetLastPingRequest {
// Gateway ID (HEX encoded).
string gateway_id = 1 [json_name = "gatewayID"];
}
message GetLastPingResponse {
// Created at timestamp.
google.protobuf.Timestamp created_at = 1;
// Frequency (Hz).
uint32 frequency = 2;
// Data-rate.
uint32 dr = 3;
// Gateways and meta-data of reception.
repeated PingRX ping_rx = 4 [json_name = "pingRX"];
}
message StreamGatewayFrameLogsRequest {
// Gateway ID (HEX encoded).
string gateway_id = 1 [json_name = "gatewayID"];
}
message StreamGatewayFrameLogsResponse {
oneof frame {
// Contains an uplink frame.
UplinkFrameLog uplink_frame = 1;
// Contains a downlink frame.
DownlinkFrameLog downlink_frame = 2;
}
}