2019-12-27 16:05:49 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-04-23 18:34:38 +00:00
|
|
|
#include <FreeRTOS.h>
|
2020-03-25 20:23:40 +00:00
|
|
|
#include <queue.h>
|
|
|
|
|
2019-12-27 16:05:49 +00:00
|
|
|
namespace Pinetime {
|
|
|
|
namespace Controllers {
|
|
|
|
class Ble {
|
|
|
|
public:
|
2020-06-01 07:22:54 +00:00
|
|
|
enum class FirmwareUpdateStates {Idle, Running, Validated, Error};
|
2020-03-25 20:23:40 +00:00
|
|
|
|
2020-03-28 18:05:28 +00:00
|
|
|
Ble() = default;
|
2019-12-27 16:05:49 +00:00
|
|
|
bool IsConnected() const {return isConnected;}
|
|
|
|
void Connect();
|
|
|
|
void Disconnect();
|
2020-05-02 12:16:57 +00:00
|
|
|
|
|
|
|
void StartFirmwareUpdate();
|
|
|
|
void StopFirmwareUpdate();
|
|
|
|
void FirmwareUpdateTotalBytes(uint32_t totalBytes);
|
|
|
|
void FirmwareUpdateCurrentBytes(uint32_t currentBytes);
|
2020-06-01 07:22:54 +00:00
|
|
|
void State(FirmwareUpdateStates state) { firmwareUpdateState = state; }
|
2020-05-02 12:16:57 +00:00
|
|
|
|
|
|
|
bool IsFirmwareUpdating() const { return isFirmwareUpdating; }
|
|
|
|
uint32_t FirmwareUpdateTotalBytes() const { return firmwareUpdateTotalBytes; }
|
|
|
|
uint32_t FirmwareUpdateCurrentBytes() const { return firmwareUpdateCurrentBytes; }
|
2020-06-01 07:22:54 +00:00
|
|
|
FirmwareUpdateStates State() const { return firmwareUpdateState; }
|
2019-12-27 16:05:49 +00:00
|
|
|
private:
|
|
|
|
bool isConnected = false;
|
2020-05-02 12:16:57 +00:00
|
|
|
bool isFirmwareUpdating = false;
|
|
|
|
uint32_t firmwareUpdateTotalBytes = 0;
|
|
|
|
uint32_t firmwareUpdateCurrentBytes = 0;
|
2020-06-01 07:22:54 +00:00
|
|
|
FirmwareUpdateStates firmwareUpdateState = FirmwareUpdateStates::Idle;
|
2020-03-25 20:23:40 +00:00
|
|
|
|
2019-12-27 16:05:49 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|