pamoja-lora 0.1.17

LoRa link math for pamoja: exact time-on-air and duty-cycle off-time, so a long-range node stays within regulations and budgets its power, no_std and allocation-free.
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
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
//! The published channel plans, transcribed from RP002-1.0.5.
//!
//! Each region is behind its own cargo feature, all on by default, because a
//! device only ever operates in one region and a microcontroller should not
//! carry the other nine in flash.

use super::ChannelPlan;
// The table types follow the regions: a build that selects one band, or none,
// must not be told it imported types no plan in it uses.
#[cfg(any(
    feature = "eu868",
    feature = "us915",
    feature = "eu433",
    feature = "au915",
    feature = "cn470",
    feature = "as923",
    feature = "kr920",
    feature = "in865",
    feature = "ru864"
))]
use super::{Beacon, ChannelBlock, DataRate, MaxPayload};
// Only the bands whose regulators cap airtime describe sub-bands; the 900 MHz
// plans and IN865 leave the table empty.
#[cfg(any(
    feature = "eu868",
    feature = "eu433",
    feature = "as923",
    feature = "kr920",
    feature = "ru864"
))]
use super::SubBand;

/// A named regional channel plan.
///
/// This is a convenience over [`ChannelPlan`], not the only way to get one: a
/// deployment on licensed spectrum builds its own plan and every method still
/// applies. Each variant is behind its own cargo feature.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Region {
    /// Europe and everywhere else following ETSI EN 300 220, 863-870 MHz.
    #[cfg(feature = "eu868")]
    Eu868,
    /// The United States, Canada, and ITU Region 2, 902-928 MHz.
    #[cfg(feature = "us915")]
    Us915,
    /// The 433 MHz ISM band.
    #[cfg(feature = "eu433")]
    Eu433,
    /// Australia and the countries following it, 915-928 MHz.
    #[cfg(feature = "au915")]
    Au915,
    /// China, 470-510 MHz.
    #[cfg(feature = "cn470")]
    Cn470,
    /// Asia and the Pacific, 923 MHz.
    #[cfg(feature = "as923")]
    As923,
    /// South Korea, 920-923 MHz.
    #[cfg(feature = "kr920")]
    Kr920,
    /// India, 865-867 MHz.
    #[cfg(feature = "in865")]
    In865,
    /// Russia, 864-870 MHz.
    #[cfg(feature = "ru864")]
    Ru864,
}

impl Region {
    /// Returns the channel plan this region names.
    ///
    /// # Returns
    ///
    /// The plan, whose tables come straight from RP002-1.0.5.
    pub const fn plan(self) -> &'static ChannelPlan<'static> {
        match self {
            #[cfg(feature = "eu868")]
            Region::Eu868 => &EU868,
            #[cfg(feature = "us915")]
            Region::Us915 => &US915,
            #[cfg(feature = "eu433")]
            Region::Eu433 => &EU433,
            #[cfg(feature = "au915")]
            Region::Au915 => &AU915,
            #[cfg(feature = "cn470")]
            Region::Cn470 => &CN470,
            #[cfg(feature = "as923")]
            Region::As923 => &AS923,
            #[cfg(feature = "kr920")]
            Region::Kr920 => &KR920,
            #[cfg(feature = "in865")]
            Region::In865 => &IN865,
            #[cfg(feature = "ru864")]
            Region::Ru864 => &RU864,
        }
    }

    /// Returns the specification's name for this region's band.
    ///
    /// # Returns
    ///
    /// The band name, such as `"EU863-870"`.
    pub const fn name(self) -> &'static str {
        self.plan().name
    }

    /// Returns the short code this region is configured by.
    ///
    /// A deployment is set up as `EU868` or `US915`; the band name the
    /// specification uses, such as `EU863-870`, is what [`name`](Self::name)
    /// reports. Both identify the same plan.
    ///
    /// # Returns
    ///
    /// The short code, such as `"EU868"`.
    ///
    /// # Examples
    ///
    /// ```
    /// # #[cfg(feature = "eu868")] {
    /// use pamoja_lora::region::Region;
    ///
    /// assert_eq!(Region::Eu868.code(), "EU868");
    /// assert_eq!(Region::Eu868.name(), "EU863-870");
    /// # }
    /// ```
    pub const fn code(self) -> &'static str {
        match self {
            #[cfg(feature = "eu868")]
            Region::Eu868 => "EU868",
            #[cfg(feature = "us915")]
            Region::Us915 => "US915",
            #[cfg(feature = "eu433")]
            Region::Eu433 => "EU433",
            #[cfg(feature = "au915")]
            Region::Au915 => "AU915",
            #[cfg(feature = "cn470")]
            Region::Cn470 => "CN470",
            #[cfg(feature = "as923")]
            Region::As923 => "AS923",
            #[cfg(feature = "kr920")]
            Region::Kr920 => "KR920",
            #[cfg(feature = "in865")]
            Region::In865 => "IN865",
            #[cfg(feature = "ru864")]
            Region::Ru864 => "RU864",
        }
    }

    /// Returns the region a short code names.
    ///
    /// The comparison ignores case, and the specification's band name is
    /// accepted as well, so a plan read back from a device's configuration
    /// resolves whichever form it was written in.
    ///
    /// # Arguments
    ///
    /// * `code` - the short code or band name, such as `"EU868"`.
    ///
    /// # Returns
    ///
    /// The region, or `None` if no region in this build goes by that name.
    ///
    /// # Examples
    ///
    /// ```
    /// # #[cfg(feature = "us915")] {
    /// use pamoja_lora::region::Region;
    ///
    /// assert_eq!(Region::from_code("us915"), Some(Region::Us915));
    /// assert_eq!(Region::from_code("US902-928"), Some(Region::Us915));
    /// assert_eq!(Region::from_code("Atlantis"), None);
    /// # }
    /// ```
    pub fn from_code(code: &str) -> Option<Self> {
        Self::all().iter().copied().find(|region| {
            code.eq_ignore_ascii_case(region.code()) || code.eq_ignore_ascii_case(region.name())
        })
    }

    /// Returns every region this build carries.
    ///
    /// A build that selects only its own region gets a one-element slice, which
    /// is the point of the per-region features.
    ///
    /// # Returns
    ///
    /// The compiled-in regions.
    pub const fn all() -> &'static [Region] {
        &[
            #[cfg(feature = "eu868")]
            Region::Eu868,
            #[cfg(feature = "us915")]
            Region::Us915,
            #[cfg(feature = "eu433")]
            Region::Eu433,
            #[cfg(feature = "au915")]
            Region::Au915,
            #[cfg(feature = "cn470")]
            Region::Cn470,
            #[cfg(feature = "as923")]
            Region::As923,
            #[cfg(feature = "kr920")]
            Region::Kr920,
            #[cfg(feature = "in865")]
            Region::In865,
            #[cfg(feature = "ru864")]
            Region::Ru864,
        ]
    }
}

// EU863-870, RP002-1.0.5 section 3.4.

