InfiniTime.git

commit 02116a2fd41518c779decdd8acc2e4c80e358425

Author: uli <cybuzuma@vnxs.de>

BLE CTS: fixed signedness of timezone

 src/components/ble/CurrentTimeService.h | 4 ++--
 src/components/datetime/DateTimeController.cpp | 2 +-
 src/components/datetime/DateTimeController.h | 12 ++++++------


diff --git a/src/components/ble/CurrentTimeService.h b/src/components/ble/CurrentTimeService.h
index 91544314f83cfd45ce4db6ed5ed690c277a964ef..9933923dde9e959204de63ae5993cc765a95c8ac 100644
--- a/src/components/ble/CurrentTimeService.h
+++ b/src/components/ble/CurrentTimeService.h
@@ -47,8 +47,8 @@         uint8_t reason;       // currently ignored, not that any host would set it anyway
       } CtsCurrentTimeData;
 
       typedef struct __attribute__((packed)) {
-        uint8_t timezone;
-        uint8_t dst;
+        int8_t timezone;
+        int8_t dst;
       } CtsLocalTimeData;
 
       DateTime& m_dateTimeController;




diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp
index 8aab49eca8017609dc0a973c0315b710b76ac0e2..e8c7cd5bd2ce209d356b9df0f476c18a6a2f5cba 100644
--- a/src/components/datetime/DateTimeController.cpp
+++ b/src/components/datetime/DateTimeController.cpp
@@ -51,7 +51,7 @@
   systemTask->PushMessage(System::Messages::OnNewTime);
 }
 
-void DateTime::SetTimeZone(uint8_t timezone, uint8_t dst) {
+void DateTime::SetTimeZone(int8_t timezone, int8_t dst) {
   tzOffset = timezone;
   dstOffset = dst;
 }




diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h
index 681bafbf37c283f3163a0a98ef308e027f24689c..24a3ed4087ceefc40c3d39542009764763d02498 100644
--- a/src/components/datetime/DateTimeController.h
+++ b/src/components/datetime/DateTimeController.h
@@ -48,7 +48,7 @@        * parameters are in quarters of an our. Following the BLE CTS specification,
        * timezone is expected to be constant over DST which will be reported in
        * dst field.
        */
-      void SetTimeZone(uint8_t timezone, uint8_t dst);
+      void SetTimeZone(int8_t timezone, int8_t dst);
 
       void UpdateTime(uint32_t systickCounter);
       uint16_t Year() const {
@@ -80,7 +80,7 @@        * Availability of this field depends on wether the companion app
        * supports the BLE CTS Local Time Characteristic. Expect it to be 0
        * if not.
        */
-      uint8_t UtcOffset() const {
+      int8_t UtcOffset() const {
         return tzOffset + dstOffset;
       }
 
@@ -92,7 +92,7 @@        * Availability of this field depends on wether the companion app
        * supports the BLE CTS Local Time Characteristic. Expect it to be 0
        * if not.
        */
-      uint8_t TzOffset() const {
+      int8_t TzOffset() const {
         return tzOffset;
       }
 
@@ -105,7 +105,7 @@        * Availability of this field depends on wether the companion app
        * supports the BLE CTS Local Time Characteristic. Expect it to be 0
        * if not.
        */
-      uint8_t DstOffset() const {
+      int8_t DstOffset() const {
         return dstOffset;
       }
 
@@ -136,8 +136,8 @@       Days dayOfWeek = Days::Unknown;
       uint8_t hour = 0;
       uint8_t minute = 0;
       uint8_t second = 0;
-      uint8_t tzOffset = 0;
-      uint8_t dstOffset = 0;
+      int8_t tzOffset = 0;
+      int8_t dstOffset = 0;
 
       uint32_t previousSystickCounter = 0;
       std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> currentDateTime;