@@ -4,7 +4,6 @@ use std::{
44} ;
55
66use clap:: Parser ;
7- use lazy_static:: lazy_static;
87use pcap_file:: {
98 pcap:: { PcapHeader , PcapPacket , PcapWriter } ,
109 DataLink ,
@@ -35,59 +34,6 @@ fn config_option_value(value: &'static str) -> ConfigOptionValue {
3534 . build ( )
3635}
3736
38- lazy_static ! {
39- static ref METADATA : Metadata = Metadata {
40- help_url: "http://github.com/esp-rs" . into( ) ,
41- display_description: "esp-ieee802154" . into( ) ,
42- ..r_extcap:: cargo_metadata!( )
43- } ;
44- static ref WIFI_CAPTURE_INTERFACE : Interface = Interface {
45- value: "802.15.4" . into( ) ,
46- display: "esp-ieee802154 Sniffer" . into( ) ,
47- dlt: Dlt {
48- data_link_type: DataLink :: USER0 ,
49- name: "USER0" . into( ) ,
50- display: "IEEE802.15.4" . into( ) ,
51- } ,
52- } ;
53- static ref CONFIG_SERIALPORT : StringConfig = StringConfig :: builder( )
54- . config_number( 1 )
55- . call( "serialport" )
56- . display( "Serialport" )
57- . tooltip( "Serialport to connect to" )
58- . required( false )
59- . placeholder( "" )
60- . build( ) ;
61- static ref CONFIG_CHANNEL : SelectorConfig = SelectorConfig :: builder( )
62- . config_number( 3 )
63- . call( "channel" )
64- . display( "Channel" )
65- . tooltip( "Channel Selector" )
66- . default_options( [
67- ConfigOptionValue :: builder( )
68- . value( "11" )
69- . display( "11" )
70- . default ( true )
71- . build( ) ,
72- config_option_value( "12" ) ,
73- config_option_value( "13" ) ,
74- config_option_value( "14" ) ,
75- config_option_value( "15" ) ,
76- config_option_value( "16" ) ,
77- config_option_value( "17" ) ,
78- config_option_value( "18" ) ,
79- config_option_value( "19" ) ,
80- config_option_value( "20" ) ,
81- config_option_value( "21" ) ,
82- config_option_value( "22" ) ,
83- config_option_value( "23" ) ,
84- config_option_value( "24" ) ,
85- config_option_value( "25" ) ,
86- config_option_value( "26" ) ,
87- ] )
88- . build( ) ;
89- }
90-
9137fn main ( ) {
9238 let args = AppArgs :: parse ( ) ;
9339
@@ -97,17 +43,71 @@ fn main() {
9743 }
9844 }
9945
46+ let wifi_capture_interface = Interface {
47+ value : "802.15.4" . into ( ) ,
48+ display : "esp-ieee802154 Sniffer" . into ( ) ,
49+ dlt : Dlt {
50+ data_link_type : DataLink :: USER0 ,
51+ name : "USER0" . into ( ) ,
52+ display : "IEEE802.15.4" . into ( ) ,
53+ } ,
54+ } ;
55+
10056 match args. extcap . run ( ) . unwrap ( ) {
10157 ExtcapStep :: Interfaces ( interfaces_step) => {
102- interfaces_step. list_interfaces ( & METADATA , & [ & * WIFI_CAPTURE_INTERFACE ] , & [ ] ) ;
58+ let metadata = Metadata {
59+ help_url : "http://github.com/esp-rs" . into ( ) ,
60+ display_description : "esp-ieee802154" . into ( ) ,
61+ ..r_extcap:: cargo_metadata!( )
62+ } ;
63+
64+ interfaces_step. list_interfaces ( & metadata, & [ & wifi_capture_interface] , & [ ] ) ;
10365 }
10466 ExtcapStep :: Dlts ( dlts_step) => {
10567 dlts_step
106- . print_from_interfaces ( & [ & * WIFI_CAPTURE_INTERFACE ] )
68+ . print_from_interfaces ( & [ & wifi_capture_interface ] )
10769 . unwrap ( ) ;
10870 }
10971 ExtcapStep :: Config ( config_step) => {
110- config_step. list_configs ( & [ & * CONFIG_SERIALPORT , & * CONFIG_CHANNEL ] )
72+ let config_serialport = StringConfig :: builder ( )
73+ . config_number ( 1 )
74+ . call ( "serialport" )
75+ . display ( "Serialport" )
76+ . tooltip ( "Serialport to connect to" )
77+ . required ( false )
78+ . placeholder ( "" )
79+ . build ( ) ;
80+
81+ let config_channel = SelectorConfig :: builder ( )
82+ . config_number ( 3 )
83+ . call ( "channel" )
84+ . display ( "Channel" )
85+ . tooltip ( "Channel Selector" )
86+ . default_options ( [
87+ ConfigOptionValue :: builder ( )
88+ . value ( "11" )
89+ . display ( "11" )
90+ . default ( true )
91+ . build ( ) ,
92+ config_option_value ( "12" ) ,
93+ config_option_value ( "13" ) ,
94+ config_option_value ( "14" ) ,
95+ config_option_value ( "15" ) ,
96+ config_option_value ( "16" ) ,
97+ config_option_value ( "17" ) ,
98+ config_option_value ( "18" ) ,
99+ config_option_value ( "19" ) ,
100+ config_option_value ( "20" ) ,
101+ config_option_value ( "21" ) ,
102+ config_option_value ( "22" ) ,
103+ config_option_value ( "23" ) ,
104+ config_option_value ( "24" ) ,
105+ config_option_value ( "25" ) ,
106+ config_option_value ( "26" ) ,
107+ ] )
108+ . build ( ) ;
109+
110+ config_step. list_configs ( & [ & config_serialport, & config_channel] )
111111 }
112112 ExtcapStep :: ReloadConfig ( _reload_config_step) => {
113113 panic ! ( "Unsupported operation" ) ;
0 commit comments