-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
117 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,17 @@ | ||
//! DevicePing packet and related functions/implementations | ||
/// DevicePing payload length | ||
pub const LEN: usize = 0; | ||
|
||
/// Represents a DevicePing packet | ||
#[derive(Clone, Debug, PartialEq)] | ||
#[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
#[allow(missing_docs)] | ||
pub struct DevicePing; | ||
|
||
pub const LEN: usize = 0; | ||
|
||
/// The raw decoder (parser) for the DevicePing packet. | ||
pub fn raw_decode(_data: &[u8; LEN]) -> DevicePing { | ||
DevicePing | ||
} | ||
|
||
/// The raw encoder (serializer) for the DevicePing packet. | ||
pub fn raw_encode(_device_ping: &DevicePing, _data: &mut [u8; LEN]) {} | ||
|
||
impl_extended_payload!(DevicePing, LEN); | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::DevicePing; | ||
use crate::{AnyPayload, ExtendedPayload, PacketAddress}; | ||
|
||
#[test] | ||
fn test_device_ping_write_and_parse() { | ||
let original = DevicePing; | ||
|
||
let raw = original | ||
.to_raw_packet(PacketAddress::Broadcast, PacketAddress::FlightController) | ||
.unwrap(); | ||
|
||
let data = raw.payload().unwrap(); | ||
assert!(raw.is_extended()); | ||
assert_eq!(data.len(), 0); | ||
|
||
let parsed = DevicePing::decode(data).unwrap(); | ||
|
||
assert_eq!(parsed, DevicePing); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.