chirpstack_api 3.7.6

ChirpStack Protobuf / gRPC API definitions.
Documentation
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
syntax = "proto3";

package ns;

option go_package = "github.com/brocaar/chirpstack-api/ns";

import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
import "common/common.proto";
import "gw/gw.proto";
import "ns/profiles.proto";


// NetworkServerService provides the network-server API methods.
service NetworkServerService {
    // CreateServiceProfile creates the given service-profile.
    rpc CreateServiceProfile(CreateServiceProfileRequest) returns (CreateServiceProfileResponse) {}

    // GetServiceProfile returns the service-profile matching the given id.
    rpc GetServiceProfile(GetServiceProfileRequest) returns (GetServiceProfileResponse) {}

    // UpdateServiceProfile updates the given service-profile.
    rpc UpdateServiceProfile(UpdateServiceProfileRequest) returns (google.protobuf.Empty) {}

    // DeleteServiceProfile deletes the service-profile matching the given id.
    rpc DeleteServiceProfile(DeleteServiceProfileRequest) returns (google.protobuf.Empty) {}

    // CreateRoutingProfile creates the given routing-profile.
    rpc CreateRoutingProfile(CreateRoutingProfileRequest) returns (CreateRoutingProfileResponse) {}

    // GetRoutingProfile returns the routing-profile matching the given id.
    rpc GetRoutingProfile(GetRoutingProfileRequest) returns (GetRoutingProfileResponse) {}

    // UpdateRoutingProfile updates the given routing-profile.
    rpc UpdateRoutingProfile(UpdateRoutingProfileRequest) returns (google.protobuf.Empty) {}

    // DeleteRoutingProfile deletes the routing-profile matching the given id.
    rpc DeleteRoutingProfile(DeleteRoutingProfileRequest) returns (google.protobuf.Empty) {}

    // CreateDeviceProfile creates the given device-profile.
    rpc CreateDeviceProfile(CreateDeviceProfileRequest) returns (CreateDeviceProfileResponse) {}

    // GetDeviceProfile returns the device-profile matching the given id.
    rpc GetDeviceProfile(GetDeviceProfileRequest) returns (GetDeviceProfileResponse) {}

    // UpdateDeviceProfile updates the given device-profile.
    rpc UpdateDeviceProfile(UpdateDeviceProfileRequest) returns (google.protobuf.Empty) {}

    // DeleteDeviceProfile deletes the device-profile matching the given id.
    rpc DeleteDeviceProfile(DeleteDeviceProfileRequest) returns (google.protobuf.Empty) {}

    // CreateDevice creates the given device.
    rpc CreateDevice(CreateDeviceRequest) returns (google.protobuf.Empty) {}

    // GetDevice returns the device matching the given DevEUI.
    rpc GetDevice(GetDeviceRequest) returns (GetDeviceResponse) {}

    // UpdateDevice updates the given device.
    rpc UpdateDevice(UpdateDeviceRequest) returns (google.protobuf.Empty) {}

    // DeleteDevice deletes the device matching the given DevEUI.
    rpc DeleteDevice(DeleteDeviceRequest) returns (google.protobuf.Empty) {}

    // ActivateDevice activates a device (ABP).
    rpc ActivateDevice(ActivateDeviceRequest) returns (google.protobuf.Empty) {}

    // DeactivateDevice de-activates a device.
    rpc DeactivateDevice(DeactivateDeviceRequest) returns (google.protobuf.Empty) {}

    // GetDeviceActivation returns the device activation details.
    rpc GetDeviceActivation(GetDeviceActivationRequest) returns (GetDeviceActivationResponse) {}

    // CreateDeviceQueueItem creates the given device-queue item.
    rpc CreateDeviceQueueItem(CreateDeviceQueueItemRequest) returns (google.protobuf.Empty) {}

    // FlushDeviceQueueForDevEUI flushes the device-queue for the given DevEUI.
    rpc FlushDeviceQueueForDevEUI(FlushDeviceQueueForDevEUIRequest) returns (google.protobuf.Empty) {}

    // GetDeviceQueueItemsForDevEUI returns all device-queue items for the given DevEUI.
    rpc GetDeviceQueueItemsForDevEUI(GetDeviceQueueItemsForDevEUIRequest) returns (GetDeviceQueueItemsForDevEUIResponse) {}

    // GetNextDownlinkFCntForDevEUI returns the next FCnt that must be used.
    // This also takes device-queue items for the given DevEUI into consideration.
    rpc GetNextDownlinkFCntForDevEUI(GetNextDownlinkFCntForDevEUIRequest) returns (GetNextDownlinkFCntForDevEUIResponse) {}

    // GetRandomDevAddr returns a random DevAddr taking the NwkID prefix into account.
    rpc GetRandomDevAddr(google.protobuf.Empty) returns (GetRandomDevAddrResponse) {}

    // CreateMACCommandQueueItem adds the downlink mac-command to the queue.
    rpc CreateMACCommandQueueItem(CreateMACCommandQueueItemRequest) returns (google.protobuf.Empty) {}

    // SendProprietaryPayload send a payload using the 'Proprietary' LoRaWAN message-type.
    rpc SendProprietaryPayload(SendProprietaryPayloadRequest) returns (google.protobuf.Empty) {}

    // CreateGateway creates the given gateway.
    rpc CreateGateway(CreateGatewayRequest) returns (google.protobuf.Empty) {}

    // GetGateway returns data for a particular gateway.
    rpc GetGateway(GetGatewayRequest) returns (GetGatewayResponse) {}

    // UpdateGateway updates an existing gateway.
    rpc UpdateGateway(UpdateGatewayRequest) returns (google.protobuf.Empty) {}

    // DeleteGateway deletes a gateway.
    rpc DeleteGateway(DeleteGatewayRequest) returns (google.protobuf.Empty) {}

    // 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) {}

    // CreateGatewayProfile creates the given gateway-profile.
    rpc CreateGatewayProfile(CreateGatewayProfileRequest) returns (CreateGatewayProfileResponse) {}

    // GetGatewayProfile returns the gateway-profile given an id.
    rpc GetGatewayProfile(GetGatewayProfileRequest) returns (GetGatewayProfileResponse) {}

    // UpdateGatewayProfile updates the given gateway-profile.
    rpc UpdateGatewayProfile(UpdateGatewayProfileRequest) returns (google.protobuf.Empty) {}

    // DeleteGatewayProfile deletes the gateway-profile matching a given id.
    rpc DeleteGatewayProfile(DeleteGatewayProfileRequest) returns (google.protobuf.Empty) {}

    // GetGatewayStats returns stats of an existing gateway.
    // Deprecated (stats are forwarded to Application Server API).
    rpc GetGatewayStats(GetGatewayStatsRequest) returns (GetGatewayStatsResponse) {}

    // StreamFrameLogsForGateway returns a stream of frames seen by the given gateway.
    rpc StreamFrameLogsForGateway(StreamFrameLogsForGatewayRequest) returns (stream StreamFrameLogsForGatewayResponse) {}

    // StreamFrameLogsForDevice returns a stream of frames seen by the given device.
    rpc StreamFrameLogsForDevice(StreamFrameLogsForDeviceRequest) returns (stream StreamFrameLogsForDeviceResponse) {}

    // CreateMulticastGroup creates the given multicast-group.
    rpc CreateMulticastGroup(CreateMulticastGroupRequest) returns (CreateMulticastGroupResponse) {}

    // GetMulticastGroup returns the multicast-group given an id.
    rpc GetMulticastGroup(GetMulticastGroupRequest) returns (GetMulticastGroupResponse) {}

    // UpdateMulticastGroup updates the given multicast-group.
    rpc UpdateMulticastGroup(UpdateMulticastGroupRequest) returns (google.protobuf.Empty) {}

    // DeleteMulticastGroup deletes a multicast-group given an id.
    rpc DeleteMulticastGroup(DeleteMulticastGroupRequest) returns (google.protobuf.Empty) {}

    // AddDeviceToMulticastGroup adds the given device to the given multicast-group.
    rpc AddDeviceToMulticastGroup(AddDeviceToMulticastGroupRequest) returns (google.protobuf.Empty) {}

    // RemoveDeviceFromMulticastGroup removes the given device from the given multicast-group.
    rpc RemoveDeviceFromMulticastGroup(RemoveDeviceFromMulticastGroupRequest) returns (google.protobuf.Empty) {}

    // EnqueueMulticastQueueItem enqueues the given multicast queue-item and
    // increments the frame-counter after enqueueing.
    rpc EnqueueMulticastQueueItem(EnqueueMulticastQueueItemRequest) returns (google.protobuf.Empty) {}

    // FlushMulticastQueueForMulticastGroup flushes the multicast device-queue given a multicast-group id.
    rpc FlushMulticastQueueForMulticastGroup(FlushMulticastQueueForMulticastGroupRequest) returns (google.protobuf.Empty) {}

    // GetMulticastQueueItemsForMulticastGroup returns the queue-items given a multicast-group id.
    rpc GetMulticastQueueItemsForMulticastGroup(GetMulticastQueueItemsForMulticastGroupRequest) returns (GetMulticastQueueItemsForMulticastGroupResponse) {}

    // GetVersion returns the ChirpStack Network Server version.
    rpc GetVersion(google.protobuf.Empty) returns (GetVersionResponse) {}
}

