diff options
author | JF <jf@codingfield.com> | 2020-09-02 21:31:31 +0200 |
---|---|---|
committer | JF <jf@codingfield.com> | 2020-09-02 21:31:31 +0200 |
commit | 1aa5b0a440de3015b5b4c88aa32d149a69bfa707 (patch) | |
tree | 28e6735e6bce40c59bd237e250113ac687494c2b /src | |
parent | 61e7ad9186831269f8ea9478c75dd6a57e474638 (diff) |
Fix firmware version reported by Device Information Service on BLE. It was previously hard-coded, it is now set by CMake accoridng to the project version.
Fix Manufacturer name, model number, sw revision according to https://wiki.pine64.org/index.php?title=Firmware_versioning_for_companion_apps.
Diffstat (limited to 'src')
-rw-r--r-- | src/Components/Ble/DeviceInformationService.cpp | 11 | ||||
-rw-r--r-- | src/Components/Ble/DeviceInformationService.h | 19 | ||||
-rw-r--r-- | src/Version.h.in | 8 |
3 files changed, 30 insertions, 8 deletions
diff --git a/src/Components/Ble/DeviceInformationService.cpp b/src/Components/Ble/DeviceInformationService.cpp index c1d55541..406db1cf 100644 --- a/src/Components/Ble/DeviceInformationService.cpp +++ b/src/Components/Ble/DeviceInformationService.cpp @@ -8,6 +8,8 @@ constexpr ble_uuid16_t DeviceInformationService::serialNumberUuid; constexpr ble_uuid16_t DeviceInformationService::fwRevisionUuid; constexpr ble_uuid16_t DeviceInformationService::deviceInfoUuid; constexpr ble_uuid16_t DeviceInformationService::hwRevisionUuid; +constexpr ble_uuid16_t DeviceInformationService::swRevisionUuid; + int DeviceInformationCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { auto deviceInformationService = static_cast<DeviceInformationService*>(arg); @@ -44,6 +46,9 @@ int DeviceInformationService::OnDeviceInfoRequested(uint16_t conn_handle, uint16 case hwRevisionId: str = hwRevision; break; + case swRevisionId: + str = swRevision; + break; default: return BLE_ATT_ERR_UNLIKELY; } @@ -85,6 +90,12 @@ DeviceInformationService::DeviceInformationService() : .flags = BLE_GATT_CHR_F_READ, }, { + .uuid = (ble_uuid_t *) &swRevisionUuid, + .access_cb = DeviceInformationCallback, + .arg = this, + .flags = BLE_GATT_CHR_F_READ, + }, + { 0 } }, diff --git a/src/Components/Ble/DeviceInformationService.h b/src/Components/Ble/DeviceInformationService.h index 7d7cea96..25ab8402 100644 --- a/src/Components/Ble/DeviceInformationService.h +++ b/src/Components/Ble/DeviceInformationService.h @@ -3,6 +3,7 @@ #include <array> #include <host/ble_gap.h> +#include <Version.h> namespace Pinetime { namespace Controllers { @@ -21,12 +22,15 @@ namespace Pinetime { static constexpr uint16_t serialNumberId {0x2a25}; static constexpr uint16_t fwRevisionId {0x2a26}; static constexpr uint16_t hwRevisionId {0x2a27}; + static constexpr uint16_t swRevisionId {0x2a28}; - static constexpr const char* manufacturerName = "Codingfield"; - static constexpr const char* modelNumber = "1"; - static constexpr const char* serialNumber = "9.8.7.6.5.4"; - static constexpr const char* fwRevision = "0.7.0"; + static constexpr const char* manufacturerName = "PINE64"; + static constexpr const char* modelNumber = "PineTime"; static constexpr const char* hwRevision = "1.0.0"; + static constexpr const char* serialNumber = "0"; + static constexpr const char* fwRevision = Version::VersionString(); + static constexpr const char* swRevision = "InfiniTime"; + static constexpr ble_uuid16_t deviceInfoUuid { .u { .type = BLE_UUID_TYPE_16 }, @@ -58,7 +62,12 @@ namespace Pinetime { .value = hwRevisionId }; - struct ble_gatt_chr_def characteristicDefinition[6]; + static constexpr ble_uuid16_t swRevisionUuid { + .u {.type = BLE_UUID_TYPE_16}, + .value = swRevisionId + }; + + struct ble_gatt_chr_def characteristicDefinition[7]; struct ble_gatt_svc_def serviceDefinition[2]; diff --git a/src/Version.h.in b/src/Version.h.in index c68a03ce..dce83c82 100644 --- a/src/Version.h.in +++ b/src/Version.h.in @@ -5,12 +5,14 @@ namespace Pinetime { class Version { public: - static uint32_t Major() {return major;} - static uint32_t Minor() {return minor;} - static uint32_t Patch() {return patch;} + static constexpr uint32_t Major() {return major;} + static constexpr uint32_t Minor() {return minor;} + static constexpr uint32_t Patch() {return patch;} + static constexpr char* VersionString() {return versionString;} private: static constexpr uint32_t major = @PROJECT_VERSION_MAJOR@; static constexpr uint32_t minor = @PROJECT_VERSION_MINOR@; static constexpr uint32_t patch = @PROJECT_VERSION_PATCH@; + static constexpr char* versionString = "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@"; }; }
\ No newline at end of file |