/// RP002-1.0.5 Table 10: EU863-870 TX data rate.
#[cfg(feature = "eu868")]
static EU868_DATA_RATES: [Option<DataRate>; 14] = [
    Some(DataRate::lora(12, 125_000, 250)),
    Some(DataRate::lora(11, 125_000, 440)),
    Some(DataRate::lora(10, 125_000, 980)),
    Some(DataRate::lora(9, 125_000, 1_760)),
    Some(DataRate::lora(8, 125_000, 3_125)),
    Some(DataRate::lora(7, 125_000, 5_470)),
    Some(DataRate::lora(7, 250_000, 11_000)),
    Some(DataRate::fsk(50_000)),
    Some(DataRate::lr_fhss(1, 3, 137_000, 162)),
    Some(DataRate::lr_fhss(2, 3, 137_000, 325)),
    Some(DataRate::lr_fhss(1, 3, 336_000, 162)),
    Some(DataRate::lr_fhss(2, 3, 336_000, 325)),
    Some(DataRate::lora(6, 125_000, 9_375)),
    Some(DataRate::lora(5, 125_000, 15_625)),
];

/// RP002-1.0.5 Table 15: EU863-870 maximum payload size (repeater compatible).
#[cfg(feature = "eu868")]
static EU868_MAX_PAYLOAD_REPEATER: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(58, 50)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(58, 50)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 16: EU863-870 maximum payload size (not repeater compatible).
#[cfg(feature = "eu868")]
static EU868_MAX_PAYLOAD_DIRECT: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(58, 50)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(58, 50)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
];

/// RP002-1.0.5 Table 17: EU863-870 downlink RX1 data rate mapping.
#[cfg(feature = "eu868")]
static EU868_RX1: [&[u8]; 14] = [
    &[0, 0, 0, 0, 0, 0],
    &[1, 0, 0, 0, 0, 0],
    &[2, 1, 0, 0, 0, 0],
    &[3, 2, 1, 0, 0, 0],
    &[4, 3, 2, 1, 0, 0],
    &[5, 4, 3, 2, 1, 0],
    &[6, 5, 4, 3, 2, 1],
    &[7, 6, 5, 4, 3, 2],
    &[1, 0, 0, 0, 0, 0],
    &[2, 1, 0, 0, 0, 0],
    &[1, 0, 0, 0, 0, 0],
    &[2, 1, 0, 0, 0, 0],
    &[12, 5, 4, 3, 2, 1],
    &[13, 12, 5, 4, 3, 2],
];

/// RP002-1.0.5 Table 12: EU863-870 data rate back-off.
#[cfg(feature = "eu868")]
static EU868_BACKOFF: [Option<u8>; 14] = [
    None,
    Some(0),
    Some(1),
    Some(2),
    Some(3),
    Some(4),
    Some(5),
    Some(6),
    Some(0),
    Some(8),
    Some(0),
    Some(10),
    Some(5),
    Some(12),
];

/// RP002-1.0.5 Table 8 and Table 9: the three default and join channels.
#[cfg(feature = "eu868")]
static EU868_CHANNELS: [ChannelBlock; 1] = [ChannelBlock::new(868_100_000, 200_000, 3, 0, 5)];

/// The ETSI sub-bands the default channels fall in.
///
/// EN 300 220 divides the band, and the 868.0-868.6 MHz sub-band carrying the
/// three mandatory channels is limited to 1%. The RX2 downlink frequency sits in
/// the 869.4-869.65 MHz sub-band, which allows 10% at a higher ceiling.
#[cfg(feature = "eu868")]
static EU868_SUB_BANDS: [SubBand; 2] = [
    SubBand::new(868_000_000, 868_600_000, 10, 16),
    SubBand::new(869_400_000, 869_650_000, 100, 27),
];

/// The EU863-870 channel plan, RP002-1.0.5 section 3.4.
#[cfg(feature = "eu868")]
pub static EU868: ChannelPlan<'static> = ChannelPlan {
    name: "EU863-870",
    uplink_data_rates: &EU868_DATA_RATES,
    downlink_data_rates: &EU868_DATA_RATES,
    max_payload_repeater: &EU868_MAX_PAYLOAD_REPEATER,
    max_payload_direct: &EU868_MAX_PAYLOAD_DIRECT,
    downlink_max_payload_repeater: &EU868_MAX_PAYLOAD_REPEATER,
    downlink_max_payload_direct: &EU868_MAX_PAYLOAD_DIRECT,
    max_payload_dwell_limited: None,
    join_channels: &EU868_CHANNELS,
    default_channels: &EU868_CHANNELS,
    sub_bands: &EU868_SUB_BANDS,
    default_max_eirp_dbm: 16,
    tx_power_step_db: 2,
    max_tx_power_index: 7,
    rx1_data_rate_offsets: &EU868_RX1,
    rx1_data_rate_offsets_dwell_limited: None,
    max_rx1_data_rate_offset: 5,
    rx2_frequency_hz: 869_525_000,
    rx2_data_rate: 0,
    data_rate_backoff: &EU868_BACKOFF,
    beacon: Beacon {
        data_rate: 3,
        frequency_hz: 869_525_000,
        ping_slot_frequency_hz: 869_525_000,
    },
    has_dwell_time_limit: false,
};

// US902-928, RP002-1.0.5 section 3.5.

/// RP002-1.0.5 Table 19: US902-928 uplink data rates.
#[cfg(feature = "us915")]
static US915_UPLINK_DATA_RATES: [Option<DataRate>; 9] = [
    Some(DataRate::lora(10, 125_000, 980)),
    Some(DataRate::lora(9, 125_000, 1_760)),
    Some(DataRate::lora(8, 125_000, 3_125)),
    Some(DataRate::lora(7, 125_000, 5_470)),
    Some(DataRate::lora(8, 500_000, 12_500)),
    Some(DataRate::lr_fhss(1, 3, 1_523_000, 162)),
    Some(DataRate::lr_fhss(2, 3, 1_523_000, 325)),
    Some(DataRate::lora(6, 125_000, 9_375)),
    Some(DataRate::lora(5, 125_000, 15_625)),
];

/// RP002-1.0.5 Table 20: US902-928 downlink data rates.
#[cfg(feature = "us915")]
static US915_DOWNLINK_DATA_RATES: [Option<DataRate>; 15] = [
    Some(DataRate::lora(5, 500_000, 62_500)),
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    Some(DataRate::lora(12, 500_000, 980)),
    Some(DataRate::lora(11, 500_000, 1_760)),
    Some(DataRate::lora(10, 500_000, 3_900)),
    Some(DataRate::lora(9, 500_000, 7_000)),
    Some(DataRate::lora(8, 500_000, 12_500)),
    Some(DataRate::lora(7, 500_000, 21_900)),
    Some(DataRate::lora(6, 500_000, 37_500)),
];

