Skip to content

Commit

Permalink
Improved seat massager sample
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbeitz committed Feb 28, 2024
1 parent 62391fa commit 65e057e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
32 changes: 16 additions & 16 deletions digital-twin-model/src/sdv_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod airbag_seat_massager {
pub const ID: &str = "dtmi:sdv:airbag_seat_massager:store_sequence:request;1";
pub const NAME: &str = "request";
pub const DESCRIPTION: &str = "Request.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub sequence_name: String,
pub sequence: crate::sdv_v1::airbag_seat_massager::massage_step::TYPE,
Expand All @@ -26,7 +26,7 @@ pub mod airbag_seat_massager {
pub const ID: &str = "dtmi:sdv:airbag_seat_massager:store_sequence:response;1";
pub const NAME: &str = "response";
pub const DESCRIPTION: &str = "Response.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub status: crate::sdv_v1::airbag_seat_massager::status::TYPE,
}
Expand All @@ -40,7 +40,7 @@ pub mod airbag_seat_massager {
pub const ID: &str = "dtmi:sdv:airbag_seat_massager:perform_step:request;1";
pub const NAME: &str = "request";
pub const DESCRIPTION: &str = "The request to perform a step in the sequence.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub step: crate::sdv_v1::airbag_seat_massager::massage_step::TYPE,
}
Expand All @@ -49,7 +49,7 @@ pub mod airbag_seat_massager {
pub const ID: &str = "dtmi:sdv:airbag_seat_massager:perform_step:response;1";
pub const NAME: &str = "response";
pub const DESCRIPTION: &str = "The response to performing a step in the sequence.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub status: crate::sdv_v1::airbag_seat_massager::status::TYPE,
}
Expand All @@ -59,7 +59,7 @@ pub mod airbag_seat_massager {
pub const ID: &str = "dtmi:sdv:airbag_seat_massager:airbag_adjustment;1";
pub const NAME: &str = "airbag_adjustment";
pub const DESCRIPTION: &str = "The airbag adjustments.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub airbag_identifier: i32,
pub inflation_level: i32,
Expand All @@ -82,10 +82,10 @@ pub mod airbag_seat_massager {
pub const ID: &str = "dtmi:sdv:airbag_seat_massager:status;1";
pub const NAME: &str = "status";
pub const DESCRIPTION: &str = "The status.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub code: i32,
pub message: String
pub message: String,
}
}
}
Expand All @@ -108,7 +108,7 @@ pub mod camera {
pub const ID: &str = "dtmi:sdv:camera:feed;1";
pub const NAME: &str = "feed";
pub const DESCRIPTION: &str = "The camera feed.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub media_type: String,
pub media_content: Vec<u8>,
Expand All @@ -127,7 +127,7 @@ pub mod hmi {
pub const ID: &str = "dtmi:sdv:hmi:show_notification::request;1";
pub const NAME: &str = "request";
pub const DESCRIPTION: &str = "The request.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub notification: String,
}
Expand All @@ -140,7 +140,7 @@ pub mod hmi {
pub const ID: &str = "dtmi:sdv:hmi:status;1";
pub const NAME: &str = "status";
pub const DESCRIPTION: &str = "The status.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub code: i32,
pub message: String,
Expand Down Expand Up @@ -204,7 +204,7 @@ pub mod seat_massager {
pub const ID: &str = "dtmi:sdv:seat_massager:load_sequence:request;1";
pub const NAME: &str = "request";
pub const DESCRIPTION: &str = "Request.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub sequence_name: String,
}
Expand All @@ -213,7 +213,7 @@ pub mod seat_massager {
pub const ID: &str = "dtmi:sdv:seat_massager:load_sequence:response;1";
pub const NAME: &str = "response";
pub const DESCRIPTION: &str = "Response.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub status: crate::sdv_v1::seat_massager::status::TYPE,
}
Expand All @@ -227,7 +227,7 @@ pub mod seat_massager {
pub const ID: &str = "dtmi:sdv:seat_massager:pause:response;1";
pub const NAME: &str = "response";
pub const DESCRIPTION: &str = "The response.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub status: crate::sdv_v1::seat_massager::status::TYPE,
}
Expand All @@ -241,7 +241,7 @@ pub mod seat_massager {
pub const ID: &str = "dtmi:sdv:seat_massager:play:response;1";
pub const NAME: &str = "response";
pub const DESCRIPTION: &str = "The response.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub status: crate::sdv_v1::seat_massager::status::TYPE,
}
Expand All @@ -255,7 +255,7 @@ pub mod seat_massager {
pub const ID: &str = "dtmi:sdv:seat_massager:reset:response;1";
pub const NAME: &str = "response";
pub const DESCRIPTION: &str = "The response.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub status: crate::sdv_v1::seat_massager::status::TYPE,
}
Expand All @@ -265,7 +265,7 @@ pub mod seat_massager {
pub const ID: &str = "dtmi:sdv:seat_massager:status;1";
pub const NAME: &str = "status";
pub const DESCRIPTION: &str = "The status.";
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)]
pub struct TYPE {
pub code: i32,
pub message: String,
Expand Down
5 changes: 2 additions & 3 deletions samples/command/provider/src/provider_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ impl DigitalTwinProvider for ProviderImpl {
.map_err(|error| Status::invalid_argument(error.to_string()))?;
let notification_json = request_payload_json.get("Notification").unwrap();

let notification: String =
serde_json::from_value(notification_json.clone()).unwrap();
let notification: String = serde_json::from_value(notification_json.clone()).unwrap();

debug!(
"Received an invoke request from for entity id {entity_id} with payload'{payload}' from consumer URI {consumer_uri}"
Expand Down Expand Up @@ -149,7 +148,7 @@ mod provider_impl_tests {
#[derive(Debug, Serialize, Deserialize)]
struct ShowNotificationRequestPayload {
#[serde(rename = "Notification")]
notification: sdv::hmi::show_notification::request::TYPE,
notification: String,
#[serde(rename = "$metadata")]
metadata: Metadata,
}
Expand Down

0 comments on commit 65e057e

Please sign in to comment.