diff options
author | JF <jf@codingfield.com> | 2020-06-01 17:35:28 +0200 |
---|---|---|
committer | JF <jf@codingfield.com> | 2020-06-01 17:35:28 +0200 |
commit | f6aa41c214eef418b55cf0f063c5a296b1e57b63 (patch) | |
tree | 2bf3bb2c86216cd69b5874bcf54d8b8de6d4f415 /src/Components/Ble/DfuService.h | |
parent | 07f74cee63d77882191c8ce53c598f91e6159ba8 (diff) |
Encapsulate notification send (sync/async) into DfuService::NotificationManager;
Diffstat (limited to 'src/Components/Ble/DfuService.h')
-rw-r--r-- | src/Components/Ble/DfuService.h | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/Components/Ble/DfuService.h b/src/Components/Ble/DfuService.h index 73846c86..b0eccdf5 100644 --- a/src/Components/Ble/DfuService.h +++ b/src/Components/Ble/DfuService.h @@ -19,17 +19,28 @@ namespace Pinetime { public: DfuService(Pinetime::System::SystemTask &systemTask, Pinetime::Controllers::Ble &bleController, Pinetime::Drivers::SpiNorFlash &spiNorFlash); - void Init(); - bool Validate(); - int OnServiceData(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context); - void OnNotificationTimer(); void OnTimeout(); - void Reset(); + class NotificationManager { + public: + NotificationManager(); + bool AsyncSend(uint16_t connection, uint16_t charactHandle, uint8_t *data, size_t size); + void Send(uint16_t connection, uint16_t characteristicHandle, const uint8_t *data, const size_t s); + private: + TimerHandle_t timer; + uint16_t connectionHandle = 0; + uint16_t characteristicHandle = 0; + size_t size = 0; + uint8_t buffer[10]; + public: + void OnNotificationTimer(); + void Reset(); + }; + private: Pinetime::System::SystemTask &systemTask; Pinetime::Controllers::Ble &bleController; @@ -117,24 +128,13 @@ namespace Pinetime { uint16_t expectedCrc = 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); - uint8_t tempBuffer[200]; - uint16_t ComputeCrc(uint8_t const *p_data, uint32_t size, uint16_t const *p_crc); - void WriteMagicNumber(); - TimerHandle_t notificationTimer; TimerHandle_t timeoutTimer; - - uint16_t notificatonConnectionHandle = 0; - size_t notificationSize = 0; - uint8_t notificationBuffer[10]; + NotificationManager notificationManager; }; } }
\ No newline at end of file |