X-Git-Url: https://code.octet-stream.net/m17rt/blobdiff_plain/9058451e46e4d36264282abe381aa9b6fd2c773f..d5f46a2d5d294c5a4287780dd609475fa73df9a8:/m17core/src/protocol.rs?ds=sidebyside diff --git a/m17core/src/protocol.rs b/m17core/src/protocol.rs index abc9e1b..e4b3b15 100755 --- a/m17core/src/protocol.rs +++ b/m17core/src/protocol.rs @@ -4,6 +4,8 @@ pub(crate) const LSF_SYNC: [i8; 8] = [1, 1, 1, 1, -1, -1, 1, -1]; pub(crate) const BERT_SYNC: [i8; 8] = [-1, 1, -1, -1, 1, 1, 1, 1]; pub(crate) const STREAM_SYNC: [i8; 8] = [-1, -1, -1, -1, 1, 1, -1, 1]; pub(crate) const PACKET_SYNC: [i8; 8] = [1, -1, 1, 1, -1, -1, -1, -1]; +pub(crate) const PREAMBLE: [i8; 8] = [1, -1, 1, -1, 1, -1, 1, -1]; +pub(crate) const END_OF_TRANSMISSION: [i8; 8] = [1, 1, 1, 1, 1, 1, -1, 1]; #[derive(Debug, Clone, PartialEq, Eq, Copy)] pub enum Mode { @@ -93,6 +95,26 @@ impl PacketType { pub struct LsfFrame(pub [u8; 30]); impl LsfFrame { + pub fn new_voice(source: &Address, destination: &Address) -> Self { + let mut out = Self([0u8; 30]); + out.set_source(source); + out.set_destination(destination); + out.set_mode(Mode::Stream); + out.set_data_type(DataType::Voice); + out.set_encryption_type(EncryptionType::None); + out + } + + pub fn new_packet(source: &Address, destination: &Address) -> Self { + let mut out = Self([0u8; 30]); + out.set_source(source); + out.set_destination(destination); + out.set_mode(Mode::Packet); + out.set_data_type(DataType::Data); + out.set_encryption_type(EncryptionType::None); + out + } + /// Calculate crc of entire frame. If zero, it is a valid frame. pub fn check_crc(&self) -> u16 { crate::crc::m17_crc(&self.0)