From d7a4334b7714b27ad0981e668d923f3911d41316 Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Mon, 1 Aug 2022 12:08:08 +0100 Subject: [PATCH] Fix missing GatewayStats v4_migrate. This is needed as the gateway_id field has changed from bytes to string (as the Protobuf JSON mapping encodes bytes to base64). --- api/rust/src/gw.rs | 8 ++++++++ chirpstack/src/gateway/backend/mqtt.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/api/rust/src/gw.rs b/api/rust/src/gw.rs index 202070f9..7b89b5de 100644 --- a/api/rust/src/gw.rs +++ b/api/rust/src/gw.rs @@ -277,3 +277,11 @@ impl DownlinkTxAck { } } } + +impl GatewayStats { + pub fn v4_migrate(&mut self) { + if self.gateway_id.is_empty() { + self.gateway_id = hex::encode(&self.gateway_id_legacy); + } + } +} diff --git a/chirpstack/src/gateway/backend/mqtt.rs b/chirpstack/src/gateway/backend/mqtt.rs index 9636aa83..6958a107 100644 --- a/chirpstack/src/gateway/backend/mqtt.rs +++ b/chirpstack/src/gateway/backend/mqtt.rs @@ -328,6 +328,7 @@ async fn message_callback(region_name: &str, region_common_name: CommonName, msg }) .inc(); let mut event = chirpstack_api::gw::GatewayStats::decode(&mut Cursor::new(b))?; + event.v4_migrate(); event .meta_data .insert("region_name".to_string(), region_name.to_string());