Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/connections/stream_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<State> ConnectedStreamApi<State> {
///
/// # Arguments
///
/// * `packet_router` - A generic packet router field that implements the `PacketRouter` trait.
/// * `packet_router` - A struct that implements the `PacketRouter` trait.
/// * `byte_data` - A `Vec<u8>` containing the byte data to send.
/// * `port_num` - A `PortNum` enum that specifies the port number to send the packet on.
/// * `destination` - A `PacketDestination` enum that specifies the destination of the packet.
Expand Down Expand Up @@ -210,18 +210,22 @@ impl<State> ConnectedStreamApi<State> {
..Default::default()
};

mesh_packet.rx_time = current_epoch_secs_u32();

let payload_variant = Some(protobufs::to_radio::PayloadVariant::Packet(
mesh_packet.clone(),
));
self.send_to_radio_packet(payload_variant).await?;

// If the sending was successful, echo it back to the client via the `PacketRouter`
if echo_response {
mesh_packet.rx_time = current_epoch_secs_u32();
packet_router
.handle_mesh_packet(mesh_packet.clone())
.map_err(|e| Error::PacketHandlerFailure {
packet_router.handle_mesh_packet(mesh_packet).map_err(|e| {
Error::PacketHandlerFailure {
source: Box::new(e),
})?;
}
})?;
}

let payload_variant = Some(protobufs::to_radio::PayloadVariant::Packet(mesh_packet));
self.send_to_radio_packet(payload_variant).await?;

Ok(())
}

Expand Down
Loading