diff options
| author | JF002 <JF002@users.noreply.github.com> | 2020-10-04 10:21:22 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-04 10:21:22 (GMT) |
| commit | 39954bbd3afb592a0c3109e3479594183e8d0778 (patch) | |
| tree | 58efd04aa38b8dc7989c51fe3c9cdb9a3fb46a54 /src/components/ble/BleController.h | |
| parent | 5adc97702c326d0252df6da75ce4ac244a4b3553 (diff) | |
| parent | 6c86d1d9d706706fcb6f214aba8259e61ed68755 (diff) | |
Merge pull request #68 from Avamander/patch-1
Rename folders to follow a consistent style
Diffstat (limited to 'src/components/ble/BleController.h')
| -rw-r--r-- | src/components/ble/BleController.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/components/ble/BleController.h b/src/components/ble/BleController.h new file mode 100644 index 0000000..3f52ea2 --- /dev/null +++ b/src/components/ble/BleController.h @@ -0,0 +1,45 @@ +#pragma once + +#include <FreeRTOS.h> +#include <queue.h> +#include <array> + +namespace Pinetime { + namespace Controllers { + class Ble { + public: + using BleAddress = std::array<uint8_t, 6>; + enum class FirmwareUpdateStates {Idle, Running, Validated, Error}; + enum class AddressTypes { Public, Random }; + + Ble() = default; + bool IsConnected() const {return isConnected;} + void Connect(); + void Disconnect(); + + void StartFirmwareUpdate(); + void StopFirmwareUpdate(); + void FirmwareUpdateTotalBytes(uint32_t totalBytes); + void FirmwareUpdateCurrentBytes(uint32_t currentBytes); + void State(FirmwareUpdateStates state) { firmwareUpdateState = state; } + + bool IsFirmwareUpdating() const { return isFirmwareUpdating; } + uint32_t FirmwareUpdateTotalBytes() const { return firmwareUpdateTotalBytes; } + uint32_t FirmwareUpdateCurrentBytes() const { return firmwareUpdateCurrentBytes; } + FirmwareUpdateStates State() const { return firmwareUpdateState; } + + void Address(BleAddress&& addr) { address = addr; } + const BleAddress& Address() const { return address; } + void AddressType(AddressTypes t) { addressType = t;} + private: + bool isConnected = false; + bool isFirmwareUpdating = false; + uint32_t firmwareUpdateTotalBytes = 0; + uint32_t firmwareUpdateCurrentBytes = 0; + FirmwareUpdateStates firmwareUpdateState = FirmwareUpdateStates::Idle; + BleAddress address; + AddressTypes addressType; + + }; + } +}
\ No newline at end of file |
