Documentation
¶
Index ¶
Constants ¶
const ( OffsetLength = 0 OffsetCRC32 = 4 OffsetMagicNumber = 8 OffsetVersion = 12 OffsetPayload = 20 HeaderSize = 20 )
Variables ¶
var ( ErrCRC32Mismatch = fmt.Errorf("CRC32 mismatch") ErrLengthMismatch = fmt.Errorf("file length mismatch") )
Functions ¶
This section is empty.
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder writes a binary to an output stream in the ota format.
func NewEncoder ¶
NewEncoder creates a new ota encoder.
type OtaMetadata ¶
type OtaMetadata struct { Length uint32 CRC32 uint32 MagicNumber uint32 BoardType string FQBN *string VID string PID string IsArduinoBoard bool Compressed bool PayloadSHA256 string // SHA256 of the payload (decompressed if compressed). This is the SHA256 as seen ny the board. OtaSHA256 string // SHA256 of the whole file (header + payload). }
func DecodeOtaFirmwareHeader ¶
func DecodeOtaFirmwareHeader(otafileptr OtaFileReader) (*OtaMetadata, error)
DecodeOtaFirmwareHeader decodes the OTA firmware header from a binary file. File is composed by an header and a payload (optionally lzss compressed). Method is also checking CRC32 of the file, verifying that file is not corrupted. OTA header layout: LENGTH (4 B) | CRC (4 B) | MAGIC NUMBER = VID + PID (4 B) | VERSION (8 B) | PAYLOAD (LENGTH - 12 B) See https://arduino.atlassian.net/wiki/spaces/RFC/pages/1616871540/OTA+header+structure
func DecodeOtaFirmwareHeaderFromFile ¶
func DecodeOtaFirmwareHeaderFromFile(binaryFilePath string) (*OtaMetadata, error)
DecodeOtaFirmwareHeader decodes the OTA firmware header from a binary file. File is composed by an header and a payload (optionally lzss compressed). Method is also checking CRC32 of the file, verifying that file is not corrupted. OTA header layout: LENGTH (4 B) | CRC (4 B) | MAGIC NUMBER = VID + PID (4 B) | VERSION (8 B) | PAYLOAD (LENGTH - 12 B) See https://arduino.atlassian.net/wiki/spaces/RFC/pages/1616871540/OTA+header+structure
func (OtaMetadata) Data ¶
func (r OtaMetadata) Data() interface{}
func (OtaMetadata) String ¶
func (r OtaMetadata) String() string
type Version ¶
type Version struct { HeaderVersion uint8 Compression bool Signature bool Spare uint8 PayloadTarget uint8 PayloadMayor uint8 PayloadMinor uint8 PayloadPatch uint8 PayloadBuildNum uint32 }
Version contains all the OTA header information Check out https://arduino.atlassian.net/wiki/spaces/RFC/pages/1616871540/OTA+header+structure for more information on the OTA header specs.