use fundamentum_edge_proto::com::fundamentum::edge::v1::{ telemetry_client::TelemetryClient, Qos, TelemetryRequest, }; use tonic::Request; async fn publish_telemetry() -> Result<(), Box> { let mut client = TelemetryClient::connect("http://127.0.0.1:8080").await?; let mut requests = Vec::new(); for i in 0..10 { let request = TelemetryRequest { payload: vec![i], sub_topic: "stream_telemetry_sub_topic".to_owned(), qos: Some(i32::from(Qos::AtLeastOnce)), }; requests.push(request); } let _response = client .publish(Request::new(tokio_stream::iter(requests))) .await?; Ok(()) } async fn publish_one_telemetry() -> Result<(), Box> { let mut client = TelemetryClient::connect("http://127.0.0.1:8080").await?; let request = TelemetryRequest { payload: vec![], sub_topic: "one_telemetry_sub_topic".to_owned(), qos: Some(i32::from(Qos::AtLeastOnce)), }; let _response = client.publish_one(request).await?; Ok(()) } #[tokio::main] async fn main() -> Result<(), Box> { publish_telemetry().await?; publish_one_telemetry().await?; Ok(()) }