/// RP002-1.0.5 Table 24: US902-928 uplink maximum payload (repeater compatible).
#[cfg(feature = "us915")]
static US915_MAX_PAYLOAD_REPEATER: [Option<MaxPayload>; 9] = [
    Some(MaxPayload::new(19, 11)),
    Some(MaxPayload::new(61, 53)),
    Some(MaxPayload::new(133, 125)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(58, 50)),
    Some(MaxPayload::new(133, 125)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 25: US902-928 uplink maximum payload (not repeater compatible).
#[cfg(feature = "us915")]
static US915_MAX_PAYLOAD_DIRECT: [Option<MaxPayload>; 9] = [
    Some(MaxPayload::new(19, 11)),
    Some(MaxPayload::new(61, 53)),
    Some(MaxPayload::new(133, 125)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(58, 50)),
    Some(MaxPayload::new(133, 125)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
];

/// RP002-1.0.5 Table 24: US902-928 downlink maximum payload (repeater compatible).
#[cfg(feature = "us915")]
static US915_DOWNLINK_MAX_PAYLOAD_REPEATER: [Option<MaxPayload>; 15] = [
    Some(MaxPayload::new(230, 222)),
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(61, 53)),
    Some(MaxPayload::new(137, 129)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 25: US902-928 downlink maximum payload (not repeater compatible).
#[cfg(feature = "us915")]
static US915_DOWNLINK_MAX_PAYLOAD_DIRECT: [Option<MaxPayload>; 15] = [
    Some(MaxPayload::new(250, 242)),
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(61, 53)),
    Some(MaxPayload::new(137, 129)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
];

/// RP002-1.0.5 Table 26: US902-928 downlink RX1 data rate mapping.
#[cfg(feature = "us915")]
static US915_RX1: [&[u8]; 9] = [
    &[10, 9, 8, 8],
    &[11, 10, 9, 8],
    &[12, 11, 10, 9],
    &[13, 12, 11, 10],
    &[13, 13, 12, 11],
    &[10, 9, 8, 8],
    &[11, 10, 9, 8],
    &[14, 13, 12, 11],
    &[0, 14, 13, 12],
];

/// RP002-1.0.5 Table 21: US902-928 uplink data rate back-off.
#[cfg(feature = "us915")]
static US915_BACKOFF: [Option<u8>; 9] = [
    None,
    Some(0),
    Some(1),
    Some(2),
    Some(3),
    Some(0),
    Some(5),
    Some(3),
    Some(7),
];

/// The 64 125 kHz channels and the 8 500 kHz channels, RP002-1.0.5 section 3.5.2.
#[cfg(feature = "us915")]
static US915_CHANNELS: [ChannelBlock; 2] = [
    ChannelBlock::new(902_300_000, 200_000, 64, 0, 3),
    ChannelBlock::new(903_000_000, 1_600_000, 8, 4, 4),
];

/// The join channels: a random 125 kHz channel at DR0 and a 500 kHz one at DR4.
#[cfg(feature = "us915")]
static US915_JOIN_CHANNELS: [ChannelBlock; 2] = [
    ChannelBlock::new(902_300_000, 200_000, 64, 0, 0),
    ChannelBlock::new(903_000_000, 1_600_000, 8, 4, 4),
];

/// The US902-928 channel plan, RP002-1.0.5 section 3.5.
///
/// The FCC constrains this band by dwell time rather than duty cycle, so the
/// plan publishes no sub-band duty limit and
/// [`duty_cycle_permille`](ChannelPlan::duty_cycle_permille) reports `None`.
#[cfg(feature = "us915")]
pub static US915: ChannelPlan<'static> = ChannelPlan {
    name: "US902-928",
    uplink_data_rates: &US915_UPLINK_DATA_RATES,
    downlink_data_rates: &US915_DOWNLINK_DATA_RATES,
    max_payload_repeater: &US915_MAX_PAYLOAD_REPEATER,
    max_payload_direct: &US915_MAX_PAYLOAD_DIRECT,
    downlink_max_payload_repeater: &US915_DOWNLINK_MAX_PAYLOAD_REPEATER,
    downlink_max_payload_direct: &US915_DOWNLINK_MAX_PAYLOAD_DIRECT,
    max_payload_dwell_limited: None,
    join_channels: &US915_JOIN_CHANNELS,
    default_channels: &US915_CHANNELS,
    sub_bands: &[],
    default_max_eirp_dbm: 30,
    tx_power_step_db: 2,
    max_tx_power_index: 14,
    rx1_data_rate_offsets: &US915_RX1,
    rx1_data_rate_offsets_dwell_limited: None,
    max_rx1_data_rate_offset: 3,
    rx2_frequency_hz: 923_300_000,
    rx2_data_rate: 8,
    data_rate_backoff: &US915_BACKOFF,
    beacon: Beacon {
        data_rate: 8,
        frequency_hz: 923_300_000,
        ping_slot_frequency_hz: 923_300_000,
    },
    has_dwell_time_limit: true,
};

// EU433, RP002-1.0.5 section 3.7.

/// RP002-1.0.5 Table 30: EU433 data rate and TXPower.
#[cfg(feature = "eu433")]
static EU433_DATA_RATES: [Option<DataRate>; 14] = [
    Some(DataRate::lora(12, 125_000, 250)),
    Some(DataRate::lora(11, 125_000, 440)),
    Some(DataRate::lora(10, 125_000, 980)),
    Some(DataRate::lora(9, 125_000, 1_760)),
    Some(DataRate::lora(8, 125_000, 3_125)),
    Some(DataRate::lora(7, 125_000, 5_470)),
    Some(DataRate::lora(7, 250_000, 11_000)),
    Some(DataRate::fsk(50_000)),
    None,
    None,
    None,
    None,
    Some(DataRate::lora(6, 125_000, 9_375)),
    Some(DataRate::lora(5, 125_000, 15_625)),
];

/// RP002-1.0.5 Table 36: EU433 maximum payload size (repeater compatible).
#[cfg(feature = "eu433")]
static EU433_MAX_PAYLOAD_REPEATER: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 37: EU433 maximum payload size (not repeater compatible).
#[cfg(feature = "eu433")]
static EU433_MAX_PAYLOAD_DIRECT: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
];

/// RP002-1.0.5 Table 38: EU433 downlink RX1 data rate mapping.
///
/// DR8 through DR11 are reserved in this region, so their rows carry the DR0
/// fallback rather than a mapping the specification does not define.
#[cfg(feature = "eu433")]
static EU433_RX1: [&[u8]; 14] = [
    &[0, 0, 0, 0, 0, 0],
    &[1, 0, 0, 0, 0, 0],
    &[2, 1, 0, 0, 0, 0],
    &[3, 2, 1, 0, 0, 0],
    &[4, 3, 2, 1, 0, 0],
    &[5, 4, 3, 2, 1, 0],
    &[6, 5, 4, 3, 2, 1],
    &[7, 6, 5, 4, 3, 2],
    &[0, 0, 0, 0, 0, 0],
    &[0, 0, 0, 0, 0, 0],
    &[0, 0, 0, 0, 0, 0],
    &[0, 0, 0, 0, 0, 0],
    &[12, 5, 4, 3, 2, 1],
    &[13, 12, 5, 4, 3, 2],
];

/// RP002-1.0.5 Table 32: EU433 data rate back-off.
#[cfg(feature = "eu433")]
static EU433_BACKOFF: [Option<u8>; 14] = [
    None,
    Some(0),
    Some(1),
    Some(2),
    Some(3),
    Some(4),
    Some(5),
    Some(6),
    None,
    None,
    None,
    None,
    Some(5),
    Some(12),
];

/// RP002-1.0.5 Table 29: the three default and join channels.
#[cfg(feature = "eu433")]
static EU433_CHANNELS: [ChannelBlock; 1] = [ChannelBlock::new(433_175_000, 200_000, 3, 0, 5)];

/// The whole EU433 band carries one limit: below 12 dBm EIRP and under 10% duty.
#[cfg(feature = "eu433")]
static EU433_SUB_BANDS: [SubBand; 1] = [SubBand::new(433_050_000, 434_790_000, 100, 12)];

/// The EU433 channel plan, RP002-1.0.5 section 3.7.
#[cfg(feature = "eu433")]
pub static EU433: ChannelPlan<'static> = ChannelPlan {
    name: "EU433",
    uplink_data_rates: &EU433_DATA_RATES,
    downlink_data_rates: &EU433_DATA_RATES,
    max_payload_repeater: &EU433_MAX_PAYLOAD_REPEATER,
    max_payload_direct: &EU433_MAX_PAYLOAD_DIRECT,
    downlink_max_payload_repeater: &EU433_MAX_PAYLOAD_REPEATER,
    downlink_max_payload_direct: &EU433_MAX_PAYLOAD_DIRECT,
    max_payload_dwell_limited: None,
    join_channels: &EU433_CHANNELS,
    default_channels: &EU433_CHANNELS,
    sub_bands: &EU433_SUB_BANDS,
    default_max_eirp_dbm: 12,
    tx_power_step_db: 2,
    max_tx_power_index: 5,
    rx1_data_rate_offsets: &EU433_RX1,
    rx1_data_rate_offsets_dwell_limited: None,
    max_rx1_data_rate_offset: 5,
    rx2_frequency_hz: 434_665_000,
    rx2_data_rate: 0,
    data_rate_backoff: &EU433_BACKOFF,
    beacon: Beacon {
        data_rate: 3,
        frequency_hz: 434_665_000,
        ping_slot_frequency_hz: 434_665_000,
    },
    has_dwell_time_limit: false,
};

// AU915-928, RP002-1.0.5 section 3.8.

/// RP002-1.0.5 Table 39: AU915-928 uplink data rates.
#[cfg(feature = "au915")]
static AU915_UPLINK_DATA_RATES: [Option<DataRate>; 11] = [
    Some(DataRate::lora(12, 125_000, 250)),
    Some(DataRate::lora(11, 125_000, 440)),
    Some(DataRate::lora(10, 125_000, 980)),
    Some(DataRate::lora(9, 125_000, 1_760)),
    Some(DataRate::lora(8, 125_000, 3_125)),
    Some(DataRate::lora(7, 125_000, 5_470)),
    Some(DataRate::lora(8, 500_000, 12_500)),
    Some(DataRate::lr_fhss(1, 3, 1_523_000, 162)),
    None,
    Some(DataRate::lora(6, 125_000, 9_375)),
    Some(DataRate::lora(5, 125_000, 15_625)),
];

/// RP002-1.0.5 Table 40: AU915-928 downlink data rates.
#[cfg(feature = "au915")]
static AU915_DOWNLINK_DATA_RATES: [Option<DataRate>; 15] = [
    Some(DataRate::lora(5, 500_000, 62_500)),
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    Some(DataRate::lora(12, 500_000, 980)),
    Some(DataRate::lora(11, 500_000, 1_760)),
    Some(DataRate::lora(10, 500_000, 3_900)),
    Some(DataRate::lora(9, 500_000, 7_000)),
    Some(DataRate::lora(8, 500_000, 12_500)),
    Some(DataRate::lora(7, 500_000, 21_900)),
    Some(DataRate::lora(6, 500_000, 37_500)),
];

/// RP002-1.0.5 Table 44: AU915-928 uplink maximum payload, no dwell limit.
#[cfg(feature = "au915")]
static AU915_MAX_PAYLOAD_REPEATER: [Option<MaxPayload>; 11] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(58, 50)),
    None,
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 45: AU915-928 uplink maximum payload, no dwell limit.
#[cfg(feature = "au915")]
static AU915_MAX_PAYLOAD_DIRECT: [Option<MaxPayload>; 11] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(58, 50)),
    None,
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
];

