Serializer and deserializer of ESP-NOW packets.
More...
#include <espnow_ser_des.hpp>
|
| static uint8_t | checksumRaw (uint8_t *data, size_t dataLen, uint8_t existingChecksum=0) noexcept |
| | Checksums the given raw data (bytes) More...
|
| |
Serializer and deserializer of ESP-NOW packets.
Converts raw data to LocalMessage instances and back.
Definition at line 23 of file espnow_ser_des.hpp.
◆ SerDes()
| SPSP::LocalLayers::ESPNOW::SerDes::SerDes |
( |
const Config & |
conf | ) |
|
|
noexcept |
Construct a new serializer/deserializer.
- Parameters
-
◆ checksumRaw()
| static uint8_t SPSP::LocalLayers::ESPNOW::SerDes::checksumRaw |
( |
uint8_t * |
data, |
|
|
size_t |
dataLen, |
|
|
uint8_t |
existingChecksum = 0 |
|
) |
| |
|
staticprotectednoexcept |
Checksums the given raw data (bytes)
Optionally subtracts existing checksum.
- Parameters
-
| data | Data to encrypt/decrypt |
| dataLen | Length of data |
| existingChecksum | Existing checksum (to subtract) |
- Returns
- Correct checksum
◆ decryptAndValidatePacketPayload()
| bool SPSP::LocalLayers::ESPNOW::SerDes::decryptAndValidatePacketPayload |
( |
uint8_t * |
data, |
|
|
size_t |
dataLen |
|
) |
| const |
|
protectednoexcept |
Decrypts and validates packet's payload.
- Parameters
-
| data | Raw packet data |
| dataLen | Length of data |
- Returns
- true Payload is valid
-
false Payload is invalid
◆ deserialize()
| bool SPSP::LocalLayers::ESPNOW::SerDes::deserialize |
( |
const LocalAddrT & |
src, |
|
|
std::string & |
data, |
|
|
LocalMessageT & |
msg |
|
) |
| const |
|
noexcept |
Deserializes raw data to local message.
- Parameters
-
| src | Source address |
| data | Raw data input |
| msg | Message output |
- Returns
- true Deserialization successful
-
false Deserialization failed
◆ encryptRaw()
| void SPSP::LocalLayers::ESPNOW::SerDes::encryptRaw |
( |
uint8_t * |
data, |
|
|
size_t |
dataLen, |
|
|
const uint8_t * |
nonce |
|
) |
| const |
|
protectednoexcept |
Encryption provider for raw data (bytes)
Wraps ChaCha20 encryption. This function is used for both encryption and decryption. Data are encrypted/decrypted in-place.
- Parameters
-
| data | Data to encrypt/decrypt |
| dataLen | Length of data |
| nonce | Encryption nonce |
◆ getPacketLength()
| static size_t SPSP::LocalLayers::ESPNOW::SerDes::getPacketLength |
( |
const LocalMessageT & |
msg | ) |
|
|
staticnoexcept |
Calculates total packet length.
Useful for checking whether packet size is within limits.
- Parameters
-
- Returns
- Length
◆ serialize()
| void SPSP::LocalLayers::ESPNOW::SerDes::serialize |
( |
const LocalMessageT & |
msg, |
|
|
std::string & |
data |
|
) |
| const |
|
noexcept |
Serializes local message to raw data.
Total message length is not checked!
- Parameters
-
| msg | Message input |
| data | Raw data output |
◆ validatePacketHeader()
| bool SPSP::LocalLayers::ESPNOW::SerDes::validatePacketHeader |
( |
const Packet * |
p | ) |
const |
|
protectednoexcept |
Validates packet's header.
- Parameters
-
- Returns
- true Header is valid
-
false Header is invalid
The documentation for this class was generated from the following file: