Skip to content

Commit

Permalink
backup
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulTrombin committed Jul 31, 2024
1 parent 382687f commit 15c9142
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/device/devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ impl DeviceActor {
let answer = device.handle(device_request).await;
let _ = request.respond_to.send(answer);
}
DeviceType::Ping1D(device) => {
trace!("Handling Common request: {device_request:?}");
let answer = device.handle(device_request).await;
let _ = request.respond_to.send(answer);
}
DeviceType::Ping360(device) => {
trace!("Handling Common request: {device_request:?}");
let answer = device.handle(device_request).await;
let _ = request.respond_to.send(answer);
}
_ => {
warn!(
"Unsupported request for device type: {:?}",
Expand Down Expand Up @@ -648,6 +658,58 @@ impl Requests<PingCommonRequest> for bluerobotics_ping::common::Device {
}
}

impl Requests<PingCommonRequest> for bluerobotics_ping::ping1d::Device {
type Reply = Result<PingAnswer, DeviceError>;

async fn handle(&self, msg: PingCommonRequest) -> Self::Reply {
match msg.clone() {
PingCommonRequest::ProtocolVersion => match self.protocol_version().await {
Ok(result) => Ok(PingAnswer::PingMessage(
bluerobotics_ping::Messages::Common(
bluerobotics_ping::common::Messages::ProtocolVersion(result),
),
)),
Err(e) => Err(DeviceError::PingError(e)),
},
PingCommonRequest::DeviceInformation => match self.device_information().await {
Ok(result) => Ok(PingAnswer::PingMessage(
bluerobotics_ping::Messages::Common(
bluerobotics_ping::common::Messages::DeviceInformation(result),
),
)),
Err(e) => Err(DeviceError::PingError(e)),
},
_ => Ok(PingAnswer::NotImplemented(PingRequest::Common(msg))),
}
}
}

impl Requests<PingCommonRequest> for bluerobotics_ping::ping360::Device {
type Reply = Result<PingAnswer, DeviceError>;

async fn handle(&self, msg: PingCommonRequest) -> Self::Reply {
match msg.clone() {
PingCommonRequest::ProtocolVersion => match self.protocol_version().await {
Ok(result) => Ok(PingAnswer::PingMessage(
bluerobotics_ping::Messages::Common(
bluerobotics_ping::common::Messages::ProtocolVersion(result),
),
)),
Err(e) => Err(DeviceError::PingError(e)),
},
PingCommonRequest::DeviceInformation => match self.device_information().await {
Ok(result) => Ok(PingAnswer::PingMessage(
bluerobotics_ping::Messages::Common(
bluerobotics_ping::common::Messages::DeviceInformation(result),
),
)),
Err(e) => Err(DeviceError::PingError(e)),
},
_ => Ok(PingAnswer::NotImplemented(PingRequest::Common(msg))),
}
}
}

impl Requests<PingRequest> for DeviceActor {
type Reply = PingAnswer;
async fn handle(&self, msg: PingRequest) -> Self::Reply {
Expand Down

0 comments on commit 15c9142

Please sign in to comment.