/// RP002-1.0.5 Table 44: AU915-928 uplink maximum payload under a 400 ms dwell.
///
/// The two slowest data rates carry nothing at all inside 400 ms, which is why
/// a device boots assuming the limit applies until told otherwise.
#[cfg(feature = "au915")]
static AU915_MAX_PAYLOAD_DWELL: [Option<MaxPayload>; 11] = [
    None,
    None,
    Some(MaxPayload::new(19, 11)),
    Some(MaxPayload::new(61, 53)),
    Some(MaxPayload::new(133, 125)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(58, 50)),
    None,
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 44: AU915-928 downlink maximum payload (repeater compatible).
#[cfg(feature = "au915")]
static AU915_DOWNLINK_MAX_PAYLOAD_REPEATER: [Option<MaxPayload>; 15] = [
    Some(MaxPayload::new(230, 222)),
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(61, 53)),
    Some(MaxPayload::new(137, 129)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 45: AU915-928 downlink maximum payload (not repeater compatible).
#[cfg(feature = "au915")]
static AU915_DOWNLINK_MAX_PAYLOAD_DIRECT: [Option<MaxPayload>; 15] = [
    Some(MaxPayload::new(250, 242)),
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(61, 53)),
    Some(MaxPayload::new(137, 129)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
];

/// RP002-1.0.5 Table 46: AU915-928 downlink RX1 data rate mapping.
#[cfg(feature = "au915")]
static AU915_RX1: [&[u8]; 11] = [
    &[8, 8, 8, 8, 8, 8],
    &[9, 8, 8, 8, 8, 8],
    &[10, 9, 8, 8, 8, 8],
    &[11, 10, 9, 8, 8, 8],
    &[12, 11, 10, 9, 8, 8],
    &[13, 12, 11, 10, 9, 8],
    &[13, 13, 12, 11, 10, 9],
    &[9, 8, 8, 8, 8, 8],
    &[8, 8, 8, 8, 8, 8],
    &[14, 13, 12, 11, 10, 9],
    &[0, 14, 13, 12, 11, 10],
];

/// RP002-1.0.5 Table 41: AU915-928 uplink data rate back-off, no dwell limit.
#[cfg(feature = "au915")]
static AU915_BACKOFF: [Option<u8>; 11] = [
    None,
    Some(0),
    Some(1),
    Some(2),
    Some(3),
    Some(4),
    Some(5),
    Some(0),
    None,
    Some(5),
    Some(9),
];

/// The 64 125 kHz uplink channels and the 8 500 kHz ones, section 3.8.2.
#[cfg(feature = "au915")]
static AU915_CHANNELS: [ChannelBlock; 2] = [
    ChannelBlock::new(915_200_000, 200_000, 64, 0, 5),
    ChannelBlock::new(915_900_000, 1_600_000, 8, 6, 7),
];

/// The AU915-928 channel plan, RP002-1.0.5 section 3.8.
///
/// Australia limits transmissions by dwell time rather than duty cycle, so
/// [`duty_cycle_permille`](ChannelPlan::duty_cycle_permille) reports nothing and
/// the dwell-limited payload table is the one that matters until the network
/// says otherwise.
#[cfg(feature = "au915")]
pub static AU915: ChannelPlan<'static> = ChannelPlan {
    name: "AU915-928",
    uplink_data_rates: &AU915_UPLINK_DATA_RATES,
    downlink_data_rates: &AU915_DOWNLINK_DATA_RATES,
    max_payload_repeater: &AU915_MAX_PAYLOAD_REPEATER,
    max_payload_direct: &AU915_MAX_PAYLOAD_DIRECT,
    downlink_max_payload_repeater: &AU915_DOWNLINK_MAX_PAYLOAD_REPEATER,
    downlink_max_payload_direct: &AU915_DOWNLINK_MAX_PAYLOAD_DIRECT,
    max_payload_dwell_limited: Some(&AU915_MAX_PAYLOAD_DWELL),
    join_channels: &AU915_CHANNELS,
    default_channels: &AU915_CHANNELS,
    sub_bands: &[],
    default_max_eirp_dbm: 30,
    tx_power_step_db: 2,
    max_tx_power_index: 14,
    rx1_data_rate_offsets: &AU915_RX1,
    rx1_data_rate_offsets_dwell_limited: None,
    max_rx1_data_rate_offset: 5,
    rx2_frequency_hz: 923_300_000,
    rx2_data_rate: 8,
    data_rate_backoff: &AU915_BACKOFF,
    beacon: Beacon {
        data_rate: 8,
        frequency_hz: 923_300_000,
        ping_slot_frequency_hz: 923_300_000,
    },
    has_dwell_time_limit: true,
};

// CN470-510, RP002-1.0.5 section 3.9.

/// RP002-1.0.5 Table 50: CN470-510 data rate and TXPower.
#[cfg(feature = "cn470")]
static CN470_DATA_RATES: [Option<DataRate>; 8] = [
    Some(DataRate::lora(12, 125_000, 250)),
    Some(DataRate::lora(11, 125_000, 440)),
    Some(DataRate::lora(10, 125_000, 980)),
    Some(DataRate::lora(9, 125_000, 1_760)),
    Some(DataRate::lora(8, 125_000, 3_125)),
    Some(DataRate::lora(7, 125_000, 5_470)),
    Some(DataRate::lora(7, 500_000, 21_900)),
    Some(DataRate::fsk(50_000)),
];

/// RP002-1.0.5 Table 54: CN470-510 maximum payload size (repeater compatible).
///
/// DR0 carries nothing: at SF12 the one-second transmission limit this band
/// works under leaves no room for a frame.
#[cfg(feature = "cn470")]
static CN470_MAX_PAYLOAD_REPEATER: [Option<MaxPayload>; 8] = [
    None,
    Some(MaxPayload::new(31, 23)),
    Some(MaxPayload::new(94, 86)),
    Some(MaxPayload::new(192, 184)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 55: CN470-510 maximum payload size (not repeater compatible).
#[cfg(feature = "cn470")]
static CN470_MAX_PAYLOAD_DIRECT: [Option<MaxPayload>; 8] = [
    None,
    Some(MaxPayload::new(31, 23)),
    Some(MaxPayload::new(94, 86)),
    Some(MaxPayload::new(192, 184)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
];

/// RP002-1.0.5 Table 56: CN470-510 downlink RX1 data rate mapping.
#[cfg(feature = "cn470")]
static CN470_RX1: [&[u8]; 8] = [
    &[0, 0, 0, 0, 0, 0],
    &[1, 1, 1, 1, 1, 1],
    &[2, 1, 1, 1, 1, 1],
    &[3, 2, 1, 1, 1, 1],
    &[4, 3, 2, 1, 1, 1],
    &[5, 4, 3, 2, 1, 1],
    &[6, 5, 4, 3, 2, 1],
    &[7, 6, 5, 4, 3, 2],
];

/// RP002-1.0.5 Table 51: CN470-510 data rate back-off.
#[cfg(feature = "cn470")]
static CN470_BACKOFF: [Option<u8>; 8] = [
    None,
    Some(0),
    Some(1),
    Some(2),
    Some(3),
    Some(4),
    Some(5),
    Some(6),
];

/// The uplink blocks of the 20 MHz antenna, channel plan A, section 3.9.2.
#[cfg(feature = "cn470")]
static CN470_CHANNELS: [ChannelBlock; 2] = [
    ChannelBlock::new(470_300_000, 200_000, 32, 0, 5),
    ChannelBlock::new(483_900_000, 200_000, 32, 0, 5),
];

/// The eight common join channels every CN470 plan shares, Table 49.
#[cfg(feature = "cn470")]
static CN470_JOIN_CHANNELS: [ChannelBlock; 2] = [
    ChannelBlock::new(470_900_000, 1_600_000, 4, 0, 5),
    ChannelBlock::new(504_100_000, 1_600_000, 4, 0, 5),
];

/// The CN470-510 channel plan, RP002-1.0.5 section 3.9.
///
/// This carries the 20 MHz antenna, channel plan A variant. RP002 defines four
/// (20 MHz and 26 MHz antennas, each with a plan A and B) whose uplink blocks,
/// RX2 frequency, and beacon frequency differ, and the RX2 frequency also
/// depends on whether the device joined over the air or was personalized. The
/// value here is the personalized default for plan A. A deployment on one of the
/// other variants builds a [`ChannelPlan`] with its own frequencies; everything
/// else in this plan is common to all four.
///
/// Transmissions in this band are limited to one second on one channel at a
/// time, with listen-before-talk rather than a duty cycle.
#[cfg(feature = "cn470")]
pub static CN470: ChannelPlan<'static> = ChannelPlan {
    name: "CN470-510",
    uplink_data_rates: &CN470_DATA_RATES,
    downlink_data_rates: &CN470_DATA_RATES,
    max_payload_repeater: &CN470_MAX_PAYLOAD_REPEATER,
    max_payload_direct: &CN470_MAX_PAYLOAD_DIRECT,
    downlink_max_payload_repeater: &CN470_MAX_PAYLOAD_REPEATER,
    downlink_max_payload_direct: &CN470_MAX_PAYLOAD_DIRECT,
    max_payload_dwell_limited: None,
    join_channels: &CN470_JOIN_CHANNELS,
    default_channels: &CN470_CHANNELS,
    sub_bands: &[],
    default_max_eirp_dbm: 19,
    tx_power_step_db: 2,
    max_tx_power_index: 7,
    rx1_data_rate_offsets: &CN470_RX1,
    rx1_data_rate_offsets_dwell_limited: None,
    max_rx1_data_rate_offset: 5,
    rx2_frequency_hz: 486_900_000,
    rx2_data_rate: 1,
    data_rate_backoff: &CN470_BACKOFF,
    beacon: Beacon {
        data_rate: 2,
        frequency_hz: 486_900_000,
        ping_slot_frequency_hz: 486_900_000,
    },
    has_dwell_time_limit: false,
};

// AS923, RP002-1.0.5 section 3.10.

/// RP002-1.0.5 Table 67: AS923 data rate.
#[cfg(feature = "as923")]
static AS923_DATA_RATES: [Option<DataRate>; 14] = [
    Some(DataRate::lora(12, 125_000, 250)),
    Some(DataRate::lora(11, 125_000, 440)),
    Some(DataRate::lora(10, 125_000, 980)),
    Some(DataRate::lora(9, 125_000, 1_760)),
    Some(DataRate::lora(8, 125_000, 3_125)),
    Some(DataRate::lora(7, 125_000, 5_470)),
    Some(DataRate::lora(7, 250_000, 11_000)),
    Some(DataRate::fsk(50_000)),
    None,
    None,
    None,
    None,
    Some(DataRate::lora(6, 125_000, 9_375)),
    Some(DataRate::lora(5, 125_000, 15_625)),
];

/// RP002-1.0.5 Table 72: AS923 maximum payload size (repeater compatible).
#[cfg(feature = "as923")]
static AS923_MAX_PAYLOAD_REPEATER: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 73: AS923 maximum payload size (not repeater compatible).
#[cfg(feature = "as923")]
static AS923_MAX_PAYLOAD_DIRECT: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
];

/// RP002-1.0.5 Table 74: AS923 RX1 mapping with no downlink dwell limit.
#[cfg(feature = "as923")]
static AS923_RX1: [&[u8]; 14] = [
    &[0, 0, 0, 0, 0, 0, 1, 2],
    &[1, 0, 0, 0, 0, 0, 2, 3],
    &[2, 1, 0, 0, 0, 0, 3, 4],
    &[3, 2, 1, 0, 0, 0, 4, 5],
    &[4, 3, 2, 1, 0, 0, 5, 6],
    &[5, 4, 3, 2, 1, 0, 6, 7],
    &[6, 5, 4, 3, 2, 1, 7, 7],
    &[7, 6, 5, 4, 3, 2, 7, 7],
    &[0, 0, 0, 0, 0, 0, 1, 2],
    &[0, 0, 0, 0, 0, 0, 1, 2],
    &[0, 0, 0, 0, 0, 0, 1, 2],
    &[0, 0, 0, 0, 0, 0, 1, 2],
    &[12, 5, 4, 3, 2, 1, 13, 13],
    &[13, 12, 5, 4, 3, 2, 13, 13],
];

/// RP002-1.0.5 Table 75: AS923 RX1 mapping under a downlink dwell limit.
#[cfg(feature = "as923")]
static AS923_RX1_DWELL: [&[u8]; 14] = [
    &[2, 2, 2, 2, 2, 2, 2, 2],
    &[2, 2, 2, 2, 2, 2, 2, 3],
    &[2, 2, 2, 2, 2, 2, 3, 4],
    &[3, 2, 2, 2, 2, 2, 4, 5],
    &[4, 3, 2, 2, 2, 2, 5, 6],
    &[5, 4, 3, 2, 2, 2, 6, 7],
    &[6, 5, 4, 3, 2, 2, 7, 7],
    &[7, 6, 5, 4, 3, 2, 7, 7],
    &[2, 2, 2, 2, 2, 2, 2, 2],
    &[2, 2, 2, 2, 2, 2, 2, 2],
    &[2, 2, 2, 2, 2, 2, 2, 2],
    &[2, 2, 2, 2, 2, 2, 2, 2],
    &[12, 5, 4, 3, 2, 2, 13, 13],
    &[13, 12, 5, 4, 3, 2, 13, 13],
];

/// RP002-1.0.5 Table 69: AS923 data rate back-off.
#[cfg(feature = "as923")]
static AS923_BACKOFF: [Option<u8>; 14] = [
    None,
    Some(0),
    Some(1),
    Some(2),
    Some(3),
    Some(4),
    Some(5),
    Some(6),
    None,
    None,
    None,
    None,
    Some(5),
    Some(12),
];

/// RP002-1.0.5 Table 65: the two default channels, at the AS923-1 offset of zero.
#[cfg(feature = "as923")]
static AS923_CHANNELS: [ChannelBlock; 1] = [ChannelBlock::new(923_200_000, 200_000, 2, 0, 5)];

/// The AS923 band is duty-cycle limited to 1% on its default channels.
#[cfg(feature = "as923")]
static AS923_SUB_BANDS: [SubBand; 1] = [SubBand::new(923_000_000, 923_500_000, 10, 16)];

/// The AS923 channel plan, RP002-1.0.5 section 3.10.
///
/// AS923 is four plans rather than one: every frequency here is the AS923-1
/// value, and AS923-2, AS923-3, and AS923-4 shift each of them by a fixed
/// `AS923_FREQ_OFFSET_HZ`. Everything that is not a frequency is common to all
/// four, so a deployment on another group copies this plan and adds its offset
/// to the channel, RX2, and beacon frequencies.
///
/// Japan reaches this band through ARIB STD-T108, which imposes a listen-before-
/// talk obligation this plan does not model.
#[cfg(feature = "as923")]
pub static AS923: ChannelPlan<'static> = ChannelPlan {
    name: "AS923",
    uplink_data_rates: &AS923_DATA_RATES,
    downlink_data_rates: &AS923_DATA_RATES,
    max_payload_repeater: &AS923_MAX_PAYLOAD_REPEATER,
    max_payload_direct: &AS923_MAX_PAYLOAD_DIRECT,
    downlink_max_payload_repeater: &AS923_MAX_PAYLOAD_REPEATER,
    downlink_max_payload_direct: &AS923_MAX_PAYLOAD_DIRECT,
    max_payload_dwell_limited: None,
    join_channels: &AS923_CHANNELS,
    default_channels: &AS923_CHANNELS,
    sub_bands: &AS923_SUB_BANDS,
    default_max_eirp_dbm: 16,
    tx_power_step_db: 2,
    max_tx_power_index: 7,
    rx1_data_rate_offsets: &AS923_RX1,
    rx1_data_rate_offsets_dwell_limited: Some(&AS923_RX1_DWELL),
    max_rx1_data_rate_offset: 7,
    rx2_frequency_hz: 923_200_000,
    rx2_data_rate: 2,
    data_rate_backoff: &AS923_BACKOFF,
    beacon: Beacon {
        data_rate: 3,
        frequency_hz: 923_400_000,
        ping_slot_frequency_hz: 923_400_000,
    },
    has_dwell_time_limit: true,
};

// KR920-923, RP002-1.0.5 section 3.11.

/// RP002-1.0.5 Table 80: KR920-923 TX data rate.
#[cfg(feature = "kr920")]
static KR920_DATA_RATES: [Option<DataRate>; 14] = [
    Some(DataRate::lora(12, 125_000, 250)),
    Some(DataRate::lora(11, 125_000, 440)),
    Some(DataRate::lora(10, 125_000, 980)),
    Some(DataRate::lora(9, 125_000, 1_760)),
    Some(DataRate::lora(8, 125_000, 3_125)),
    Some(DataRate::lora(7, 125_000, 5_470)),
    None,
    None,
    None,
    None,
    None,
    None,
    Some(DataRate::lora(6, 125_000, 9_375)),
    Some(DataRate::lora(5, 125_000, 15_625)),
];

/// RP002-1.0.5 Table 85: KR920-923 maximum payload size (repeater compatible).
#[cfg(feature = "kr920")]
static KR920_MAX_PAYLOAD_REPEATER: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    None,
    None,
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 86: KR920-923 maximum payload size (not repeater compatible).
#[cfg(feature = "kr920")]
static KR920_MAX_PAYLOAD_DIRECT: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    None,
    None,
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
];

