api: Rename Mesh to MeshEvent.

This is needed as we are also adding commands, thus we need MeshEvent
and MeshCommand messages.
This commit is contained in:
Orne Brocaar
2025-05-14 13:34:21 +01:00
parent 5cf1120f20
commit 038e45e8f0
4 changed files with 80 additions and 14 deletions

41
api/proto/gw/gw.proto vendored
View File

@ -114,7 +114,7 @@ message Event {
GatewayStats gateway_stats = 2; GatewayStats gateway_stats = 2;
// Gateway Mesh Event. // Gateway Mesh Event.
Mesh mesh = 3; MeshEvent mesh = 3;
} }
} }
@ -132,10 +132,13 @@ message Command {
// Get location. // Get location.
GetLocationRequest get_location = 4; GetLocationRequest get_location = 4;
// Gateway Mesh Command.
MeshCommand mesh = 5;
} }
} }
message Mesh { message MeshEvent {
// Gateway ID (of the Border Gateway). // Gateway ID (of the Border Gateway).
string gateway_id = 1; string gateway_id = 1;
@ -146,10 +149,10 @@ message Mesh {
google.protobuf.Timestamp time = 3; google.protobuf.Timestamp time = 3;
// Mesh events. // Mesh events.
repeated MeshEvent events = 4; repeated MeshEventItem events = 4;
} }
message MeshEvent { message MeshEventItem {
oneof event { oneof event {
// Proprietary Mesh event. // Proprietary Mesh event.
MeshEventProprietary proprietary = 1; MeshEventProprietary proprietary = 1;
@ -159,6 +162,27 @@ message MeshEvent {
} }
} }
message MeshCommand {
// Gateway ID (of the Border Gateway).
string gateway_id = 1;
// Relay ID.
string relay_id = 2;
// Timestamp (second precision).
google.protobuf.Timestamp time = 3;
// Mesh events.
repeated MeshCommandItem commands = 4;
}
message MeshCommandItem {
oneof command {
// Proprietary Mesh command.
MeshCommandProprietary proprietary = 1;
}
}
message Modulation { message Modulation {
oneof parameters { oneof parameters {
// LoRa modulation information. // LoRa modulation information.
@ -848,3 +872,12 @@ message MeshEventProprietary {
// Payload. // Payload.
bytes payload = 2; bytes payload = 2;
} }
// Proprietary mesh command.
message MeshCommandProprietary {
// Command type.
uint32 command_type = 1;
// Payload.
bytes payload = 2;
}

View File

@ -114,7 +114,7 @@ message Event {
GatewayStats gateway_stats = 2; GatewayStats gateway_stats = 2;
// Gateway Mesh Event. // Gateway Mesh Event.
Mesh mesh = 3; MeshEvent mesh = 3;
} }
} }
@ -132,10 +132,13 @@ message Command {
// Get location. // Get location.
GetLocationRequest get_location = 4; GetLocationRequest get_location = 4;
// Gateway Mesh Command.
MeshCommand mesh = 5;
} }
} }
message Mesh { message MeshEvent {
// Gateway ID (of the Border Gateway). // Gateway ID (of the Border Gateway).
string gateway_id = 1; string gateway_id = 1;
@ -146,10 +149,10 @@ message Mesh {
google.protobuf.Timestamp time = 3; google.protobuf.Timestamp time = 3;
// Mesh events. // Mesh events.
repeated MeshEvent events = 4; repeated MeshEventItem events = 4;
} }
message MeshEvent { message MeshEventItem {
oneof event { oneof event {
// Proprietary Mesh event. // Proprietary Mesh event.
MeshEventProprietary proprietary = 1; MeshEventProprietary proprietary = 1;
@ -159,6 +162,27 @@ message MeshEvent {
} }
} }
message MeshCommand {
// Gateway ID (of the Border Gateway).
string gateway_id = 1;
// Relay ID.
string relay_id = 2;
// Timestamp (second precision).
google.protobuf.Timestamp time = 3;
// Mesh events.
repeated MeshCommandItem commands = 4;
}
message MeshCommandItem {
oneof command {
// Proprietary Mesh command.
MeshCommandProprietary proprietary = 1;
}
}
message Modulation { message Modulation {
oneof parameters { oneof parameters {
// LoRa modulation information. // LoRa modulation information.
@ -848,3 +872,12 @@ message MeshEventProprietary {
// Payload. // Payload.
bytes payload = 2; bytes payload = 2;
} }
// Proprietary mesh command.
message MeshCommandProprietary {
// Command type.
uint32 command_type = 1;
// Payload.
bytes payload = 2;
}

View File

@ -417,7 +417,7 @@ async fn message_callback(
.inc(); .inc();
let event = match json { let event = match json {
true => serde_json::from_slice(&p.payload)?, true => serde_json::from_slice(&p.payload)?,
false => chirpstack_api::gw::Mesh::decode(p.payload.as_ref())?, false => chirpstack_api::gw::MeshEvent::decode(p.payload.as_ref())?,
}; };
tokio::spawn(uplink::mesh::Mesh::handle(event)); tokio::spawn(uplink::mesh::Mesh::handle(event));

View File

@ -18,11 +18,11 @@ pub struct Mesh {
gateway_id: EUI64, gateway_id: EUI64,
relay_id: RelayId, relay_id: RelayId,
time: DateTime<Utc>, time: DateTime<Utc>,
mesh_event: gw::Mesh, mesh_event: gw::MeshEvent,
} }
impl Mesh { impl Mesh {
pub async fn handle(s: gw::Mesh) { pub async fn handle(s: gw::MeshEvent) {
let gateway_id = match EUI64::from_str(&s.gateway_id) { let gateway_id = match EUI64::from_str(&s.gateway_id) {
Ok(v) => v, Ok(v) => v,
Err(e) => { Err(e) => {
@ -59,7 +59,7 @@ impl Mesh {
} }
} }
async fn _handle(gateway_id: EUI64, relay_id: RelayId, s: gw::Mesh) -> Result<()> { async fn _handle(gateway_id: EUI64, relay_id: RelayId, s: gw::MeshEvent) -> Result<()> {
let ctx = Mesh { let ctx = Mesh {
gateway_id, gateway_id,
relay_id, relay_id,
@ -81,8 +81,8 @@ impl Mesh {
for event in &self.mesh_event.events { for event in &self.mesh_event.events {
match &event.event { match &event.event {
Some(gw::mesh_event::Event::Proprietary(_)) | None => continue, Some(gw::mesh_event_item::Event::Proprietary(_)) | None => continue,
Some(gw::mesh_event::Event::Heartbeat(v)) => self._handle_heartbeat(v).await?, Some(gw::mesh_event_item::Event::Heartbeat(v)) => self._handle_heartbeat(v).await?,
} }
} }