enum RXWindow {
    // Receive window 1
    RX1 = 0;

    // Receive window 2
    RX2 = 1;
}

message CreateServiceProfileRequest {
    // Service-profile object to create.
    ServiceProfile service_profile = 1;
}

message CreateServiceProfileResponse {
    // ID of the created service-profile.
    bytes id = 1;
}

message GetServiceProfileRequest {
    // ID of the service-profile.
    bytes id = 1;
}

message GetServiceProfileResponse {
    // Service-profile object.
    ServiceProfile service_profile = 1;

    // Created at timestamp.
    google.protobuf.Timestamp created_at = 2;

    // Last update timestamp.
    google.protobuf.Timestamp updated_at = 3;
}

message UpdateServiceProfileRequest {
    // Service-profile object to update.
    ServiceProfile service_profile = 1;
}

message DeleteServiceProfileRequest {
    // ID of the service-profile.
    bytes id = 1;
}


message CreateRoutingProfileRequest {
    // Routing-profile object to create.
    RoutingProfile routing_profile = 1;

}

message CreateRoutingProfileResponse {
    // ID of the created routing-profile.
    bytes id = 1;
}

message GetRoutingProfileRequest {
    // ID of the routing-profile.
    bytes id = 1;
}

message GetRoutingProfileResponse {
    // Routing-profile object.
    RoutingProfile routing_profile = 1;

    // Created at timestamp.
    google.protobuf.Timestamp created_at = 2;

    // Last update timestamp.
    google.protobuf.Timestamp updated_at = 3;
}

