From 5291bcc7de582cfe3a83b94781ee80aa79765706 Mon Sep 17 00:00:00 2001 From: JF Date: Mon, 27 Apr 2020 20:16:03 +0200 Subject: Nimble OTA : work in progress --- src/Components/Ble/DfuService.h | 69 +++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 40 deletions(-) (limited to 'src/Components/Ble/DfuService.h') diff --git a/src/Components/Ble/DfuService.h b/src/Components/Ble/DfuService.h index 6249893d..221b6e89 100644 --- a/src/Components/Ble/DfuService.h +++ b/src/Components/Ble/DfuService.h @@ -6,62 +6,51 @@ namespace Pinetime { namespace Controllers { - class DeviceInformationService { + class DfuService { public: - DeviceInformationService(); + DfuService(); void Init(); - int OnDeviceInfoRequested(uint16_t conn_handle, uint16_t attr_handle, - struct ble_gatt_access_ctxt *ctxt); - + int OnServiceData(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context); private: - static constexpr uint16_t deviceInfoId {0x180a}; - static constexpr uint16_t manufacturerNameId {0x2a29}; - static constexpr uint16_t modelNumberId {0x2a24}; - static constexpr uint16_t serialNumberId {0x2a25}; - static constexpr uint16_t fwRevisionId {0x2a26}; - static constexpr uint16_t hwRevisionId {0x2a27}; - - static constexpr char* manufacturerName = "Codingfield"; - static constexpr char* modelNumber = "1"; - static constexpr char* serialNumber = "9.8.7.6.5.4"; - static constexpr char* fwRevision = "0.5.0"; - static constexpr char* hwRevision = "1.0.0"; + static constexpr uint16_t dfuServiceId {0x1530}; + static constexpr uint16_t packetCharacteristicId {0x1532}; + static constexpr uint16_t controlPointCharacteristicId {0x1531}; + static constexpr uint16_t revisionCharacteristicId {0x1534}; - static constexpr ble_uuid16_t deviceInfoUuid { - .u { .type = BLE_UUID_TYPE_16 }, - .value = deviceInfoId - }; + uint16_t revision {0x0008}; - static constexpr ble_uuid16_t manufacturerNameUuid { - .u { .type = BLE_UUID_TYPE_16 }, - .value = manufacturerNameId - }; + static constexpr uint16_t opcodeInit = 0x0002; - static constexpr ble_uuid16_t modelNumberUuid { - .u { .type = BLE_UUID_TYPE_16 }, - .value = modelNumberId + static constexpr ble_uuid128_t serviceUuid { + .u { .type = BLE_UUID_TYPE_128}, + .value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, + 0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00} }; - static constexpr ble_uuid16_t serialNumberUuid { - .u { .type = BLE_UUID_TYPE_16 }, - .value = serialNumberId + static constexpr ble_uuid128_t packetCharacteristicUuid { + .u { .type = BLE_UUID_TYPE_128}, + .value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, + 0xDE, 0xEF, 0x12, 0x12, 0x32, 0x15, 0x00, 0x00} }; - static constexpr ble_uuid16_t fwRevisionUuid { - .u { .type = BLE_UUID_TYPE_16 }, - .value = fwRevisionId + static constexpr ble_uuid128_t controlPointCharacteristicUuid { + .u { .type = BLE_UUID_TYPE_128}, + .value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, + 0xDE, 0xEF, 0x12, 0x12, 0x31, 0x15, 0x00, 0x00} }; - static constexpr ble_uuid16_t hwRevisionUuid { - .u {.type = BLE_UUID_TYPE_16}, - .value = hwRevisionId + static constexpr ble_uuid128_t revisionCharacteristicUuid { + .u { .type = BLE_UUID_TYPE_128}, + .value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, + 0xDE, 0xEF, 0x12, 0x12, 0x34, 0x15, 0x00, 0x00} }; - struct ble_gatt_chr_def characteristicDefinition[6]; + struct ble_gatt_chr_def characteristicDefinition[4]; struct ble_gatt_svc_def serviceDefinition[2]; - - + uint16_t packetCharacteristicHandle; + uint16_t controlPointCharacteristicHandle; + uint16_t revisionCharacteristicHandle; }; } } \ No newline at end of file -- cgit v1.2.3-70-g09d2