/// RP002-1.0.5 Table 87: KR920-923 downlink RX1 data rate mapping.
#[cfg(feature = "kr920")]
static KR920_RX1: [&[u8]; 14] = [
    &[0, 0, 0, 0, 0, 0],
    &[1, 0, 0, 0, 0, 0],
    &[2, 1, 0, 0, 0, 0],
    &[3, 2, 1, 0, 0, 0],
    &[4, 3, 2, 1, 0, 0],
    &[5, 4, 3, 2, 1, 0],
    &[0, 0, 0, 0, 0, 0],
    &[0, 0, 0, 0, 0, 0],
    &[0, 0, 0, 0, 0, 0],
    &[0, 0, 0, 0, 0, 0],
    &[0, 0, 0, 0, 0, 0],
    &[0, 0, 0, 0, 0, 0],
    &[12, 5, 4, 3, 2, 1],
    &[13, 12, 5, 4, 3, 2],
];

/// RP002-1.0.5 Table 82: KR920-923 data rate back-off.
#[cfg(feature = "kr920")]
static KR920_BACKOFF: [Option<u8>; 14] = [
    None,
    Some(0),
    Some(1),
    Some(2),
    Some(3),
    Some(4),
    None,
    None,
    None,
    None,
    None,
    None,
    Some(5),
    Some(12),
];

