Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit add a helper function for checksumming data which is needed in hvac frames. History of this function is complicated and described below... :) When writing a rust function I was basing on two current implementations: Python: https://github.com/liaan/broadlink_ac_mqtt/blob/eb26e2b2eafabc58d55680abd911afeae523f592/broadlink_ac_mqtt/classes/broadlink/ac_db.py#L876 and a Swift one: https://github.com/makleso6/ACFreedom/blob/25f36bfeac0ebaca7db2def8507e37f37cfbac7c/Sources/ACFreedom/DeviceController.swift#L241 Thanks to stackoverflow (https://stackoverflow.com/a/57172592) I ended up using chunks_exact() and got a working implementation. But when searching for example code using this, I came across Microsoft implementation: https://github.com/microsoft/demikernel/blob/9667ad81546421dbf709330e9e21ed8e187cb816/src/rust/inetstack/protocols/mod.rs#L40 I liked this very much so I only adjusted this function to our needs. After all this I realized that this function is just the UDP checksum function. So we may consider using eg. following crates for this: https://crates.io/crates/pnet_packet https://crates.io/crates/etherparse Anyway - it's a thing to consider if adding the dependency for using a single checksum function is worth it... For now I am just commiting this implementation. The commit also fixes lack of new line at EOF.
- Loading branch information