message UpdateRoutingProfileRequest {
    // Routing-profile object to update.
    RoutingProfile routing_profile = 1;
}

message DeleteRoutingProfileRequest {
    // Routing-profile ID.
    bytes id = 1;
}

message CreateDeviceProfileRequest {
    // Device-profile object to create.
    DeviceProfile device_profile = 1;
}

message CreateDeviceProfileResponse {
    // ID of the created device-profile.
    bytes id = 1;
}

message GetDeviceProfileRequest {
    // Device-profile ID.
    bytes id = 1;
}

message GetDeviceProfileResponse {
    // Device-profile object.
    DeviceProfile device_profile = 1;

    // Created at timestamp.
    google.protobuf.Timestamp created_at = 2;

    // Last update timestamp.
    google.protobuf.Timestamp updated_at = 3;
}

message UpdateDeviceProfileRequest {
    // Device-profile object to update.
    DeviceProfile device_profile = 1;
}

message DeleteDeviceProfileRequest {
    // Device-profile ID.
    bytes id = 1;
}

message Device {
    // DevEUI.
    bytes dev_eui = 1;

    // Device-profile ID.
    bytes device_profile_id = 2;

    // Service-profile ID.
    bytes service_profile_id = 3;

    // Routing-profile ID.
    bytes routing_profile_id = 4;

    // Skip frame-counter check.
    // Note that turning this on is insecure and is intended for debugging only.
    bool skip_f_cnt_check = 5;

    // Reference altitude.
    // When using geolocation, this altitude will be used as a reference
    // (when supported by the geolocation-server) to increase geolocation
    // accuracy.
    double reference_altitude = 6;

    // Device is disabled.
    bool is_disabled = 7;
}

message CreateDeviceRequest {
    // Device object to create.
    Device device = 1;
}

message GetDeviceRequest {
    // DevEUI.
    bytes dev_eui = 1;
}