/// RP002-1.0.5 Tables 78 and 79: the three default and join channels.
#[cfg(feature = "kr920")]
static KR920_CHANNELS: [ChannelBlock; 1] = [ChannelBlock::new(922_100_000, 200_000, 3, 0, 5)];

/// RP002-1.0.5 Table 77: the band's power ceiling steps at 922.1 MHz.
///
/// Korea publishes no duty cycle for this band; the two sub-bands differ only in
/// how much power they allow, so the limit reported here is the ceiling.
#[cfg(feature = "kr920")]
static KR920_SUB_BANDS: [SubBand; 2] = [
    SubBand::new(920_900_000, 921_900_000, 1000, 10),
    SubBand::new(922_100_000, 923_300_000, 1000, 14),
];

/// The KR920-923 channel plan, RP002-1.0.5 section 3.11.
#[cfg(feature = "kr920")]
pub static KR920: ChannelPlan<'static> = ChannelPlan {
    name: "KR920-923",
    uplink_data_rates: &KR920_DATA_RATES,
    downlink_data_rates: &KR920_DATA_RATES,
    max_payload_repeater: &KR920_MAX_PAYLOAD_REPEATER,
    max_payload_direct: &KR920_MAX_PAYLOAD_DIRECT,
    downlink_max_payload_repeater: &KR920_MAX_PAYLOAD_REPEATER,
    downlink_max_payload_direct: &KR920_MAX_PAYLOAD_DIRECT,
    max_payload_dwell_limited: None,
    join_channels: &KR920_CHANNELS,
    default_channels: &KR920_CHANNELS,
    sub_bands: &KR920_SUB_BANDS,
    default_max_eirp_dbm: 14,
    tx_power_step_db: 2,
    max_tx_power_index: 7,
    rx1_data_rate_offsets: &KR920_RX1,
    rx1_data_rate_offsets_dwell_limited: None,
    max_rx1_data_rate_offset: 5,
    rx2_frequency_hz: 921_900_000,
    rx2_data_rate: 0,
    data_rate_backoff: &KR920_BACKOFF,
    beacon: Beacon {
        data_rate: 3,
        frequency_hz: 923_100_000,
        ping_slot_frequency_hz: 923_100_000,
    },
    has_dwell_time_limit: false,
};

