/
lorawan.proto
1588 lines (1467 loc) · 48.9 KB
/
lorawan.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
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
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright © 2019 The Things Network Foundation, The Things Industries B.V.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package ttn.lorawan.v3;
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "thethings/flags/annotations.proto";
import "thethings/json/annotations.proto";
import "ttn/lorawan/v3/identifiers.proto";
import "validate/validate.proto";
option go_package = "go.thethings.network/lorawan-stack/v3/pkg/ttnpb";
// Message represents a LoRaWAN message
message Message {
MHDR m_hdr = 1 [(validate.rules).message.required = true];
bytes mic = 2 [(validate.rules).bytes = {
min_len: 0,
max_len: 4
}];
// Payload represents either MACPayload, RejoinRequestPayload, JoinRequestPayload or JoinAcceptPayload
// - MACPayload length is in range [7:M] bytes, where M is PHY specific.
// - JoinRequestPayload length is 18 bytes.
// - JoinAcceptPayload length is either 12 or 28 bytes.
// - RejoinRequestPayload length is 14 for Type 0 and 2, 19 for Type 1.
oneof Payload {
option (validate.required) = true;
MACPayload mac_payload = 3;
JoinRequestPayload join_request_payload = 4;
JoinAcceptPayload join_accept_payload = 5;
RejoinRequestPayload rejoin_request_payload = 6;
}
reserved 7; // Reserved for proprietary payload.
}
enum MType {
option (thethings.json.enum) = {marshal_as_string: true};
JOIN_REQUEST = 0;
JOIN_ACCEPT = 1;
UNCONFIRMED_UP = 2;
UNCONFIRMED_DOWN = 3;
CONFIRMED_UP = 4;
CONFIRMED_DOWN = 5;
REJOIN_REQUEST = 6;
PROPRIETARY = 7;
}
enum Major {
option (thethings.json.enum) = {
marshal_as_string: true,
prefix: "LORAWAN"
};
LORAWAN_R1 = 0;
}
enum MACVersion {
option (thethings.json.enum) = {
marshal_as_string: true,
prefix: "MAC"
};
option (thethings.flags.enum) = {alias_map: "go.thethings.network/lorawan-stack/v3/pkg/ttnpb.MACVersion_customvalue"};
MAC_UNKNOWN = 0 [(thethings.json.enum_value) = {
aliases: ["unknown"]
}];
MAC_V1_0 = 1 [(thethings.json.enum_value) = {
aliases: [
"1.0",
"1.0.0"
]
}];
MAC_V1_0_1 = 2 [(thethings.json.enum_value) = {
aliases: ["1.0.1"]
}];
MAC_V1_0_2 = 3 [(thethings.json.enum_value) = {
aliases: ["1.0.2"]
}];
MAC_V1_1 = 4 [(thethings.json.enum_value) = {
aliases: [
"1.1",
"1.1.0"
]
}];
MAC_V1_0_3 = 5 [(thethings.json.enum_value) = {
aliases: ["1.0.3"]
}];
MAC_V1_0_4 = 6 [(thethings.json.enum_value) = {
aliases: ["1.0.4"]
}];
}
enum PHYVersion {
option allow_alias = true;
option (thethings.json.enum) = {marshal_as_string: true};
option (thethings.flags.enum) = {alias_map: "go.thethings.network/lorawan-stack/v3/pkg/ttnpb.PHYVersion_customvalue"};
PHY_UNKNOWN = 0 [(thethings.json.enum_value) = {
aliases: ["unknown"]
}];
PHY_V1_0 = 1 [(thethings.json.enum_value) = {
aliases: [
"1.0",
"1.0.0",
"V1_0"
]
}];
TS001_V1_0 = 1;
PHY_V1_0_1 = 2 [(thethings.json.enum_value) = {
aliases: [
"1.0.1",
"V1_0_1"
]
}];
TS001_V1_0_1 = 2;
PHY_V1_0_2_REV_A = 3 [(thethings.json.enum_value) = {
aliases: [
"1.0.2",
"1.0.2-a",
"V1_0_2",
"V1_0_2_REV_A"
]
}];
RP001_V1_0_2 = 3;
PHY_V1_0_2_REV_B = 4 [(thethings.json.enum_value) = {
aliases: [
"1.0.2-b",
"V1_0_2_REV_B"
]
}];
RP001_V1_0_2_REV_B = 4;
PHY_V1_1_REV_A = 5 [(thethings.json.enum_value) = {
aliases: [
"1.1-a",
"1.1.0-a",
"V1_1_REV_A"
]
}];
RP001_V1_1_REV_A = 5;
PHY_V1_1_REV_B = 6 [(thethings.json.enum_value) = {
aliases: [
"1.1-b",
"1.1.0-b",
"V1_1_REV_B"
]
}];
RP001_V1_1_REV_B = 6;
PHY_V1_0_3_REV_A = 7 [(thethings.json.enum_value) = {
aliases: [
"1.0.3-a",
"V1_0_3_REV_A"
]
}];
RP001_V1_0_3_REV_A = 7;
RP002_V1_0_0 = 8;
RP002_V1_0_1 = 9;
RP002_V1_0_2 = 10;
RP002_V1_0_3 = 11;
RP002_V1_0_4 = 12;
}
enum DataRateIndex {
option (thethings.json.enum) = {
marshal_as_number: true,
prefix: "DATA_RATE"
};
option (thethings.flags.enum) = {alias_map: "go.thethings.network/lorawan-stack/v3/pkg/ttnpb.DataRateIndex_customvalue"};
DATA_RATE_0 = 0;
DATA_RATE_1 = 1;
DATA_RATE_2 = 2;
DATA_RATE_3 = 3;
DATA_RATE_4 = 4;
DATA_RATE_5 = 5;
DATA_RATE_6 = 6;
DATA_RATE_7 = 7;
DATA_RATE_8 = 8;
DATA_RATE_9 = 9;
DATA_RATE_10 = 10;
DATA_RATE_11 = 11;
DATA_RATE_12 = 12;
DATA_RATE_13 = 13;
DATA_RATE_14 = 14;
DATA_RATE_15 = 15;
}
enum DataRateOffset {
option (thethings.json.enum) = {
marshal_as_number: true,
prefix: "DATA_RATE_OFFSET"
};
option (thethings.flags.enum) = {alias_map: "go.thethings.network/lorawan-stack/v3/pkg/ttnpb.DataRateOffset_customvalue"};
DATA_RATE_OFFSET_0 = 0;
DATA_RATE_OFFSET_1 = 1;
DATA_RATE_OFFSET_2 = 2;
DATA_RATE_OFFSET_3 = 3;
DATA_RATE_OFFSET_4 = 4;
DATA_RATE_OFFSET_5 = 5;
DATA_RATE_OFFSET_6 = 6;
DATA_RATE_OFFSET_7 = 7;
}
message MHDR {
MType m_type = 1 [(validate.rules).enum.defined_only = true];
Major major = 2 [(validate.rules).enum.defined_only = true];
}
message MACPayload {
FHDR f_hdr = 1 [(validate.rules).message.required = true];
uint32 f_port = 2 [(validate.rules).uint32.lte = 255];
bytes frm_payload = 3;
google.protobuf.Struct decoded_payload = 4;
// Full 32-bit FCnt value. Used internally by Network Server.
uint32 full_f_cnt = 5;
}
message FHDR {
bytes dev_addr = 1 [
(validate.rules).bytes = {
len: 4,
ignore_empty: true
},
(thethings.json.field) = {
marshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.MarshalHEXBytes",
unmarshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.Unmarshal4Bytes"
},
(thethings.flags.field) = {
set_flag_new_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.New4BytesFlag",
set_flag_getter_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.GetExactBytes"
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
type: STRING,
format: "string",
example: "\"2600ABCD\""
}
];
FCtrl f_ctrl = 2 [(validate.rules).message.required = true];
uint32 f_cnt = 3 [(validate.rules).uint32.lte = 65535];
bytes f_opts = 4 [(validate.rules).bytes.max_len = 15];
}
message FCtrl {
bool adr = 1;
bool adr_ack_req = 2; // Only on uplink.
bool ack = 3;
bool f_pending = 4; // Only on downlink.
bool class_b = 5; // Only on uplink.
}
message JoinRequestPayload {
bytes join_eui = 1 [
(validate.rules).bytes = {
len: 8,
ignore_empty: true
},
(thethings.json.field) = {
marshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.MarshalHEXBytes",
unmarshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.Unmarshal8Bytes"
},
(thethings.flags.field) = {
set_flag_new_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.New8BytesFlag",
set_flag_getter_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.GetExactBytes"
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
type: STRING,
format: "string",
example: "\"70B3D57ED000ABCD\""
}
];
bytes dev_eui = 2 [
(validate.rules).bytes = {
len: 8,
ignore_empty: true
},
(thethings.json.field) = {
marshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.MarshalHEXBytes",
unmarshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.Unmarshal8Bytes"
},
(thethings.flags.field) = {
set_flag_new_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.New8BytesFlag",
set_flag_getter_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.GetExactBytes"
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
type: STRING,
format: "string",
example: "\"70B3D57ED000ABCD\""
}
];
bytes dev_nonce = 3 [
(validate.rules).bytes = {
len: 2,
ignore_empty: true
},
(thethings.json.field) = {
marshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.MarshalHEXBytes",
unmarshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.Unmarshal2Bytes"
},
(thethings.flags.field) = {
set_flag_new_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.New2BytesFlag",
set_flag_getter_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.GetExactBytes"
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
type: STRING,
format: "string",
example: "\"ABCD\""
}
];
}
enum JoinRequestType {
option (thethings.json.enum) = {marshal_as_string: true};
REJOIN_CONTEXT = 0; // Resets DevAddr, Session Keys, Frame Counters, Radio Parameters.
REJOIN_SESSION = 1; // Equivalent to the initial JoinRequest.
REJOIN_KEYS = 2; // Resets DevAddr, Session Keys, Frame Counters, while keeping the Radio Parameters.
JOIN = 255; // Normal join-request.
}
enum RejoinRequestType {
option (thethings.json.enum) = {marshal_as_string: true};
CONTEXT = 0; // Resets DevAddr, Session Keys, Frame Counters, Radio Parameters.
SESSION = 1; // Equivalent to the initial JoinRequest.
KEYS = 2; // Resets DevAddr, Session Keys, Frame Counters, while keeping the Radio Parameters.
}
message RejoinRequestPayload {
RejoinRequestType rejoin_type = 1 [(validate.rules).enum.defined_only = true];
bytes net_id = 2 [
(validate.rules).bytes = {
len: 3,
ignore_empty: true
},
(thethings.json.field) = {
marshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.MarshalHEXBytes",
unmarshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.Unmarshal3Bytes"
},
(thethings.flags.field) = {
set_flag_new_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.New3BytesFlag",
set_flag_getter_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.GetExactBytes"
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
type: STRING,
format: "string",
example: "\"000013\""
}
];
bytes join_eui = 3 [
(validate.rules).bytes = {
len: 8,
ignore_empty: true
},
(thethings.json.field) = {
marshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.MarshalHEXBytes",
unmarshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.Unmarshal8Bytes"
},
(thethings.flags.field) = {
set_flag_new_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.New8BytesFlag",
set_flag_getter_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.GetExactBytes"
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
type: STRING,
format: "string",
example: "\"70B3D57ED000ABCD\""
}
];
bytes dev_eui = 4 [
(validate.rules).bytes = {
len: 8,
ignore_empty: true
},
(thethings.json.field) = {
marshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.MarshalHEXBytes",
unmarshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.Unmarshal8Bytes"
},
(thethings.flags.field) = {
set_flag_new_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.New8BytesFlag",
set_flag_getter_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.GetExactBytes"
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
type: STRING,
format: "string",
example: "\"70B3D57ED000ABCD\""
}
];
uint32 rejoin_cnt = 5; // Contains RJCount0 or RJCount1 depending on rejoin_type.
}
message JoinAcceptPayload {
bytes encrypted = 1;
bytes join_nonce = 2 [
(validate.rules).bytes = {
len: 3,
ignore_empty: true
},
(thethings.json.field) = {
marshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.MarshalHEXBytes",
unmarshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.Unmarshal3Bytes"
},
(thethings.flags.field) = {
set_flag_new_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.New3BytesFlag",
set_flag_getter_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.GetExactBytes"
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
type: STRING,
format: "string",
example: "\"ABCDEF\""
}
];
bytes net_id = 3 [
(validate.rules).bytes = {
len: 3,
ignore_empty: true
},
(thethings.json.field) = {
marshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.MarshalHEXBytes",
unmarshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.Unmarshal3Bytes"
},
(thethings.flags.field) = {
set_flag_new_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.New3BytesFlag",
set_flag_getter_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.GetExactBytes"
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
type: STRING,
format: "string",
example: "\"000013\""
}
];
bytes dev_addr = 4 [
(validate.rules).bytes = {
len: 4,
ignore_empty: true
},
(thethings.json.field) = {
marshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.MarshalHEXBytes",
unmarshaler_func: "go.thethings.network/lorawan-stack/v3/pkg/types.Unmarshal4Bytes"
},
(thethings.flags.field) = {
set_flag_new_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.New4BytesFlag",
set_flag_getter_func: "go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-cli/customflags.GetExactBytes"
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
type: STRING,
format: "string",
example: "\"2600ABCD\""
}
];
DLSettings dl_settings = 5 [(validate.rules).message.required = true];
RxDelay rx_delay = 6 [(validate.rules).enum.defined_only = true];
CFList cf_list = 7;
}
message DLSettings {
option (thethings.flags.message) = {
select: true,
set: true
};
DataRateOffset rx1_dr_offset = 1 [(validate.rules).enum.defined_only = true];
DataRateIndex rx2_dr = 2 [(validate.rules).enum.defined_only = true];
// OptNeg is set if Network Server implements LoRaWAN 1.1 or greater.
bool opt_neg = 3;
}
enum CFListType {
option (thethings.json.enum) = {marshal_as_string: true};
FREQUENCIES = 0;
CHANNEL_MASKS = 1;
}
message CFList {
option (thethings.flags.message) = {
select: true,
set: true
};
CFListType type = 1 [(validate.rules).enum.defined_only = true];
// Frequencies to be broadcasted, in hecto-Hz.
// These values are broadcasted as 24 bits unsigned integers.
// This field should not contain default values.
repeated uint32 freq = 2;
// ChMasks controlling the channels to be used.
// Length of this field must be equal to the amount of uplink channels
// defined by the selected frequency plan.
repeated bool ch_masks = 3;
}
enum Class {
option (thethings.json.enum) = {
marshal_as_string: true,
prefix: "CLASS"
};
CLASS_A = 0;
CLASS_B = 1;
CLASS_C = 2;
}
enum TxSchedulePriority {
option (thethings.json.enum) = {marshal_as_string: true};
LOWEST = 0;
LOW = 1;
BELOW_NORMAL = 2;
NORMAL = 3;
ABOVE_NORMAL = 4;
HIGH = 5;
HIGHEST = 6;
}
message LoRaDataRate {
option (thethings.flags.message) = {
select: true,
set: true
};
// Bandwidth (Hz).
uint32 bandwidth = 1;
uint32 spreading_factor = 2;
string coding_rate = 3;
}
message FSKDataRate {
option (thethings.flags.message) = {
select: true,
set: true
};
// Bit rate (bps).
uint32 bit_rate = 1;
}
message LRFHSSDataRate {
option (thethings.flags.message) = {
select: true,
set: true
};
uint32 modulation_type = 1;
// Operating Channel Width (Hz).
uint32 operating_channel_width = 2;
string coding_rate = 3;
}
message DataRate {
option (thethings.flags.message) = {
select: true,
set: true
};
oneof modulation {
option (validate.required) = true;
LoRaDataRate lora = 1;
FSKDataRate fsk = 2;
LRFHSSDataRate lrfhss = 3;
}
}
// TxSettings contains the settings for a transmission.
// This message is used on both uplink and downlink.
// On downlink, this is a scheduled transmission.
message TxSettings {
option (thethings.flags.message) = {
select: true,
set: true
};
// Transmission settings for downlink.
message Downlink {
option (thethings.flags.message) = {
select: true,
set: true
};
// Index of the antenna on which the uplink was received and/or downlink must be sent.
uint32 antenna_index = 1;
// Transmission power (dBm). Only on downlink.
float tx_power = 2;
// Invert LoRa polarization; false for LoRaWAN uplink, true for downlink.
bool invert_polarization = 3;
}
// Data rate.
DataRate data_rate = 1 [(validate.rules).message.required = true];
reserved 2; // data_rate_index
reserved 3; // coding_rate
// Frequency (Hz).
uint64 frequency = 4 [(validate.rules).uint64.gte = 100000];
// Send a CRC in the packet; only on uplink; on downlink, CRC should not be enabled.
bool enable_crc = 5;
// Timestamp of the gateway concentrator when the uplink message was received, or when the downlink message should be transmitted (microseconds).
// On downlink, set timestamp to 0 and time to null to use immediate scheduling.
uint32 timestamp = 6;
// Time of the gateway when the uplink message was received, or when the downlink message should be transmitted.
// For downlink, this requires the gateway to have GPS time synchronization.
google.protobuf.Timestamp time = 7;
// Transmission settings for downlink.
Downlink downlink = 8;
// Concentrator timestamp for the downlink as calculated by the Gateway Server scheduler.
// This value takes into account necessary offsets such as the RTT (Round Trip Time) and TOA (Time Of Arrival).
// This field is set and used only by the Gateway Server.
int64 concentrator_timestamp = 9;
}
message GatewayAntennaIdentifiers {
GatewayIdentifiers gateway_ids = 1 [(validate.rules).message.required = true];
uint32 antenna_index = 2;
}
message ClassBCGatewayIdentifiers {
GatewayIdentifiers gateway_ids = 1 [(validate.rules).message.required = true];
uint32 antenna_index = 2;
uint32 group_index = 3;
}
message UplinkToken {
GatewayAntennaIdentifiers ids = 1 [(validate.rules).message.required = true];
uint32 timestamp = 2;
// Absolute time observed by the server when the uplink message has been received.
google.protobuf.Timestamp server_time = 3;
// Absolute concentrator time as observed by the Gateway Server, accounting for rollovers.
int64 concentrator_time = 4;
// Absolute time observed by the gateway when the uplink has been received.
google.protobuf.Timestamp gateway_time = 5;
}
message DownlinkPath {
// Set uplink token for class A, B or C downlink to the uplink token received from the corresponding RxMetadata. Uplink tokens are opaque to the Network Server.
// Set fixed to force using the specified gateway antenna identifiers for downlink. This can only be used for class B or C downlinks.
oneof path {
option (validate.required) = true;
bytes uplink_token = 1;
GatewayAntennaIdentifiers fixed = 2;
}
}
// TxRequest is a request for transmission.
// If sent to a roaming partner, this request is used to generate the DLMetadata Object (see Backend Interfaces 1.0, Table 22).
// If the gateway has a scheduler, this request is sent to the gateway, in the order of gateway_ids.
// Otherwise, the Gateway Server attempts to schedule the request and creates the TxSettings.
message TxRequest {
Class class = 1;
// Downlink paths used to select a gateway for downlink.
// In class A, the downlink paths are required to only contain uplink tokens.
// In class B and C, the downlink paths may contain uplink tokens and fixed gateways antenna identifiers.
repeated DownlinkPath downlink_paths = 2;
// Rx1 delay (Rx2 delay is Rx1 delay + 1 second).
RxDelay rx1_delay = 3 [(validate.rules).enum.defined_only = true];
// LoRaWAN data rate for Rx1.
DataRate rx1_data_rate = 12;
reserved 4; // rx1_data_rate_index
// Frequency (Hz) for Rx1.
uint64 rx1_frequency = 5;
// LoRaWAN data rate for Rx2.
DataRate rx2_data_rate = 13;
reserved 6; // rx2_data_rate_index
// Frequency (Hz) for Rx2.
uint64 rx2_frequency = 7;
// Priority for scheduling.
// Requests with a higher priority are allocated more channel time than messages with a lower priority, in duty-cycle limited regions.
// A priority of HIGH or higher sets the HiPriorityFlag in the DLMetadata Object.
TxSchedulePriority priority = 8 [(validate.rules).enum.defined_only = true];
// Time when the downlink message should be transmitted.
// This value is only valid for class C downlink; class A downlink uses uplink tokens and class B downlink is scheduled on ping slots.
// This requires the gateway to have GPS time sychronization.
// If the absolute time is not set, the first available time will be used that does not conflict or violate regional limitations.
google.protobuf.Timestamp absolute_time = 9;
// Frequency plan ID from which the frequencies in this message are retrieved.
string frequency_plan_id = 10 [(validate.rules).string.max_len = 64];
reserved 11; // lorawan_phy_version
// Advanced metadata fields
// - can be used for advanced information or experimental features that are not yet formally defined in the API
// - field names are written in snake_case
google.protobuf.Struct advanced = 99;
}
enum MACCommandIdentifier {
option (thethings.json.enum) = {
marshal_as_string: true,
prefix: "CID"
};
CID_RFU_0 = 0;
CID_RESET = 1;
CID_LINK_CHECK = 2;
CID_LINK_ADR = 3;
CID_DUTY_CYCLE = 4;
CID_RX_PARAM_SETUP = 5;
CID_DEV_STATUS = 6;
CID_NEW_CHANNEL = 7;
CID_RX_TIMING_SETUP = 8;
CID_TX_PARAM_SETUP = 9;
CID_DL_CHANNEL = 10;
CID_REKEY = 11;
CID_ADR_PARAM_SETUP = 12;
CID_DEVICE_TIME = 13;
CID_FORCE_REJOIN = 14;
CID_REJOIN_PARAM_SETUP = 15;
CID_PING_SLOT_INFO = 16;
CID_PING_SLOT_CHANNEL = 17;
CID_BEACON_TIMING = 18; // Deprecated
CID_BEACON_FREQ = 19;
CID_DEVICE_MODE = 32;
CID_RELAY_CONF = 64;
CID_RELAY_END_DEVICE_CONF = 65;
CID_RELAY_FILTER_LIST = 66;
CID_RELAY_UPDATE_UPLINK_LIST = 67;
CID_RELAY_CTRL_UPLINK_LIST = 68;
CID_RELAY_CONFIGURE_FWD_LIMIT = 69;
CID_RELAY_NOTIFY_NEW_END_DEVICE = 70;
}
enum RelayCADPeriodicity {
option (thethings.json.enum) = {
marshal_as_string: true,
prefix: "RELAY_CAD_PERIODICITY"
};
RELAY_CAD_PERIODICITY_1_SECOND = 0;
RELAY_CAD_PERIODICITY_500_MILLISECONDS = 1;
RELAY_CAD_PERIODICITY_250_MILLISECONDS = 2;
RELAY_CAD_PERIODICITY_100_MILLISECONDS = 3;
RELAY_CAD_PERIODICITY_50_MILLISECONDS = 4;
RELAY_CAD_PERIODICITY_20_MILLISECONDS = 5; // sic
}
enum RelaySecondChAckOffset {
option (thethings.json.enum) = {
marshal_as_string: true,
prefix: "RELAY_SECOND_CH_ACK_OFFSET"
};
RELAY_SECOND_CH_ACK_OFFSET_0 = 0; // 0 kHz
RELAY_SECOND_CH_ACK_OFFSET_200 = 1; // 200 kHz
RELAY_SECOND_CH_ACK_OFFSET_400 = 2; // 400 kHz
RELAY_SECOND_CH_ACK_OFFSET_800 = 3; // 800 kHz
RELAY_SECOND_CH_ACK_OFFSET_1600 = 4; // 1.6 MHz
RELAY_SECOND_CH_ACK_OFFSET_3200 = 5; // 3.2 MHz
}
enum RelayLimitBucketSize {
option (thethings.json.enum) = {
marshal_as_string: true,
prefix: "RELAY_LIMIT_BUCKET_SIZE"
};
RELAY_LIMIT_BUCKET_SIZE_1 = 0;
RELAY_LIMIT_BUCKET_SIZE_2 = 1;
RELAY_LIMIT_BUCKET_SIZE_4 = 2;
RELAY_LIMIT_BUCKET_SIZE_12 = 3; // sic
}
enum RelaySmartEnableLevel {
option (thethings.json.enum) = {
marshal_as_string: true,
prefix: "RELAY_SMART_ENABLE_LEVEL"
};
RELAY_SMART_ENABLE_LEVEL_8 = 0;
RELAY_SMART_ENABLE_LEVEL_16 = 1;
RELAY_SMART_ENABLE_LEVEL_32 = 2;
RELAY_SMART_ENABLE_LEVEL_64 = 3;
}
enum RelayWORChannel {
option (thethings.json.enum) = {
marshal_as_string: true,
prefix: "RELAY_WOR_CHANNEL"
};
RELAY_WOR_CHANNEL_DEFAULT = 0;
RELAY_WOR_CHANNEL_SECONDARY = 1;
}
enum RelayResetLimitCounter {
option (thethings.json.enum) = {
marshal_as_string: true,
prefix: "RELAY_RESET_LIMIT_COUNTER"
};
RELAY_RESET_LIMIT_COUNTER_ZERO = 0;
RELAY_RESET_LIMIT_COUNTER_RELOAD_RATE = 1;
RELAY_RESET_LIMIT_COUNTER_MAX_VALUE = 2;
RELAY_RESET_LIMIT_COUNTER_NO_RESET = 3;
}
enum RelayCtrlUplinkListAction {
option (thethings.json.enum) = {
marshal_as_string: true,
prefix: "RELAY_CTRL_UPLINK_LIST_ACTION"
};
RELAY_CTRL_UPLINK_LIST_ACTION_READ_W_F_CNT = 0;
RELAY_CTRL_UPLINK_LIST_ACTION_REMOVE_TRUSTED_END_DEVICE = 1;
}
message RelaySecondChannel {
option (thethings.flags.message) = {
select: true,
set: true
};
// The frequency (Hz) offset used for the WOR acknowledgement.
RelaySecondChAckOffset ack_offset = 1 [(validate.rules).enum.defined_only = true];
// The data rate index used by the WOR and WOR acknowledgement.
DataRateIndex data_rate_index = 2 [(validate.rules).enum.defined_only = true];
// The frequency (Hz) used by the wake on radio message.
uint64 frequency = 3 [(validate.rules).uint64.gte = 100000];
}
message RelayUplinkForwardLimits {
option (thethings.flags.message) = {
select: true,
set: true
};
// The multiplier used to compute the total bucket size for the limits.
// The multiplier is multiplied by the reload rate in order to compute the total bucket size.
RelayLimitBucketSize bucket_size = 1 [(validate.rules).enum.defined_only = true];
// The number of tokens which are replenished in the bucket every hour.
uint32 reload_rate = 2 [(validate.rules).uint32.lte = 62];
}
message RelayForwardLimits {
option (thethings.flags.message) = {
select: true,
set: true
};
// The multiplier used to compute the total bucket size for the limits.
// The multiplier is multiplied by the reload rate in order to compute the total bucket size.
RelayLimitBucketSize bucket_size = 1 [(validate.rules).enum.defined_only = true];
// The number of tokens which are replenished in the bucket every hour.
uint32 reload_rate = 2 [(validate.rules).uint32.lte = 126];
}
message RelayEndDeviceAlwaysMode {
option (thethings.flags.message) = {
select: true,
set: true
};
}
message RelayEndDeviceDynamicMode {
option (thethings.flags.message) = {
select: true,
set: true
};
// The number of consecutive uplinks without a valid downlink before the end device attempts
// to use the relay mode to transmit messages.
RelaySmartEnableLevel smart_enable_level = 1 [(validate.rules).enum.defined_only = true];
}
message RelayEndDeviceControlledMode {
option (thethings.flags.message) = {
select: true,
set: true
};
}
message MACCommand {
MACCommandIdentifier cid = 1 [(validate.rules).enum = {
defined_only: true,
not_in: [0]
}];
oneof payload {
bytes raw_payload = 2;
ResetInd reset_ind = 3;
ResetConf reset_conf = 4;
LinkCheckAns link_check_ans = 5;
LinkADRReq link_adr_req = 6;
LinkADRAns link_adr_ans = 7;
DutyCycleReq duty_cycle_req = 8;
RxParamSetupReq rx_param_setup_req = 9;
RxParamSetupAns rx_param_setup_ans = 10;
DevStatusAns dev_status_ans = 11;
NewChannelReq new_channel_req = 12;
NewChannelAns new_channel_ans = 13;
DLChannelReq dl_channel_req = 14;
DLChannelAns dl_channel_ans = 15;
RxTimingSetupReq rx_timing_setup_req = 16;
TxParamSetupReq tx_param_setup_req = 17;
RekeyInd rekey_ind = 18;
RekeyConf rekey_conf = 19;
ADRParamSetupReq adr_param_setup_req = 20;
DeviceTimeAns device_time_ans = 21;
ForceRejoinReq force_rejoin_req = 22;
RejoinParamSetupReq rejoin_param_setup_req = 23;
RejoinParamSetupAns rejoin_param_setup_ans = 24;
PingSlotInfoReq ping_slot_info_req = 25;
PingSlotChannelReq ping_slot_channel_req = 26;
PingSlotChannelAns ping_slot_channel_ans = 27;
BeaconTimingAns beacon_timing_ans = 28;
BeaconFreqReq beacon_freq_req = 29;
BeaconFreqAns beacon_freq_ans = 30;
DeviceModeInd device_mode_ind = 31;
DeviceModeConf device_mode_conf = 32;
RelayConfReq relay_conf_req = 33;
RelayConfAns relay_conf_ans = 34;
RelayEndDeviceConfReq relay_end_device_conf_req = 35;
RelayEndDeviceConfAns relay_end_device_conf_ans = 36;
RelayUpdateUplinkListReq relay_update_uplink_list_req = 39;
RelayUpdateUplinkListAns relay_update_uplink_list_ans = 40;
RelayCtrlUplinkListReq relay_ctrl_uplink_list_req = 41;
RelayCtrlUplinkListAns relay_ctrl_uplink_list_ans = 42;
RelayConfigureFwdLimitReq relay_configure_fwd_limit_req = 43;
RelayConfigureFwdLimitAns relay_configure_fwd_limit_ans = 44;
RelayNotifyNewEndDeviceReq relay_notify_new_end_device_req = 45;
}
reserved 37;
reserved "relay_filter_list_req";
reserved 38;
reserved "relay_filter_list_ans";
message ResetInd {
Minor minor_version = 1 [(validate.rules).enum = {
defined_only: true,
in: [1]
}];
}
message ResetConf {
Minor minor_version = 1 [(validate.rules).enum = {
defined_only: true,
in: [1]
}];
}
message LinkCheckAns {
// Indicates the link margin in dB of the received LinkCheckReq, relative to the demodulation floor.
uint32 margin = 1 [(validate.rules).uint32.lte = 254];
uint32 gateway_count = 2 [(validate.rules).uint32.lte = 255];
}
message LinkADRReq {
DataRateIndex data_rate_index = 1 [(validate.rules).enum.defined_only = true];
uint32 tx_power_index = 2 [(validate.rules).uint32.lte = 15];
repeated bool channel_mask = 3 [(validate.rules).repeated.max_items = 16];
reserved 4; // For RFU 7th bit of Redundancy.
uint32 channel_mask_control = 5 [(validate.rules).uint32.lte = 7];
uint32 nb_trans = 6 [(validate.rules).uint32.lte = 15];
}
message LinkADRAns {
bool channel_mask_ack = 1;
bool data_rate_index_ack = 2;
bool tx_power_index_ack = 3;
}
message DutyCycleReq {
AggregatedDutyCycle max_duty_cycle = 1 [(validate.rules).enum.defined_only = true];
}
message RxParamSetupReq {
DataRateIndex rx2_data_rate_index = 1 [(validate.rules).enum.defined_only = true];
DataRateOffset rx1_data_rate_offset = 2 [(validate.rules).enum.defined_only = true];
uint64 rx2_frequency = 3 [(validate.rules).uint64.gte = 100000]; // Rx2 frequency (Hz).
}
message RxParamSetupAns {
bool rx2_data_rate_index_ack = 1;
bool rx1_data_rate_offset_ack = 2;
bool rx2_frequency_ack = 3;
}
message DevStatusAns {
// Device battery status.
// 0 indicates that the device is connected to an external power source.
// 1..254 indicates a battery level.
// 255 indicates that the device was not able to measure the battery level.
uint32 battery = 1 [(validate.rules).uint32.lte = 255];
// SNR of the last downlink (dB; [-32, +31]).
int32 margin = 2 [(validate.rules).int32 = {
gte: -32,
lte: 31
}];
}
message NewChannelReq {
uint32 channel_index = 1 [(validate.rules).uint32.lte = 255];
uint64 frequency = 2 [(validate.rules).uint64 = {
lte: 0,
gte: 100000
}]; // Channel frequency (Hz).
DataRateIndex min_data_rate_index = 3 [(validate.rules).enum.defined_only = true];
DataRateIndex max_data_rate_index = 4 [(validate.rules).enum.defined_only = true];
}