diff options
Diffstat (limited to 'src/Components/Ble/DfuService.h')
-rw-r--r-- | src/Components/Ble/DfuService.h | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/Components/Ble/DfuService.h b/src/Components/Ble/DfuService.h index bb643632..1b13c00d 100644 --- a/src/Components/Ble/DfuService.h +++ b/src/Components/Ble/DfuService.h @@ -20,8 +20,6 @@ namespace Pinetime { uint16_t revision {0x0008}; - static constexpr uint16_t opcodeInit = 0x0002; - static constexpr ble_uuid128_t serviceUuid { .u { .type = BLE_UUID_TYPE_128}, .value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, @@ -51,12 +49,39 @@ namespace Pinetime { uint16_t packetCharacteristicHandle; uint16_t controlPointCharacteristicHandle; uint16_t revisionCharacteristicHandle; - uint8_t opcode = 0; - uint8_t param = 0; + + enum class States : uint8_t {Idle, Init, Start, Data, Validate, Validated}; + States state = States::Idle; + + enum class ImageTypes : uint8_t { + NoImage = 0x00, + SoftDevice = 0x01, + Bootloader = 0x02, + SoftDeviceAndBootloader = 0x03, + Application = 0x04 + }; + + enum class Opcodes : uint8_t { + StartDFU = 0x01, + InitDFUParameters = 0x02, + ReceiveFirmwareImage = 0x03, + ValidateFirmware = 0x04, + ActivateImageAndReset = 0x05, + PacketReceiptNotificationRequest = 0x08, + Response = 0x10, + PacketReceiptNotification = 0x11 + }; + + enum class ErrorCodes { NoError = 0x01}; + uint8_t nbPacketsToNotify = 0; uint32_t nbPacketReceived = 0; - bool dataMode = false; uint32_t bytesReceived = 0; + + int SendDfuRevision(os_mbuf *om) const; + void SendNotification(uint16_t connectionHandle, const uint8_t *data, const size_t size); + int WritePacketHandler(uint16_t connectionHandle, os_mbuf *om); + int ControlPointHandler(uint16_t connectionHandle, os_mbuf *om); }; } }
\ No newline at end of file |