ProtocolV32

Struct ProtocolV32 

Source
pub struct ProtocolV32;

Trait Implementations§

Source§

impl TuyaProtocol for ProtocolV32

Source§

fn version(&self) -> Version

Source§

fn get_effective_command(&self, command: CommandType) -> u32

Source§

fn generate_payload( &self, device_id: &str, command: CommandType, data: Option<Value>, cid: Option<&str>, t: u64, ) -> Result<(u32, Value)>

Source§

fn pack_payload( &self, payload: &[u8], cmd: u32, cipher: &TuyaCipher, ) -> Result<Vec<u8>>

Source§

fn decrypt_payload( &self, payload: Vec<u8>, cipher: &TuyaCipher, ) -> Result<Vec<u8>>

Source§

fn has_version_header(&self, payload: &[u8]) -> bool

Source§

fn requires_session_key(&self) -> bool

Returns whether this protocol version requires session key negotiation.
Source§

fn encrypt_session_key( &self, session_key: &[u8], cipher: &TuyaCipher, _nonce: &[u8], ) -> Result<Vec<u8>>

Encrypts the session key according to protocol version requirements.
Source§

fn get_prefix(&self) -> u32

Returns the message prefix (e.g., 0x55AA or 0x6699) for this protocol version.
Source§

fn get_hmac_key<'a>(&self, _cipher_key: &'a [u8]) -> Option<&'a [u8]>

Returns the HMAC key to use for message packing/unpacking, if applicable.
Source§

fn is_empty_payload_allowed(&self, _cmd: u32) -> bool

Returns whether an empty payload is allowed for the given command.
Source§

fn should_check_dev22_fallback(&self) -> bool

Returns whether the protocol should attempt dev22 fallback on error.
Source§

fn prepare_session_key_negotiation(&self) -> Vec<u8>

Step 1: Prepare local nonce for session key negotiation.
Source§

fn verify_session_key_response( &self, local_nonce: &[u8], remote_payload: &[u8], local_key: &[u8], ) -> Result<Vec<u8>>

Step 2: Verify the HMAC from device response during negotiation.
Source§

fn finalize_session_key( &self, local_nonce: &[u8], remote_nonce: &[u8], local_key: &[u8], ) -> Result<(Vec<u8>, Vec<u8>)>

Step 3: Calculate final session key and its HMAC for the finish message.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V