File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 11use anyhow:: Result ;
2+ use chirpstack_api:: { gw, prost:: Message } ;
23
34use super :: commands;
45
@@ -7,9 +8,13 @@ pub fn get_gateway_id(command_url: &str) -> Result<Vec<u8>> {
78
89 let sock = commands:: get_socket ( command_url) . expect ( "get client error" ) ;
910
10- // send 'gateway_id' command with empty payload
11- sock. send ( "gateway_id" , zmq:: SNDMORE ) . unwrap ( ) ;
12- sock. send ( "" , 0 ) . unwrap ( ) ;
11+ // Send command.
12+ let cmd = gw:: Command {
13+ command : Some ( gw:: command:: Command :: GetGatewayId (
14+ gw:: GetGatewayIdRequest { } ,
15+ ) ) ,
16+ } ;
17+ sock. send ( cmd. encode_to_vec ( ) , 0 ) . unwrap ( ) ;
1318
1419 // set poller so that we can timout after 100ms
1520 let mut items = [ sock. as_poll_item ( zmq:: POLLIN ) ] ;
@@ -19,6 +24,8 @@ pub fn get_gateway_id(command_url: &str) -> Result<Vec<u8>> {
1924 }
2025
2126 // read 'gateway_id' response
22- let gateway_id = sock. recv_bytes ( 0 ) . unwrap ( ) ;
23- Ok ( gateway_id)
27+ let b = sock. recv_bytes ( 0 ) . unwrap ( ) ;
28+ let resp = gw:: GetGatewayIdResponse :: decode ( b. as_slice ( ) ) . unwrap ( ) ;
29+
30+ Ok ( hex:: decode ( resp. gateway_id ) ?)
2431}
You can’t perform that action at this time.
0 commit comments