Skip to content

Commit 4451330

Browse files
committed
Change MeshStats > MeshHeartbeat.
1 parent e6e6075 commit 4451330

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"usage",
1717
"derive",
1818
] }
19-
chirpstack_api = { version = "4.9.0-test.1", default-features = false, features = [
19+
chirpstack_api = { version = "4.9.0-test.2", default-features = false, features = [
2020
"json",
2121
] }
2222
lrwn_filters = { version = "4.7", features = ["serde"] }

src/backend/concentratord.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use tokio::task;
1313
use super::Backend as BackendTrait;
1414
use crate::config::Configuration;
1515
use crate::metadata;
16-
use crate::mqtt::{send_gateway_stats, send_mesh_stats, send_tx_ack, send_uplink_frame};
16+
use crate::mqtt::{send_gateway_stats, send_mesh_heartbeat, send_tx_ack, send_uplink_frame};
1717

1818
pub struct Backend {
1919
gateway_id: String,
@@ -291,10 +291,10 @@ async fn handle_event_msg(
291291
pl.metadata.extend(metadata::get().await?);
292292
send_gateway_stats(&pl).await?;
293293
}
294-
"mesh_stats" => {
295-
let pl = gw::MeshStats::decode(pl)?;
296-
info!("Received mesh stats");
297-
send_mesh_stats(&pl).await?;
294+
"mesh_heartbeat" => {
295+
let pl = gw::MeshHeartbeat::decode(pl)?;
296+
info!("Received mesh heartbeat");
297+
send_mesh_heartbeat(&pl).await?;
298298
}
299299
_ => {
300300
return Err(anyhow!("Unexpected event: {}", event));

src/mqtt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,15 @@ pub async fn send_gateway_stats(pl: &gw::GatewayStats) -> Result<()> {
286286
Ok(())
287287
}
288288

289-
pub async fn send_mesh_stats(pl: &gw::MeshStats) -> Result<()> {
289+
pub async fn send_mesh_heartbeat(pl: &gw::MeshHeartbeat) -> Result<()> {
290290
let state = STATE.get().ok_or_else(|| anyhow!("STATE is not set"))?;
291291

292292
let b = match state.json {
293293
true => serde_json::to_vec(&pl)?,
294294
false => pl.encode_to_vec(),
295295
};
296-
let topic = get_event_topic(&state.topic_prefix, &state.gateway_id, "mesh-stats");
297-
info!("Sending mesh stats event, topic: {}", topic);
296+
let topic = get_event_topic(&state.topic_prefix, &state.gateway_id, "mesh-heartbeat");
297+
info!("Sending mesh heartbeat event, topic: {}", topic);
298298
state.client.publish(topic, state.qos, false, b).await?;
299299
trace!("Message published");
300300

tests/concentratord_test.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,30 +187,30 @@ async fn end_to_end() {
187187
pl
188188
);
189189

190-
// Mesh Stats
191-
let mesh_stats_pl = gw::MeshStats {
190+
// Mesh Heartbeat
191+
let mesh_heartbeat_pl = gw::MeshHeartbeat {
192192
gateway_id: "0102030405060708".into(),
193193
..Default::default()
194194
};
195195
thread::spawn({
196196
let zmq_pub = zmq_pub.clone();
197-
let mesh_stats_pl = mesh_stats_pl.encode_to_vec();
197+
let mesh_heartbeat_pl = mesh_heartbeat_pl.encode_to_vec();
198198

199199
move || {
200200
let zmq_pub = zmq_pub.lock().unwrap();
201-
zmq_pub.send("mesh_stats", zmq::SNDMORE).unwrap();
202-
zmq_pub.send(mesh_stats_pl, 0).unwrap();
201+
zmq_pub.send("mesh_heartbeat", zmq::SNDMORE).unwrap();
202+
zmq_pub.send(mesh_heartbeat_pl, 0).unwrap();
203203
}
204204
});
205205

206206
let mqtt_msg = mqtt_rx.recv().await.unwrap();
207207
assert_eq!(
208-
"eu868/gateway/0102030405060708/event/mesh-stats",
208+
"eu868/gateway/0102030405060708/event/mesh-heartbeat",
209209
String::from_utf8(mqtt_msg.topic.to_vec()).unwrap()
210210
);
211-
let pl = gw::MeshStats::decode(&mut Cursor::new(mqtt_msg.payload.to_vec())).unwrap();
211+
let pl = gw::MeshHeartbeat::decode(&mut Cursor::new(mqtt_msg.payload.to_vec())).unwrap();
212212
assert_eq!(
213-
gw::MeshStats {
213+
gw::MeshHeartbeat {
214214
gateway_id: "0102030405060708".into(),
215215
..Default::default()
216216
},

0 commit comments

Comments
 (0)