// IN865, RP002-1.0.5 section 3.12.

/// RP002-1.0.5 Table 91: IN865 TX data rate.
#[cfg(feature = "in865")]
static IN865_DATA_RATES: [Option<DataRate>; 14] = [
    Some(DataRate::lora(12, 125_000, 250)),
    Some(DataRate::lora(11, 125_000, 440)),
    Some(DataRate::lora(10, 125_000, 980)),
    Some(DataRate::lora(9, 125_000, 1_760)),
    Some(DataRate::lora(8, 125_000, 3_125)),
    Some(DataRate::lora(7, 125_000, 5_470)),
    None,
    Some(DataRate::fsk(50_000)),
    None,
    None,
    None,
    None,
    Some(DataRate::lora(6, 125_000, 9_375)),
    Some(DataRate::lora(5, 125_000, 15_625)),
];

/// RP002-1.0.5 Table 96: IN865 maximum payload size (repeater compatible).
#[cfg(feature = "in865")]
static IN865_MAX_PAYLOAD_REPEATER: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    None,
    Some(MaxPayload::new(230, 222)),
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 97: IN865 maximum payload size (not repeater compatible).
#[cfg(feature = "in865")]
static IN865_MAX_PAYLOAD_DIRECT: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    None,
    Some(MaxPayload::new(250, 242)),
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
];

/// RP002-1.0.5 Table 98: IN865 downlink RX1 data rate mapping.
///
/// India is one of the regions that allows all eight RX1 data-rate offsets.
#[cfg(feature = "in865")]
static IN865_RX1: [&[u8]; 14] = [
    &[0, 0, 0, 0, 0, 0, 1, 2],
    &[1, 0, 0, 0, 0, 0, 2, 3],
    &[2, 1, 0, 0, 0, 0, 3, 4],
    &[3, 2, 1, 0, 0, 0, 4, 5],
    &[4, 3, 2, 1, 0, 0, 5, 5],
    &[5, 4, 3, 2, 1, 0, 5, 7],
    &[0, 0, 0, 0, 0, 0, 1, 2],
    &[7, 5, 5, 4, 3, 2, 7, 7],
    &[0, 0, 0, 0, 0, 0, 1, 2],
    &[0, 0, 0, 0, 0, 0, 1, 2],
    &[0, 0, 0, 0, 0, 0, 1, 2],
    &[0, 0, 0, 0, 0, 0, 1, 2],
    &[12, 5, 4, 3, 2, 1, 13, 13],
    &[13, 12, 5, 4, 3, 2, 13, 13],
];

/// RP002-1.0.5 Table 93: IN865 data rate back-off.
#[cfg(feature = "in865")]
static IN865_BACKOFF: [Option<u8>; 14] = [
    None,
    Some(0),
    Some(1),
    Some(2),
    Some(3),
    Some(4),
    None,
    Some(5),
    None,
    None,
    None,
    None,
    Some(5),
    Some(12),
];