message GetDeviceResponse {
    // Device object.
    Device device = 1;

    // Created at timestamp.
    google.protobuf.Timestamp created_at = 2;

    // Last update timestamp.
    google.protobuf.Timestamp updated_at = 3;
}

message UpdateDeviceRequest {
    // Device object to update.
    Device device = 1;
}

message DeleteDeviceRequest {
    // DevEUI.
    bytes dev_eui = 1;
}

message DeviceActivation {
    // DevEUI.
    bytes dev_eui = 1;

    // Device address (DevAddr).
    bytes dev_addr = 2;

    // SNwkSIntKey (serving network-server session integrity key).
    bytes s_nwk_s_int_key = 3;

    // FNwkSIntKey (forwarding network-server session integrity key).
    bytes f_nwk_s_int_key = 4;

    // NwkSEncKey (network-server session encryption key).
    bytes nwk_s_enc_key = 5;

    // The next expected uplink frame-counter.
    uint32 f_cnt_up = 6;

    // The network frame-counter used for the next downlink frame.
    uint32 n_f_cnt_down = 7;

    // The application frame-counter used for the next downlink frame (LoRaWAN 1.1).
    uint32 a_f_cnt_down = 8;

    // Skip frame-counter checks (this is insecure, but could be helpful for debugging).
    bool skip_f_cnt_check = 9;
}

message ActivateDeviceRequest {
    // Device-activation to activate a device (ABP).
    DeviceActivation device_activation = 1;
}

message DeactivateDeviceRequest {
    // Device EUI (8 bytes).
    bytes dev_eui = 1;
}

message GetDeviceActivationRequest {
    // Device EUI (8 bytes).
    bytes dev_eui = 1;
}

message GetDeviceActivationResponse {
    // Device-activation object.
    DeviceActivation device_activation = 1;
}

message GetRandomDevAddrResponse {
    // Random device address (DevAddr).
    // Note that this includes the NetID prefix of the network-server.
    bytes dev_addr = 1;
}

message CreateMACCommandQueueItemRequest {
    // DevEUI EUI (8 bytes).
    bytes dev_eui = 1;

    // Command identifier (specified by the LoRaWAN specs).
    uint32 cid = 4;

    // MAC-command(s). In case multiple payloads are defined, then they
    // are always sent within a single frame.
    repeated bytes commands = 5;
}

message SendProprietaryPayloadRequest {
    // MACPayload of the proprietary LoRaWAN frame.
    bytes mac_payload = 1;

    // MIC of the proprietary LoRaWAN frame (must be 4 bytes).
    bytes mic = 2;

    // Gateway MAC address(es) to use for transmitting the LoRaWAN frame.
    repeated bytes gateway_macs = 3;

    // Set to true for sending as a gateway, or false for sending as a node.
    // In the latter case the frame will be received by other gateways.
    bool polarization_inversion = 4;

    // Frequency (Hz) to use for the transmission.
    uint32 frequency = 5;

    // Data-rate to use for the transmission.
    uint32 dr = 6;
}

message Gateway {
    // Gateway ID (8 bytes EUI64).
    bytes id = 1;

    // Gateway location.
    common.Location location = 2;

    // ID of the gateway-profile (optional).
    bytes gateway_profile_id = 3;

    // 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 = 4;

    // Routing Profile ID.
    // The routing-profile ID defines to which application-server statistical
    // data for this gateway is forwarded.
    bytes routing_profile_id = 5;
}

message GatewayBoard {
    // FPGA ID of the gateway (8 bytes) (optional).
    bytes fpga_id = 1;

    // Fine-timestamp AES decryption key (16 bytes) (optional).
    bytes fine_timestamp_key = 2;
}

message CreateGatewayRequest {
    // Gateway object to create.
    Gateway gateway = 1;
}

message GetGatewayRequest {
    // Gateway ID.
    bytes 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 timestamp.
    google.protobuf.Timestamp first_seen_at = 4;

    // Last seen timestamp.
    google.protobuf.Timestamp last_seen_at = 5;
}

message UpdateGatewayRequest {
    // Gateway object to update.
    Gateway gateway = 1;
}

message DeleteGatewayRequest {
    // Gateway ID.
    bytes id = 1;
}

message GenerateGatewayClientCertificateRequest {
    // Gateway ID.
    bytes id = 1;
}

message GenerateGatewayClientCertificateResponse {
    // TLS certificate.
    bytes tls_cert = 1;

    // TLS key.
    bytes tls_key = 2;

    // CA certificate.
    bytes ca_cert = 3;
}

