18#include "fota_error.h"
45#define FOTA_PACKET_SOF 0xAAU
46#define FOTA_PACKET_EOF 0xBBU
47#define FOTA_PACKET_PAYLOAD_SIZE 128U
48#define FOTA_PACKET_HEADER_SIZE (1U + 1U + 4U + 1U + 2U)
49#define FOTA_PACKET_SERIALIZED_SIZE (FOTA_PACKET_HEADER_SIZE + FOTA_PACKET_PAYLOAD_SIZE + 4U + 1U)
50#define FOTA_PACKET_MINIMUM_SIZE FOTA_PACKET_SERIALIZED_SIZE
75 uint8_t payload[FOTA_PACKET_PAYLOAD_SIZE];
FotaError fota_packet_serialize(FotaPacket *packet, uint8_t *buffer, uint32_t buf_size, uint32_t *bytes_written)
Serialize FOTA packet into buffer.
Definition: fota_packet.c:56
FotaPacketType
FOTA Packet Type.
Definition: fota_packet.h:55
FotaError fota_packet_init(FotaPacket *packet, FotaPacketType type, uint8_t sequence, uint16_t length)
Initialize a FOTA packet.
Definition: fota_packet.c:20
FotaError fota_packet_set_crc(FotaPacket *packet)
Compute and set CRC32 of payload.
Definition: fota_packet.c:37
FotaError fota_packet_deserialize(FotaPacket *packet, uint8_t *buffer, uint32_t buf_size)
Deserialize buffer into FOTA packet.
Definition: fota_packet.c:99
FotaError
FOTA Error code definitions.
Definition: fota_error.h:27
@ FOTA_PACKET_TYPE_ERROR
Definition: fota_packet.h:60
@ FOTA_PACKET_TYPE_ACK
Definition: fota_packet.h:58
@ FOTA_PACKET_TYPE_HEADER
Definition: fota_packet.h:57
@ FOTA_PACKET_TYPE_DATA
Definition: fota_packet.h:56
@ FOTA_PACKET_TYPE_NACK
Definition: fota_packet.h:59
FOTA Packet structure.
Definition: fota_packet.h:69
uint32_t datagram_id
Definition: fota_packet.h:72
uint8_t eof
Definition: fota_packet.h:77
uint16_t payload_length
Definition: fota_packet.h:74
uint32_t crc32
Definition: fota_packet.h:76
uint8_t sequence_num
Definition: fota_packet.h:73
FotaPacketType packet_type
Definition: fota_packet.h:71
uint8_t sof
Definition: fota_packet.h:70