File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -174,7 +174,16 @@ async fn setup_mesh_conncentratord(conf: &Configuration) -> Result<()> {
174174 info ! ( "Retrieved Gateway ID: {}" , resp. gateway_id) ;
175175
176176 let mut relay_id: [ u8 ; 4 ] = [ 0 ; 4 ] ;
177- relay_id. copy_from_slice ( & hex:: decode ( & resp. gateway_id ) ?[ 4 ..] ) ;
177+ if conf. mesh . relay_id . is_empty ( ) {
178+ relay_id. copy_from_slice ( & hex:: decode ( & resp. gateway_id ) ?[ 4 ..] ) ;
179+ } else {
180+ info ! ( "Using relay_id from configuration file" ) ;
181+ let b = hex:: decode ( & conf. mesh . relay_id ) ?;
182+ if b. len ( ) != 4 {
183+ return Err ( anyhow ! ( "relay_id must be exactly 4 bytes!" ) ) ;
184+ }
185+ relay_id. copy_from_slice ( & b) ;
186+ }
178187 RELAY_ID
179188 . set ( Mutex :: new ( relay_id) )
180189 . map_err ( |e| anyhow ! ( "OnceLock error: {:?}" , e) ) ?;
Original file line number Diff line number Diff line change @@ -39,6 +39,13 @@ pub fn run() {
3939 # above root_key, but this key will be used.
4040 signing_key="{{ mesh.signing_key }}"
4141
42+ # Relay ID.
43+ #
44+ # If set, this will override the Relay ID that is derived from the
45+ # Gateway ID provided by the Concentratord backend (using the 4 least
46+ # significant bytes). Example: "01020304".
47+ relay_id="{{ mesh.relay_id }}"
48+
4249 # Border Gateway.
4350 #
4451 # If this is set to true, then the ChirpStack Gateway Mesh will consider
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ impl Default for Logging {
5858#[ derive( Serialize , Deserialize ) ]
5959#[ serde( default ) ]
6060pub struct Mesh {
61+ pub relay_id : String ,
6162 pub root_key : Aes128Key ,
6263 pub signing_key : Aes128Key ,
6364 pub frequencies : Vec < u32 > ,
@@ -73,6 +74,7 @@ pub struct Mesh {
7374impl Default for Mesh {
7475 fn default ( ) -> Self {
7576 Mesh {
77+ relay_id : "" . into ( ) ,
7678 root_key : Aes128Key :: null ( ) ,
7779 signing_key : Aes128Key :: null ( ) ,
7880 frequencies : vec ! [ 868100000 , 868300000 , 868500000 ] ,
You can’t perform that action at this time.
0 commit comments