enum AggregationInterval {
    SECOND = 0;
    MINUTE = 1;
    HOUR = 2;
    DAY = 3;
    WEEK = 4;
    MONTH = 5;
    QUARTER = 6;
    YEAR = 7;
}

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;

    // Packets received by the gateway for transmission.
    int32 tx_packets_received = 4;

    // Packets transmitted by the gateway.
    int32 tx_packets_emitted = 5;
}

message GetGatewayStatsRequest {
    // MAC address of the gateway.
    bytes gateway_id = 1;

    // Aggregation interval.
    AggregationInterval 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 DeviceQueueItem {
    // DevEUI of the device.
    bytes dev_eui = 1;

    // The encrypted FRMPayload bytes.
    bytes frm_payload = 2;

    // The FCnt of the payload.
    uint32 f_cnt = 3;

    // The FPort of the payload.
    uint32 f_port = 4;

    // When set to true, ChirpStack Network Server will wait for the device to ack the
    // received frame.
    bool confirmed = 5;

    // Device address (as known by the application-server).
    // It will be used to validate that the application-server is
    // using the correct security context of the device. As on OTAA, there
    // is a gap between the activation and the delivery of the AppSKey to the
    // application-server, there is a possibility that the application-server
    // tries to enqueue payloads encrypted with the old session-key.
    bytes dev_addr = 6;
}

message CreateDeviceQueueItemRequest {
    DeviceQueueItem item = 1;
}

message FlushDeviceQueueForDevEUIRequest {
    // DevEUI of the device.
    bytes dev_eui = 1;
}

message GetDeviceQueueItemsForDevEUIRequest {
    // DevEUI of the device.
    bytes dev_eui = 1;

    // Return only the count, not the result-set.
    bool count_only = 2;
}

message GetDeviceQueueItemsForDevEUIResponse {
    // The device queue items.
    repeated DeviceQueueItem items = 1;

    // Total number of items in the queue.
    uint32 total_count = 2;
}

message GetNextDownlinkFCntForDevEUIRequest {
    // DevEUI of the device.
    bytes dev_eui = 1;
}

message GetNextDownlinkFCntForDevEUIResponse {
    // The frame-counter to use.
    uint32 f_cnt = 1;
}

message UplinkFrameLog {
    // PHYPayload.
    bytes phy_payload = 1;

    // TX meta-data.
    gw.UplinkTXInfo tx_info = 2;

    // RX meta-data.
    repeated gw.UplinkRXInfo rx_info = 3;
}

message DownlinkFrameLog {
    // PHYPayload.
    bytes phy_payload = 1;

    // TX meta-data.
    gw.DownlinkTXInfo tx_info = 2;

    // Token (uint16 value).
    // Deprecated: replaced by downlink_id.
    uint32 token = 3;

    // Downlink ID (UUID).
    bytes downlink_id = 4 [json_name = "downlinkID"];

    // Gateway ID.
    bytes gateway_id = 5 [json_name = "gatewayID"];
}

message StreamFrameLogsForGatewayRequest {
    // MAC address of the gateway.
    bytes gateway_id = 1;
}

message StreamFrameLogsForGatewayResponse {
    oneof frame {
        // Contains an uplink frame.
        UplinkFrameLog uplink_frame_set = 1;

        // Contains a downlink frame.
        DownlinkFrameLog downlink_frame = 2;
    }
}

message StreamFrameLogsForDeviceRequest {
    // DevEUI of the device.
    bytes dev_eui = 1;
}

message StreamFrameLogsForDeviceResponse {
    oneof frame {
        // Contains an uplink frame.
        UplinkFrameLog uplink_frame_set = 1;

        // Contains a downlink frame.
        DownlinkFrameLog downlink_frame = 2;
    }
}

message GetVersionResponse {
    // ChirpStack Network Server version.
    string version = 1;

    // Region configured for this network-server.
    common.Region region = 2;
}
message GatewayProfile {
    // ID of the gateway-profile.
    bytes id = 1;

    // Default channels (channels specified by the LoRaWAN Regional Parameters
    // specification) enabled for this configuration.
    repeated uint32 channels = 2;

    // Extra channels added to the channel-configuration (in case the LoRaWAN
    // region supports adding custom channels).
    repeated GatewayProfileExtraChannel extra_channels = 3;
}

message GatewayProfileExtraChannel {
    // Modulation.
    common.Modulation modulation = 1;

    // Frequency.
    uint32 frequency = 2;

    // Bandwidth.
    uint32 bandwidth = 3;

    // Bitrate (in case of FSK modulation).
    uint32 bitrate = 4;

    // Spreading factors (in case of LoRa modulation).
    repeated uint32 spreading_factors = 5;
}

message CreateGatewayProfileRequest {
    // Gateway-profile object to create.
    GatewayProfile gateway_profile = 1;
}

message CreateGatewayProfileResponse {
    // ID of the create configuration object.
    bytes id = 1;
}

message GetGatewayProfileRequest {
    // Gateway-profile ID.
    bytes id = 1;
}

message GetGatewayProfileResponse {
    // Gateway-profile object.
    GatewayProfile gateway_profile = 1;

    // Created at timestamp.
    google.protobuf.Timestamp created_at = 2;

    // Last update timestamp.
    google.protobuf.Timestamp updated_at = 3;
}

message UpdateGatewayProfileRequest {
    // Gateway-profile object to update.
    GatewayProfile gateway_profile = 1;
}

message DeleteGatewayProfileRequest {
    // Gateway-profile ID.
    bytes id = 1;
}

enum MulticastGroupType {
    // Class-C.
    CLASS_C = 0;

    // Class-B.
    CLASS_B = 1;
}

message MulticastGroup {
    // Multicast-group ID.
    // Note: this can be set on create. When left blank, a random ID will
    // be generated.
    bytes id = 1;

    // Multicast Address for this group.
    bytes mc_addr = 2;

    // Multicast network session key.
    bytes mc_nwk_s_key = 3;

    // Frame-counter (downlink).
    uint32 f_cnt = 4;

    // Multicast-group type (Class-B or Class-C).
    MulticastGroupType group_type = 5;

    // Data-rate.
    uint32 dr = 6;

    // Frequency (Hz).
    uint32 frequency = 7;

    // Ping-slot period.
    // Mandatory for Class-B multicast groups.
    uint32 ping_slot_period = 8;

    // Service-profile ID.
    bytes service_profile_id = 9;

    // Routing-profile ID.
    bytes routing_profile_id = 10;
}

message CreateMulticastGroupRequest {
    // Multicast-group to create.
    MulticastGroup multicast_group = 1;
}

message CreateMulticastGroupResponse {
    // Multicast-group ID.
    bytes id = 1;
}

message GetMulticastGroupRequest {
    // Multicast-group ID.
    bytes id = 1;
}

message GetMulticastGroupResponse {
    // Multicast-group.
    MulticastGroup multicast_group = 1;

    // Created at timestamp.
    google.protobuf.Timestamp created_at = 2;

    // Last update timestamp.
    google.protobuf.Timestamp updated_at = 3;
}

message UpdateMulticastGroupRequest {
    // Multicast-group to update.
    MulticastGroup multicast_group = 1;
}

message DeleteMulticastGroupRequest {
    // Multicast-group ID.
    bytes id = 1;
}


message AddDeviceToMulticastGroupRequest {
    // Device EUI.
    bytes dev_eui = 1;

    // Multicast-group ID.
    bytes multicast_group_id = 2;
}

message RemoveDeviceFromMulticastGroupRequest {
    // Device EUI.
    bytes dev_eui = 1;

    // Multicast-group ID.
    bytes multicast_group_id = 2;
}

message MulticastQueueItem {
    // Multicast-group id.
    bytes multicast_group_id = 1;

    // Frame-counter of payload.
    uint32 f_cnt = 2;

    // Frame-port of payload.
    uint32 f_port = 3;

    // Encrypted FRMPayload bytes.
    bytes frm_payload = 4;

}

message EnqueueMulticastQueueItemRequest {
    MulticastQueueItem multicast_queue_item = 1;
}

message FlushMulticastQueueForMulticastGroupRequest {
    // Multicast-group id.
    bytes multicast_group_id = 1;
}

message GetMulticastQueueItemsForMulticastGroupRequest {
    // Multicast-group id.
    bytes multicast_group_id = 1;
}

message GetMulticastQueueItemsForMulticastGroupResponse {
    repeated MulticastQueueItem multicast_queue_items = 1;
}