/// RP002-1.0.5 Tables 89 and 90: the three default and join channels.
///
/// These are not evenly spaced, so each is its own single-channel block.
#[cfg(feature = "in865")]
static IN865_CHANNELS: [ChannelBlock; 3] = [
    ChannelBlock::new(865_062_500, 0, 1, 0, 5),
    ChannelBlock::new(865_402_500, 0, 1, 0, 5),
    ChannelBlock::new(865_985_000, 0, 1, 0, 5),
];

/// The IN865 channel plan, RP002-1.0.5 section 3.12.
///
/// The published ceiling is 29.2 dBm EIRP, reported here as the whole decibel
/// below it so a caller reading this as a limit is never over the real one.
#[cfg(feature = "in865")]
pub static IN865: ChannelPlan<'static> = ChannelPlan {
    name: "IN865",
    uplink_data_rates: &IN865_DATA_RATES,
    downlink_data_rates: &IN865_DATA_RATES,
    max_payload_repeater: &IN865_MAX_PAYLOAD_REPEATER,
    max_payload_direct: &IN865_MAX_PAYLOAD_DIRECT,
    downlink_max_payload_repeater: &IN865_MAX_PAYLOAD_REPEATER,
    downlink_max_payload_direct: &IN865_MAX_PAYLOAD_DIRECT,
    max_payload_dwell_limited: None,
    join_channels: &IN865_CHANNELS,
    default_channels: &IN865_CHANNELS,
    sub_bands: &[],
    default_max_eirp_dbm: 29,
    tx_power_step_db: 2,
    max_tx_power_index: 10,
    rx1_data_rate_offsets: &IN865_RX1,
    rx1_data_rate_offsets_dwell_limited: None,
    max_rx1_data_rate_offset: 7,
    rx2_frequency_hz: 866_550_000,
    rx2_data_rate: 2,
    data_rate_backoff: &IN865_BACKOFF,
    beacon: Beacon {
        data_rate: 4,
        frequency_hz: 866_550_000,
        ping_slot_frequency_hz: 866_550_000,
    },
    has_dwell_time_limit: false,
};

// RU864-870, RP002-1.0.5 section 3.13.

/// RP002-1.0.5 Table 102: RU864-870 TX data rate.
#[cfg(feature = "ru864")]
static RU864_DATA_RATES: [Option<DataRate>; 14] = [
    Some(DataRate::lora(12, 125_000, 250)),
    Some(DataRate::lora(11, 125_000, 440)),
    Some(DataRate::lora(10, 125_000, 980)),
    Some(DataRate::lora(9, 125_000, 1_760)),
    Some(DataRate::lora(8, 125_000, 3_125)),
    Some(DataRate::lora(7, 125_000, 5_470)),
    Some(DataRate::lora(7, 250_000, 11_000)),
    Some(DataRate::fsk(50_000)),
    None,
    None,
    None,
    None,
    Some(DataRate::lora(6, 125_000, 9_375)),
    Some(DataRate::lora(5, 125_000, 15_625)),
];

/// RP002-1.0.5 Table 107: RU864-870 maximum payload size (repeater compatible).
#[cfg(feature = "ru864")]
static RU864_MAX_PAYLOAD_REPEATER: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(230, 222)),
    Some(MaxPayload::new(230, 222)),
];

/// RP002-1.0.5 Table 108: RU864-870 maximum payload size (not repeater compatible).
#[cfg(feature = "ru864")]
static RU864_MAX_PAYLOAD_DIRECT: [Option<MaxPayload>; 14] = [
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(59, 51)),
    Some(MaxPayload::new(123, 115)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
    None,
    None,
    None,
    None,
    Some(MaxPayload::new(250, 242)),
    Some(MaxPayload::new(250, 242)),
];

/// RP002-1.0.5 Table 109: RU864-870 downlink RX1 data rate mapping.
#[cfg(feature = "ru864")]
static RU864_RX1: [&[u8]; 14] = [
    &[0, 0, 0, 0, 0, 0],
    &[1, 0, 0, 0, 0, 0],
    &[2, 1, 0, 0, 0, 0],
    &[3, 2, 1, 0, 0, 0],
    &[4, 3, 2, 1, 0, 0],
    &[5, 4, 3, 2, 1, 0],
    &[6, 5, 4, 3, 2, 1],
    &[7, 6, 5, 4, 3, 2],
    &[0, 0, 0, 0, 0, 0],
    &[0, 0, 0, 0, 0, 0],
    &[0, 0, 0, 0, 0, 0],
    &[0, 0, 0, 0, 0, 0],
    &[12, 5, 4, 3, 2, 1],
    &[13, 12, 5, 4, 3, 2],
];

/// RP002-1.0.5 Table 104: RU864-870 data rate back-off.
#[cfg(feature = "ru864")]
static RU864_BACKOFF: [Option<u8>; 14] = [
    None,
    Some(0),
    Some(1),
    Some(2),
    Some(3),
    Some(4),
    Some(5),
    Some(6),
    None,
    None,
    None,
    None,
    Some(5),
    Some(12),
];

/// RP002-1.0.5 Tables 100 and 101: the two default and join channels.
#[cfg(feature = "ru864")]
static RU864_CHANNELS: [ChannelBlock; 1] = [ChannelBlock::new(868_900_000, 200_000, 2, 0, 5)];

/// The Russian band carries a 1% duty cycle on its default channels.
#[cfg(feature = "ru864")]
static RU864_SUB_BANDS: [SubBand; 1] = [SubBand::new(868_700_000, 869_200_000, 10, 16)];

/// The RU864-870 channel plan, RP002-1.0.5 section 3.13.
#[cfg(feature = "ru864")]
pub static RU864: ChannelPlan<'static> = ChannelPlan {
    name: "RU864-870",
    uplink_data_rates: &RU864_DATA_RATES,
    downlink_data_rates: &RU864_DATA_RATES,
    max_payload_repeater: &RU864_MAX_PAYLOAD_REPEATER,
    max_payload_direct: &RU864_MAX_PAYLOAD_DIRECT,
    downlink_max_payload_repeater: &RU864_MAX_PAYLOAD_REPEATER,
    downlink_max_payload_direct: &RU864_MAX_PAYLOAD_DIRECT,
    max_payload_dwell_limited: None,
    join_channels: &RU864_CHANNELS,
    default_channels: &RU864_CHANNELS,
    sub_bands: &RU864_SUB_BANDS,
    default_max_eirp_dbm: 16,
    tx_power_step_db: 2,
    max_tx_power_index: 7,
    rx1_data_rate_offsets: &RU864_RX1,
    rx1_data_rate_offsets_dwell_limited: None,
    max_rx1_data_rate_offset: 5,
    rx2_frequency_hz: 869_100_000,
    rx2_data_rate: 0,
    data_rate_backoff: &RU864_BACKOFF,
    beacon: Beacon {
        data_rate: 3,
        frequency_hz: 869_100_000,
        ping_slot_frequency_hz: 868_900_000,
    },
    has_dwell_time_limit: false,
};