add error codes to CTS; cosmetics

This commit is contained in:
uli 2022-05-29 16:35:35 +02:00
parent 688d5f04f5
commit 11fa523166
4 changed files with 34 additions and 36 deletions

View File

@ -44,8 +44,7 @@ int CurrentTimeService::OnCurrentTimeAccessed(uint16_t conn_handle, uint16_t att
if (res < 0) { if (res < 0) {
NRF_LOG_ERROR("Error reading BLE Data writing to CTS Current Time (too little data)") 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 BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
return 0;
} }
uint16_t year = ((uint16_t) result.year_MSO << 8) + result.year_LSO; 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) { if (res < 0) {
NRF_LOG_ERROR("Error reading BLE Data writing to CTS Local Time (too little data)") 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 BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
return 0;
} }
NRF_LOG_INFO("Received data: %d %d", result.timezone, result.dst); NRF_LOG_INFO("Received data: %d %d", result.timezone, result.dst);

View File

@ -5,7 +5,6 @@
#include <string> #include <string>
#include "components/settings/Settings.h" #include "components/settings/Settings.h"
namespace Pinetime { namespace Pinetime {
namespace System { namespace System {
class SystemTask; class SystemTask;
@ -41,14 +40,14 @@ namespace Pinetime {
uint32_t systickCounter); uint32_t systickCounter);
/* /*
* setter corresponding to the BLE Set Local Time characteristic. * setter corresponding to the BLE Set Local Time characteristic.
* *
* used to update difference between utc and local time (see UtcOffset()) * used to update difference between utc and local time (see UtcOffset())
* *
* parameters are in quarters of an our. Following the BLE CTS specification, * 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 * timezone is expected to be constant over DST which will be reported in
* dst field. * dst field.
*/ */
void SetTimeZone(uint8_t timezone, uint8_t dst); void SetTimeZone(uint8_t timezone, uint8_t dst);
void UpdateTime(uint32_t systickCounter); void UpdateTime(uint32_t systickCounter);

View File

@ -140,15 +140,14 @@ namespace Pinetime {
return settings.screenTimeOut; return settings.screenTimeOut;
}; };
void SetShakeThreshold(uint16_t thresh){ void SetShakeThreshold(uint16_t thresh) {
if(settings.shakeWakeThreshold != thresh){ if (settings.shakeWakeThreshold != thresh) {
settings.shakeWakeThreshold = thresh; settings.shakeWakeThreshold = thresh;
settingsChanged = true; settingsChanged = true;
} }
} }
int16_t GetShakeThreshold() const{ int16_t GetShakeThreshold() const {
return settings.shakeWakeThreshold; return settings.shakeWakeThreshold;
} }
@ -195,20 +194,20 @@ namespace Pinetime {
if (goal != settings.stepsGoal) { if (goal != settings.stepsGoal) {
settingsChanged = true; settingsChanged = true;
} }
settings.stepsGoal = goal; settings.stepsGoal = goal;
}; };
uint32_t GetStepsGoal() const { uint32_t GetStepsGoal() const {
return settings.stepsGoal; return settings.stepsGoal;
}; };
void SetBleRadioEnabled(bool enabled) { void SetBleRadioEnabled(bool enabled) {
bleRadioEnabled = enabled; bleRadioEnabled = enabled;
}; };
bool GetBleRadioEnabled() const { bool GetBleRadioEnabled() const {
return bleRadioEnabled; return bleRadioEnabled;
}; };
private: private:
Pinetime::Controllers::FS& fs; Pinetime::Controllers::FS& fs;

View File

@ -70,15 +70,17 @@ void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (object == cbOption[i]) { if (object == cbOption[i]) {
lv_checkbox_set_checked(cbOption[i], true); lv_checkbox_set_checked(cbOption[i], true);
if (i == 0) { switch (i) {
settingsController.SetClockType(Controllers::Settings::ClockType::H12); case 0:
}; settingsController.SetClockType(Controllers::Settings::ClockType::H12);
if (i == 1) { break;
settingsController.SetClockType(Controllers::Settings::ClockType::H24); case 1:
}; settingsController.SetClockType(Controllers::Settings::ClockType::H24);
if (i == 2) { break;
settingsController.SetClockType(Controllers::Settings::ClockType::UTC); case 2:
}; settingsController.SetClockType(Controllers::Settings::ClockType::UTC);
break;
}
} else { } else {
lv_checkbox_set_checked(cbOption[i], false); lv_checkbox_set_checked(cbOption[i], false);