28 lines
567 B
C++
28 lines
567 B
C++
#ifndef __OTA_H
|
|
#define __OTA_H
|
|
|
|
#include "Can.h"
|
|
#include "config.h"
|
|
#include "gd32c10x.h"
|
|
|
|
class OTAHandler {
|
|
public:
|
|
bool ota_active;
|
|
uint32_t received_size;
|
|
uint32_t expected_size;
|
|
|
|
OTAHandler();
|
|
void init();
|
|
void process();
|
|
bool isActive() const { return ota_active; }
|
|
|
|
void handleOTAMessage(uint32_t id, uint8_t *data, uint8_t len);
|
|
void jumpToApplication();
|
|
|
|
private:
|
|
bool validateApplication();
|
|
void eraseApplicationArea();
|
|
void writeApplicationData(uint32_t offset, uint8_t *data, uint32_t size);
|
|
void sendACK(uint32_t packet_num);
|
|
};
|
|
#endif |