1use crate::{
13 Band, BandPlan, BandRestrictions, LicenseClass, PlanBand, PowerRestriction, Segment,
14 UsageRestriction,
15};
16use rfham_core::{
17 agencies::{agency_arrl, agency_fcc},
18 countries::country_code_us,
19 frequencies::megahertz,
20 power::watts,
21};
22use rfham_itu::{allocations::FrequencyAllocation::*, regions::Region};
23
24pub fn band_2200m() -> Band {
37 Band::new_default(Band2200M, Region::Two)
38}
39
40pub fn band_630m() -> Band {
41 Band::new_default(Band630M, Region::Two)
42}
43
44pub fn band_160m() -> Band {
45 Band::new_default(Band160M, Region::Two)
46}
47
48pub fn band_80m() -> Band {
49 Band::new_default(Band80M, Region::Two)
50}
51
52pub fn band_60m() -> Band {
53 Band::new_default(Band60M, Region::Two)
54}
55
56pub fn band_40m() -> Band {
57 Band::new_default(Band40M, Region::Two)
58}
59
60pub fn band_30m() -> Band {
61 Band::new_default(Band30M, Region::Two)
62}
63
64pub fn band_20m() -> Band {
65 Band::new_default(Band20M, Region::Two)
66}
67
68pub fn band_17m() -> Band {
69 Band::new_default(Band17M, Region::Two)
70}
71
72pub fn band_15m() -> Band {
73 Band::new_default(Band15M, Region::Two)
74}
75
76pub fn band_12m() -> Band {
77 Band::new_default(Band12M, Region::Two)
78}
79
80pub fn band_10m() -> Band {
81 Band::new_default(Band10M, Region::Two)
82}
83
84pub fn band_6m() -> Band {
85 Band::new_default(Band6M, Region::Two)
86}
87
88pub fn band_2m() -> Band {
89 Band::new_default(Band2M, Region::Two)
90}
91
92pub fn band_1_25m() -> Band {
93 Band::new_default(Band1_25M, Region::Two)
94}
95
96pub fn band_70cm() -> Band {
97 Band::new_default(Band70Cm, Region::Two)
98}
99
100pub fn band_33cm() -> Band {
101 Band::new_default(Band33Cm, Region::Two)
102}
103
104pub fn band_23cm() -> Band {
105 Band::new_default(Band23Cm, Region::Two)
106}
107
108pub fn band_13cm() -> Band {
109 Band::new_default(Band13Cm, Region::Two)
110}
111
112pub fn band_9cm() -> Band {
113 Band::new_default(Band9Cm, Region::Two)
114}
115
116pub fn band_5cm() -> Band {
117 Band::new_default(Band5Cm, Region::Two)
118}
119
120pub fn band_3cm() -> Band {
121 Band::new_default(Band3Cm, Region::Two)
122}
123
124pub fn band_1_2cm() -> Band {
125 Band::new_default(Band1_2Cm, Region::Two)
126}
127
128pub fn band_6mm() -> Band {
129 Band::new_default(Band6Mm, Region::Two)
130}
131
132pub fn band_4mm() -> Band {
133 Band::new_default(Band4Mm, Region::Two)
134}
135
136pub fn band_2_5mm() -> Band {
137 Band::new_default(Band2_5Mm, Region::Two)
138}
139
140pub fn band_2mm() -> Band {
141 Band::new_default(Band2Mm, Region::Two)
142}
143
144pub fn band_1mm() -> Band {
145 Band::new_default(Band1Mm, Region::Two)
146}
147
148pub fn arrl_voluntary_band_plan() -> BandPlan {
149 BandPlan::new(agency_arrl(), Region::Two, "US Amateur Radio Bands")
150 .with_regulator(agency_fcc())
151 .in_country(country_code_us())
152 .with_default_max_power(watts(1500.0))
153 .with_notes(vec![
154 "An amateur station must use the minimum transmitter power necessary to carry out the desired communications.".to_string()
155 ])
156 .with_licenses(
157 vec![
158 ("N".to_string(), LicenseClass::new(1, "Novice", false)),
159 ("T".to_string(), LicenseClass::new(2, "Technician", true)),
160 ("G".to_string(), LicenseClass::new(3, "General", true)),
161 ("A".to_string(), LicenseClass::new(4, "Advanced", false)),
162 ("E".to_string(), LicenseClass::new(5, "Amateur Extra", true)),
163 ]
164 .into_iter()
165 .collect(),
166 )
167 .with_bands_list(vec![
168 PlanBand::new(band_2200m()).with_restrictions(
169 BandRestrictions::default()
170 .with_license_restrictions(
171 vec!["G", "A", "E"]
172 .into_iter()
173 .map(|n| n.to_string())
174 .collect(),
175 )
176 .with_usage_restrictions(vec![UsageRestriction::Rtty, UsageRestriction::Data, UsageRestriction::Phone])
177 .with_power_restriction(PowerRestriction::eirp(watts(1.0))),
178 ),
179 PlanBand::new(band_630m()).with_is_primary_user(false)
180 .with_restrictions(
181 BandRestrictions::default()
182 .with_license_restrictions(
183 vec!["G", "A", "E"]
184 .into_iter()
185 .map(|n| n.to_string())
186 .collect(),
187 )
188 .with_usage_restrictions(vec![UsageRestriction::Rtty, UsageRestriction::Data, UsageRestriction::Phone])
189 .with_power_restriction(PowerRestriction::eirp(watts(5.0))),
190 ),
191 PlanBand::new(band_160m()).with_restrictions(
192 BandRestrictions::default().with_license_restrictions(
193 vec!["G", "A", "E"]
194 .into_iter()
195 .map(|n| n.to_string())
196 .collect(),
197 )
198 .with_usage_restrictions(vec![UsageRestriction::Rtty, UsageRestriction::Data, UsageRestriction::Phone])
199,
200 )
201 .with_notes(vec!["Avoid interference to radiolocation operations from 1.9MHz-2.0MHz.".to_string()]),
202 PlanBand::new(band_80m()).with_segments(vec![
203 Segment::new(megahertz(3.5), megahertz(3.6)).with_restrictions(
204 BandRestrictions::default()
205 .with_usage_restrictions(vec![UsageRestriction::Rtty, UsageRestriction::Data])
206 .with_license_restrictions(vec!["E".to_string()])
207 ),
208 Segment::new(megahertz(3.6), megahertz(4.0)).with_restrictions(
209 BandRestrictions::default()
210 .with_usage_restrictions(vec![UsageRestriction::Phone])
211 .with_license_restrictions(vec!["E".to_string()])
212 ),
213 Segment::new(megahertz(3.525), megahertz(3.6)).with_restrictions(
214 BandRestrictions::default()
215 .with_usage_restrictions(vec![UsageRestriction::Rtty, UsageRestriction::Data])
216 .with_license_restrictions(vec!["A".to_string()])
217 ),
218 Segment::new(megahertz(3.7), megahertz(4.0)).with_restrictions(
219 BandRestrictions::default()
220 .with_usage_restrictions(vec![UsageRestriction::Phone])
221 .with_license_restrictions(vec!["A".to_string()])
222 ),
223 Segment::new(megahertz(3.525), megahertz(3.6)).with_restrictions(
224 BandRestrictions::default()
225 .with_usage_restrictions(vec![UsageRestriction::Rtty, UsageRestriction::Data])
226 .with_license_restrictions(vec!["G".to_string()])
227 ),
228 Segment::new(megahertz(3.8), megahertz(4.0)).with_restrictions(
229 BandRestrictions::default()
230 .with_usage_restrictions(vec![UsageRestriction::Phone])
231 .with_license_restrictions(vec!["G".to_string()])
232 ),
233 Segment::new(megahertz(3.525), megahertz(3.6)).with_restrictions(
234 BandRestrictions::default()
235 .with_usage_restrictions(vec![UsageRestriction::CW])
236 .with_license_restrictions(vec!["N".to_string(), "T".to_string()])
237 ),
238 ]),
239 PlanBand::new(band_60m()), PlanBand::new(band_40m()), PlanBand::new(band_30m()).with_restrictions(
242 BandRestrictions::default()
243 .with_license_restrictions(
244 vec!["G", "A", "E"]
245 .into_iter()
246 .map(|n| n.to_string())
247 .collect(),
248 )
249 .with_power_restriction(PowerRestriction::pep(watts(200.0))),
250 ),
251 PlanBand::new(band_20m()), PlanBand::new(band_17m()).with_segments(vec![
253 Segment::new(megahertz(18.068), megahertz(18.110)).with_restrictions(
254 BandRestrictions::default()
255 .with_usage_restrictions(vec![UsageRestriction::Rtty, UsageRestriction::Data])
256 .with_license_restrictions(vec!["G", "A", "E"]
257 .into_iter()
258 .map(|n| n.to_string())
259 .collect(),)
260 ),
261 Segment::new(megahertz(18.110), megahertz(18.168)).with_restrictions(
262 BandRestrictions::default()
263 .with_usage_restrictions(vec![UsageRestriction::Phone])
264 .with_license_restrictions(vec!["G", "A", "E"]
265 .into_iter()
266 .map(|n| n.to_string())
267 .collect(),)
268 ),
269 ]),
270 PlanBand::new(band_15m()), PlanBand::new(band_12m()), PlanBand::new(band_10m()), PlanBand::new(band_6m()).with_segments(vec![
274 Segment::new(megahertz(50.0), megahertz(50.1)).with_restrictions(
275 BandRestrictions::default()
276 .with_usage_restrictions(vec![UsageRestriction::CW]),
277 ),
278 Segment::new(megahertz(50.1), megahertz(54.0)),
279 ]),
280 PlanBand::new(band_2m()).with_segments(vec![
281 Segment::new(megahertz(144.0), megahertz(144.1)).with_restrictions(
282 BandRestrictions::default()
283 .with_usage_restrictions(vec![UsageRestriction::CW]),
284 ),
285 Segment::new(megahertz(144.1), megahertz(148.0)),
286 ]),
287 PlanBand::new(band_1_25m()), PlanBand::new(band_70cm()).with_restrictions(
289 BandRestrictions::default()
290 .with_license_restrictions(
291 vec!["T", "G", "A", "E"]
292 .into_iter()
293 .map(|n| n.to_string())
294 .collect(),
295 )
296 .with_usage_restrictions(vec![UsageRestriction::Rtty, UsageRestriction::Data, UsageRestriction::Phone])
297 ),
298 PlanBand::new(band_33cm()).with_restrictions(
299 BandRestrictions::default()
300 .with_license_restrictions(
301 vec!["T", "G", "A", "E"]
302 .into_iter()
303 .map(|n| n.to_string())
304 .collect(),
305 )
306 .with_usage_restrictions(vec![UsageRestriction::Rtty, UsageRestriction::Data, UsageRestriction::Phone])
307 ),
308 PlanBand::new(band_23cm()), PlanBand::new(band_13cm()).with_restrictions(
310 BandRestrictions::default()
311 .with_license_restrictions(
312 vec!["T", "G", "A", "E"]
313 .into_iter()
314 .map(|n| n.to_string())
315 .collect(),
316 )),
317 PlanBand::new(band_9cm()).with_restrictions(
318 BandRestrictions::default()
319 .with_license_restrictions(
320 vec!["T", "G", "A", "E"]
321 .into_iter()
322 .map(|n| n.to_string())
323 .collect(),
324 )),
325 PlanBand::new(band_5cm()).with_restrictions(
326 BandRestrictions::default()
327 .with_license_restrictions(
328 vec!["T", "G", "A", "E"]
329 .into_iter()
330 .map(|n| n.to_string())
331 .collect(),
332 )),
333 PlanBand::new(band_3cm()).with_restrictions(
334 BandRestrictions::default()
335 .with_license_restrictions(
336 vec!["T", "G", "A", "E"]
337 .into_iter()
338 .map(|n| n.to_string())
339 .collect(),
340 )),
341 PlanBand::new(band_1_2cm()).with_restrictions(
342 BandRestrictions::default()
343 .with_license_restrictions(
344 vec!["T", "G", "A", "E"]
345 .into_iter()
346 .map(|n| n.to_string())
347 .collect(),
348 )),
349 PlanBand::new(band_6mm()).with_restrictions(
350 BandRestrictions::default()
351 .with_license_restrictions(
352 vec!["T", "G", "A", "E"]
353 .into_iter()
354 .map(|n| n.to_string())
355 .collect(),
356 )),
357 PlanBand::new(band_4mm()).with_restrictions(
358 BandRestrictions::default()
359 .with_license_restrictions(
360 vec!["T", "G", "A", "E"]
361 .into_iter()
362 .map(|n| n.to_string())
363 .collect(),
364 )),
365 PlanBand::new(band_2_5mm()).with_restrictions(
366 BandRestrictions::default()
367 .with_license_restrictions(
368 vec!["T", "G", "A", "E"]
369 .into_iter()
370 .map(|n| n.to_string())
371 .collect(),
372 )),
373 PlanBand::new(band_2mm()).with_restrictions(
374 BandRestrictions::default()
375 .with_license_restrictions(
376 vec!["T", "G", "A", "E"]
377 .into_iter()
378 .map(|n| n.to_string())
379 .collect(),
380 )),
381 PlanBand::new(band_1mm()).with_restrictions(
382 BandRestrictions::default()
383 .with_license_restrictions(
384 vec!["T", "G", "A", "E"]
385 .into_iter()
386 .map(|n| n.to_string())
387 .collect(),
388 )),
389 ])
390}
391
392#[cfg(test)]
413mod test {
414 use super::*;
415 use rfham_markdown::ToMarkdown;
416
417 #[test]
418 fn test_write_json_band_plan() {
419 let plan = arrl_voluntary_band_plan();
420 println!("{}", serde_json::to_string_pretty(&plan).unwrap());
421 }
422
423 #[test]
424 fn test_write_markdown_band_plan() {
425 let plan = arrl_voluntary_band_plan();
426 plan.write_markdown(&mut std::io::stdout()).unwrap();
427 }
428}