2019-12-27 16:05:49 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-06-08 19:51:34 +00:00
|
|
|
#include <array>
|
2020-11-15 14:05:51 +00:00
|
|
|
#include <cstdint>
|
2020-03-25 20:23:40 +00:00
|
|
|
|
2019-12-27 16:05:49 +00:00
|
|
|
namespace Pinetime {
|
|
|
|
namespace Controllers {
|
|
|
|
class Ble {
|
|
|
|
public:
|
2020-06-08 19:51:34 +00:00
|
|
|
using BleAddress = std::array<uint8_t, 6>;
|
2020-06-01 07:22:54 +00:00
|
|
|
enum class FirmwareUpdateStates {Idle, Running, Validated, Error};
|
2020-06-08 19:51:34 +00:00
|
|
|
enum class AddressTypes { Public, Random };
|
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; }
|
2020-06-08 19:51:34 +00:00
|
|
|
|
|
|
|
void Address(BleAddress&& addr) { address = addr; }
|
|
|
|
const BleAddress& Address() const { return address; }
|
|
|
|
void AddressType(AddressTypes t) { addressType = t;}
|
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-06-08 19:51:34 +00:00
|
|
|
BleAddress address;
|
|
|
|
AddressTypes addressType;
|
2020-03-25 20:23:40 +00:00
|
|
|
|
2019-12-27 16:05:49 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|