From 11fa52316680f589721a20f636375b9ee66dc8b8 Mon Sep 17 00:00:00 2001 From: uli Date: Sun, 29 May 2022 16:35:35 +0200 Subject: [PATCH] add error codes to CTS; cosmetics --- src/components/ble/CurrentTimeService.cpp | 6 ++--- src/components/datetime/DateTimeController.h | 17 ++++++------ src/components/settings/Settings.h | 27 +++++++++---------- .../screens/settings/SettingTimeFormat.cpp | 20 +++++++------- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/components/ble/CurrentTimeService.cpp b/src/components/ble/CurrentTimeService.cpp index c8aae360..b3a14ae5 100644 --- a/src/components/ble/CurrentTimeService.cpp +++ b/src/components/ble/CurrentTimeService.cpp @@ -44,8 +44,7 @@ int CurrentTimeService::OnCurrentTimeAccessed(uint16_t conn_handle, uint16_t att if (res < 0) { NRF_LOG_ERROR("Error reading BLE Data writing to CTS Current Time (too little data)") - // return OK/0 anyway, we did consume the request, we just ignored the invalid value´ - return 0; + return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; } uint16_t year = ((uint16_t) result.year_MSO << 8) + result.year_LSO; @@ -82,8 +81,7 @@ int CurrentTimeService::OnLocalTimeAccessed(uint16_t conn_handle, uint16_t attr_ if (res < 0) { NRF_LOG_ERROR("Error reading BLE Data writing to CTS Local Time (too little data)") - // return OK/0 anyway, we did consume the request, we just ignored the invalid value´ - return 0; + return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; } NRF_LOG_INFO("Received data: %d %d", result.timezone, result.dst); diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h index 7c166d9d..62927310 100644 --- a/src/components/datetime/DateTimeController.h +++ b/src/components/datetime/DateTimeController.h @@ -5,7 +5,6 @@ #include #include "components/settings/Settings.h" - namespace Pinetime { namespace System { class SystemTask; @@ -41,14 +40,14 @@ namespace Pinetime { uint32_t systickCounter); /* - * setter corresponding to the BLE Set Local Time characteristic. - * - * used to update difference between utc and local time (see UtcOffset()) - * - * 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. - */ + * setter corresponding to the BLE Set Local Time characteristic. + * + * used to update difference between utc and local time (see UtcOffset()) + * + * 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 UpdateTime(uint32_t systickCounter); diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index c2e9106f..55ab95ed 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -140,15 +140,14 @@ namespace Pinetime { return settings.screenTimeOut; }; - void SetShakeThreshold(uint16_t thresh){ - if(settings.shakeWakeThreshold != thresh){ - settings.shakeWakeThreshold = thresh; - settingsChanged = true; + void SetShakeThreshold(uint16_t thresh) { + if (settings.shakeWakeThreshold != thresh) { + settings.shakeWakeThreshold = thresh; + settingsChanged = true; } - } - int16_t GetShakeThreshold() const{ + int16_t GetShakeThreshold() const { return settings.shakeWakeThreshold; } @@ -195,20 +194,20 @@ namespace Pinetime { if (goal != settings.stepsGoal) { settingsChanged = true; } - settings.stepsGoal = goal; + settings.stepsGoal = goal; }; - + uint32_t GetStepsGoal() const { return settings.stepsGoal; }; - void SetBleRadioEnabled(bool enabled) { - bleRadioEnabled = enabled; - }; + void SetBleRadioEnabled(bool enabled) { + bleRadioEnabled = enabled; + }; - bool GetBleRadioEnabled() const { - return bleRadioEnabled; - }; + bool GetBleRadioEnabled() const { + return bleRadioEnabled; + }; private: Pinetime::Controllers::FS& fs; diff --git a/src/displayapp/screens/settings/SettingTimeFormat.cpp b/src/displayapp/screens/settings/SettingTimeFormat.cpp index f9f5c01f..f7da3f46 100644 --- a/src/displayapp/screens/settings/SettingTimeFormat.cpp +++ b/src/displayapp/screens/settings/SettingTimeFormat.cpp @@ -70,15 +70,17 @@ void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) { if (object == cbOption[i]) { lv_checkbox_set_checked(cbOption[i], true); - if (i == 0) { - settingsController.SetClockType(Controllers::Settings::ClockType::H12); - }; - if (i == 1) { - settingsController.SetClockType(Controllers::Settings::ClockType::H24); - }; - if (i == 2) { - settingsController.SetClockType(Controllers::Settings::ClockType::UTC); - }; + switch (i) { + case 0: + settingsController.SetClockType(Controllers::Settings::ClockType::H12); + break; + case 1: + settingsController.SetClockType(Controllers::Settings::ClockType::H24); + break; + case 2: + settingsController.SetClockType(Controllers::Settings::ClockType::UTC); + break; + } } else { lv_checkbox_set_checked(cbOption[i], false);