-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove industry_group field and add test for NameBuilder
- Loading branch information
1 parent
fafaf17
commit d0257d5
Showing
2 changed files
with
33 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
use crate::{FrameBuilder, IdBuilder, PGN}; | ||
use crate::{Frame, FrameBuilder, IdBuilder, Name, PGN}; | ||
|
||
/// Create PGN request frame. | ||
pub fn request(da: u8, pgn: PGN) -> crate::Frame { | ||
pub fn request(da: u8, pgn: PGN) -> Frame { | ||
let byte_array = pgn.to_le_bytes(); | ||
|
||
FrameBuilder::new(IdBuilder::from_pgn(PGN::Request).da(da).build()) | ||
let id = IdBuilder::from_pgn(PGN::Request).da(da).build(); | ||
|
||
FrameBuilder::new(id) | ||
.copy_from_slice(&[byte_array[0], byte_array[1], byte_array[2]]) | ||
.build() | ||
} | ||
|
||
/// Create address claimed frame. | ||
pub fn address_claimed(sa: u8, name: Name) -> Frame { | ||
let id = IdBuilder::from_pgn(PGN::AddressClaimed) | ||
.sa(sa) | ||
.da(0xff) | ||
.build(); | ||
|
||
FrameBuilder::new(id) | ||
.copy_from_slice(&name.to_bytes()[..]) | ||
.build() | ||
} |