Skip to content

Commit

Permalink
[#13] Use any up-rust upstreamed code
Browse files Browse the repository at this point in the history
* Remove transport handle, collapse down to lib and transport
* Rearrange transport engine
* Implement LocalUriProvider

Implements [#6], [#8]
  • Loading branch information
PLeVasseur committed Aug 1, 2024
1 parent acbb0d0 commit 4100ea0
Show file tree
Hide file tree
Showing 18 changed files with 911 additions and 1,048 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ regex = { version = "1.10" }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
tokio = { version = "1.35.1", features = ["rt", "rt-multi-thread", "macros", "sync", "time", "tracing"] }
up-rust = { git = "https://github.com/eclipse-uprotocol/up-rust", rev = "3a50104421a801d52e1d9c68979db54c013ce43d" }
up-rust = { version = "0.1.5" }
vsomeip-proc-macro = { path = "vsomeip-proc-macro" }
vsomeip-sys = { path = "vsomeip-sys", default-features = false }

Expand Down
16 changes: 9 additions & 7 deletions up-transport-vsomeip/examples/hello_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,12 @@ impl UListener for ServiceResponseListener {
::protobuf::EnumOrUnknown::new(UPAYLOAD_FORMAT_PROTOBUF_WRAPPED_IN_ANY);
}

let Ok(hello_response) = msg.extract_protobuf_payload::<HelloResponse>() else {
let Ok(hello_response) = msg.extract_protobuf::<HelloResponse>() else {
panic!("Unable to parse into HelloResponse");
};

println!("Here we received response: {hello_response:?}");
}

async fn on_error(&self, err: UStatus) {
println!("ServiceResponseListener: Encountered an error: {err:?}");
}
}

#[tokio::main]
Expand All @@ -70,11 +66,17 @@ async fn main() -> Result<(), UStatus> {

// There will be a single vsomeip_transport, as there is a connection into device and a streamer
// TODO: Add error handling if we fail to create a UPTransportVsomeip
let client_uuri = UUri {
authority_name: CLIENT_AUTHORITY.to_string(),
ue_id: CLIENT_UE_ID as u32,
ue_version_major: CLIENT_UE_VERSION_MAJOR as u32,
resource_id: CLIENT_RESOURCE_ID as u32,
..Default::default()
};
let client: Arc<dyn UTransport> = Arc::new(
UPTransportVsomeip::new_with_config(
&CLIENT_AUTHORITY.to_string(),
client_uuri,
&HELLO_SERVICE_AUTHORITY.to_string(),
CLIENT_UE_ID,
&vsomeip_config.unwrap(),
None,
)
Expand Down
17 changes: 9 additions & 8 deletions up-transport-vsomeip/examples/hello_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::thread;
use up_rust::UPayloadFormat::UPAYLOAD_FORMAT_PROTOBUF_WRAPPED_IN_ANY;
use up_rust::{UListener, UMessage, UMessageBuilder, UStatus, UTransport, UUri};
use up_transport_vsomeip::UPTransportVsomeip;
use up_transport_vsomeip::UeId;

const HELLO_SERVICE_ID: u16 = 0x6000;
const HELLO_INSTANCE_ID: u32 = 0x0001;
Expand Down Expand Up @@ -51,7 +50,7 @@ impl UListener for ServiceRequestResponder {
::protobuf::EnumOrUnknown::new(UPAYLOAD_FORMAT_PROTOBUF_WRAPPED_IN_ANY);
}

let hello_request = msg.extract_protobuf_payload::<HelloRequest>();
let hello_request = msg.extract_protobuf::<HelloRequest>();

let hello_request = match hello_request {
Ok(hello_request) => {
Expand All @@ -74,10 +73,6 @@ impl UListener for ServiceRequestResponder {
.unwrap();
self.client.send(response_msg).await.unwrap();
}

async fn on_error(&self, err: UStatus) {
println!("ServiceRequestResponder: Encountered an error: {err:?}");
}
}

#[tokio::main]
Expand All @@ -94,11 +89,17 @@ async fn main() -> Result<(), UStatus> {

// There will be a single vsomeip_transport, as there is a connection into device and a streamer
// TODO: Add error handling if we fail to create a UPTransportVsomeip
let service_uuri = UUri {
authority_name: HELLO_SERVICE_AUTHORITY.to_string(),
ue_id: HELLO_SERVICE_UE_ID,
ue_version_major: HELLO_SERVICE_MAJOR as u32,
resource_id: HELLO_SERVICE_RESOURCE_ID as u32,
..Default::default()
};
let service: Arc<dyn UTransport> = Arc::new(
UPTransportVsomeip::new_with_config(
&HELLO_SERVICE_AUTHORITY.to_string(),
service_uuri,
&CLIENT_AUTHORITY.to_string(),
HELLO_SERVICE_UE_ID as UeId,
&vsomeip_config.unwrap(),
None,
)
Expand Down
4 changes: 2 additions & 2 deletions up-transport-vsomeip/src/determine_message_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ fn determine_type(
}
Some(ue_id) => ue_id,
},
DeterminationType::Send => source_filter.ue_id as ClientId,
DeterminationType::Send => source_filter.ue_id,
};
Ok(RegistrationType::Publish(client_id))
Ok(RegistrationType::Publish(client_id as ClientId))
}
}

Expand Down
Loading

0 comments on commit 4100ea0

Please sign in to comment.