diff options
Diffstat (limited to 'src/components')
29 files changed, 80 insertions, 101 deletions
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index ead3e43b..4d860490 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -61,14 +61,8 @@ void Battery::SaadcInit() { } void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) { - static const Utility::LinearApproximation<uint16_t, uint8_t, 6> aprox {{{ - {3500, 0}, // Minimum voltage before shutdown (depends on the battery) - {3600, 10}, // Keen point that corresponds to 10% - {3700, 25}, - {3750, 50}, - {3900, 75}, - {4180, 100} // Maximum voltage during charging is 4.21V - }}}; + static const Utility::LinearApproximation<uint16_t, uint8_t, 6> approx { + {{{3500, 0}, {3616, 3}, {3723, 22}, {3776, 48}, {3979, 79}, {4180, 100}}}}; if (p_event->type == NRFX_SAADC_EVT_DONE) { @@ -83,7 +77,8 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) { uint8_t newPercent = 100; if (!isFull) { - newPercent = std::min(aprox.GetValue(voltage), isCharging ? uint8_t {99} : uint8_t {100}); + // max. voltage while charging is higher than when discharging + newPercent = std::min(approx.GetValue(voltage), isCharging ? uint8_t {99} : uint8_t {100}); } if (isPowerPresent) { diff --git a/src/components/ble/AlertNotificationClient.cpp b/src/components/ble/AlertNotificationClient.cpp index 095fdef6..e3bc9242 100644 --- a/src/components/ble/AlertNotificationClient.cpp +++ b/src/components/ble/AlertNotificationClient.cpp @@ -35,9 +35,9 @@ namespace { return client->OnDescriptorDiscoveryEventCallback(conn_handle, error, chr_val_handle, dsc); } - int NewAlertSubcribeCallback(uint16_t conn_handle, const struct ble_gatt_error* error, struct ble_gatt_attr* attr, void* arg) { + int NewAlertSubcribeCallback(uint16_t conn_handle, const struct ble_gatt_error* error, struct ble_gatt_attr* /*attr*/, void* arg) { auto client = static_cast<AlertNotificationClient*>(arg); - return client->OnNewAlertSubcribe(conn_handle, error, attr); + return client->OnNewAlertSubcribe(conn_handle, error); } } @@ -107,7 +107,7 @@ int AlertNotificationClient::OnCharacteristicsDiscoveryEvent(uint16_t connection return 0; } -int AlertNotificationClient::OnNewAlertSubcribe(uint16_t connectionHandle, const ble_gatt_error* error, ble_gatt_attr* attribute) { +int AlertNotificationClient::OnNewAlertSubcribe(uint16_t connectionHandle, const ble_gatt_error* error) { if (error->status == 0) { NRF_LOG_INFO("ANS New alert subscribe OK"); } else { diff --git a/src/components/ble/AlertNotificationClient.h b/src/components/ble/AlertNotificationClient.h index 2d6a3873..b038f0d8 100644 --- a/src/components/ble/AlertNotificationClient.h +++ b/src/components/ble/AlertNotificationClient.h @@ -25,7 +25,7 @@ namespace Pinetime { bool OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error* error, const ble_gatt_svc* service); int OnCharacteristicsDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error* error, const ble_gatt_chr* characteristic); - int OnNewAlertSubcribe(uint16_t connectionHandle, const ble_gatt_error* error, ble_gatt_attr* attribute); + int OnNewAlertSubcribe(uint16_t connectionHandle, const ble_gatt_error* error); int OnDescriptorDiscoveryEventCallback(uint16_t connectionHandle, const ble_gatt_error* error, uint16_t characteristicValueHandle, diff --git a/src/components/ble/AlertNotificationService.cpp b/src/components/ble/AlertNotificationService.cpp index 04819122..d9f28698 100644 --- a/src/components/ble/AlertNotificationService.cpp +++ b/src/components/ble/AlertNotificationService.cpp @@ -11,9 +11,9 @@ constexpr ble_uuid16_t AlertNotificationService::ansUuid; constexpr ble_uuid16_t AlertNotificationService::ansCharUuid; constexpr ble_uuid128_t AlertNotificationService::notificationEventUuid; -int AlertNotificationCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { +int AlertNotificationCallback(uint16_t /*conn_handle*/, uint16_t /*attr_handle*/, struct ble_gatt_access_ctxt* ctxt, void* arg) { auto anService = static_cast<AlertNotificationService*>(arg); - return anService->OnAlert(conn_handle, attr_handle, ctxt); + return anService->OnAlert(ctxt); } void AlertNotificationService::Init() { @@ -44,7 +44,7 @@ AlertNotificationService::AlertNotificationService(System::SystemTask& systemTas notificationManager {notificationManager} { } -int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) { +int AlertNotificationService::OnAlert(struct ble_gatt_access_ctxt* ctxt) { if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) { constexpr size_t stringTerminatorSize = 1; // end of string '\0' constexpr size_t headerSize = 3; diff --git a/src/components/ble/AlertNotificationService.h b/src/components/ble/AlertNotificationService.h index 7f5273ac..4b3c6385 100644 --- a/src/components/ble/AlertNotificationService.h +++ b/src/components/ble/AlertNotificationService.h @@ -25,7 +25,7 @@ namespace Pinetime { AlertNotificationService(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::NotificationManager& notificationManager); void Init(); - int OnAlert(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt); + int OnAlert(struct ble_gatt_access_ctxt* ctxt); void AcceptIncomingCall(); void RejectIncomingCall(); diff --git a/src/components/ble/BatteryInformationService.cpp b/src/components/ble/BatteryInformationService.cpp index 14589cb9..db7c8566 100644 --- a/src/components/ble/BatteryInformationService.cpp +++ b/src/components/ble/BatteryInformationService.cpp @@ -7,9 +7,9 @@ using namespace Pinetime::Controllers; constexpr ble_uuid16_t BatteryInformationService::batteryInformationServiceUuid; constexpr ble_uuid16_t BatteryInformationService::batteryLevelUuid; -int BatteryInformationServiceCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { +int BatteryInformationServiceCallback(uint16_t /*conn_handle*/, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { auto* batteryInformationService = static_cast<BatteryInformationService*>(arg); - return batteryInformationService->OnBatteryServiceRequested(conn_handle, attr_handle, ctxt); + return batteryInformationService->OnBatteryServiceRequested(attr_handle, ctxt); } BatteryInformationService::BatteryInformationService(Controllers::Battery& batteryController) @@ -38,9 +38,7 @@ void BatteryInformationService::Init() { ASSERT(res == 0); } -int BatteryInformationService::OnBatteryServiceRequested(uint16_t connectionHandle, - uint16_t attributeHandle, - ble_gatt_access_ctxt* context) { +int BatteryInformationService::OnBatteryServiceRequested(uint16_t attributeHandle, ble_gatt_access_ctxt* context) { if (attributeHandle == batteryLevelHandle) { NRF_LOG_INFO("BATTERY : handle = %d", batteryLevelHandle); uint8_t batteryValue = batteryController.PercentRemaining(); diff --git a/src/components/ble/BatteryInformationService.h b/src/components/ble/BatteryInformationService.h index cc4d2604..7f0a89ad 100644 --- a/src/components/ble/BatteryInformationService.h +++ b/src/components/ble/BatteryInformationService.h @@ -18,7 +18,7 @@ namespace Pinetime { BatteryInformationService(Controllers::Battery& batteryController); void Init(); - int OnBatteryServiceRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context); + int OnBatteryServiceRequested(uint16_t attributeHandle, ble_gatt_access_ctxt* context); void NotifyBatteryLevel(uint16_t connectionHandle, uint8_t level); private: diff --git a/src/components/ble/CurrentTimeClient.cpp b/src/components/ble/CurrentTimeClient.cpp index 96134526..e535ae83 100644 --- a/src/components/ble/CurrentTimeClient.cpp +++ b/src/components/ble/CurrentTimeClient.cpp @@ -89,7 +89,7 @@ int CurrentTimeClient::OnCurrentTimeReadResult(uint16_t conn_handle, const ble_g NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", year, result.month, result.dayofmonth, result.hour, result.minute, result.second); dateTimeController - .SetTime(year, result.month, result.dayofmonth, 0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG)); + .SetTime(year, result.month, result.dayofmonth, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG)); } else { NRF_LOG_INFO("Error retrieving current time: %d", error->status); } diff --git a/src/components/ble/CurrentTimeService.cpp b/src/components/ble/CurrentTimeService.cpp index a264efba..856bc63a 100644 --- a/src/components/ble/CurrentTimeService.cpp +++ b/src/components/ble/CurrentTimeService.cpp @@ -8,18 +8,18 @@ constexpr ble_uuid16_t CurrentTimeService::ctsUuid; constexpr ble_uuid16_t CurrentTimeService::ctsCtChrUuid; constexpr ble_uuid16_t CurrentTimeService::ctsLtChrUuid; -int CTSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { +int CTSCallback(uint16_t /*conn_handle*/, uint16_t /*attr_handle*/, struct ble_gatt_access_ctxt* ctxt, void* arg) { auto cts = static_cast<CurrentTimeService*>(arg); - return cts->OnCurrentTimeServiceAccessed(conn_handle, attr_handle, ctxt); + return cts->OnCurrentTimeServiceAccessed(ctxt); } -int CurrentTimeService::OnCurrentTimeServiceAccessed(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) { +int CurrentTimeService::OnCurrentTimeServiceAccessed(struct ble_gatt_access_ctxt* ctxt) { switch (ble_uuid_u16(ctxt->chr->uuid)) { case ctsCurrentTimeCharId: - return OnCurrentTimeAccessed(conn_handle, attr_handle, ctxt); + return OnCurrentTimeAccessed(ctxt); case ctsLocalTimeCharId: - return OnLocalTimeAccessed(conn_handle, attr_handle, ctxt); + return OnLocalTimeAccessed(ctxt); } return -1; // Unknown characteristic } @@ -34,7 +34,7 @@ void CurrentTimeService::Init() { ASSERT(res == 0); } -int CurrentTimeService::OnCurrentTimeAccessed(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) { +int CurrentTimeService::OnCurrentTimeAccessed(struct ble_gatt_access_ctxt* ctxt) { NRF_LOG_INFO("Setting time..."); @@ -51,7 +51,7 @@ int CurrentTimeService::OnCurrentTimeAccessed(uint16_t conn_handle, uint16_t att NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", year, result.month, result.dayofmonth, result.hour, result.minute, result.second); m_dateTimeController - .SetTime(year, result.month, result.dayofmonth, 0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG)); + .SetTime(year, result.month, result.dayofmonth, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG)); } else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) { CtsCurrentTimeData currentDateTime; @@ -71,7 +71,7 @@ int CurrentTimeService::OnCurrentTimeAccessed(uint16_t conn_handle, uint16_t att return 0; } -int CurrentTimeService::OnLocalTimeAccessed(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) { +int CurrentTimeService::OnLocalTimeAccessed(struct ble_gatt_access_ctxt* ctxt) { NRF_LOG_INFO("Setting timezone..."); if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) { diff --git a/src/components/ble/CurrentTimeService.h b/src/components/ble/CurrentTimeService.h index 9933923d..bec75a2b 100644 --- a/src/components/ble/CurrentTimeService.h +++ b/src/components/ble/CurrentTimeService.h @@ -16,9 +16,9 @@ namespace Pinetime { CurrentTimeService(DateTime& dateTimeController); void Init(); - int OnCurrentTimeServiceAccessed(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt); - int OnCurrentTimeAccessed(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt); - int OnLocalTimeAccessed(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt); + int OnCurrentTimeServiceAccessed(struct ble_gatt_access_ctxt* ctxt); + int OnCurrentTimeAccessed(struct ble_gatt_access_ctxt* ctxt); + int OnLocalTimeAccessed(struct ble_gatt_access_ctxt* ctxt); private: static constexpr uint16_t ctsId {0x1805}; diff --git a/src/components/ble/DeviceInformationService.cpp b/src/components/ble/DeviceInformationService.cpp index 0f47c90f..f0d1b5a7 100644 --- a/src/components/ble/DeviceInformationService.cpp +++ b/src/components/ble/DeviceInformationService.cpp @@ -10,9 +10,9 @@ 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) { +int DeviceInformationCallback(uint16_t /*conn_handle*/, uint16_t /*attr_handle*/, struct ble_gatt_access_ctxt* ctxt, void* arg) { auto deviceInformationService = static_cast<DeviceInformationService*>(arg); - return deviceInformationService->OnDeviceInfoRequested(conn_handle, attr_handle, ctxt); + return deviceInformationService->OnDeviceInfoRequested(ctxt); } void DeviceInformationService::Init() { @@ -24,7 +24,7 @@ void DeviceInformationService::Init() { ASSERT(res == 0); } -int DeviceInformationService::OnDeviceInfoRequested(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) { +int DeviceInformationService::OnDeviceInfoRequested(struct ble_gatt_access_ctxt* ctxt) { const char* str; switch (ble_uuid_u16(ctxt->chr->uuid)) { diff --git a/src/components/ble/DeviceInformationService.h b/src/components/ble/DeviceInformationService.h index a269afb4..c4babd1b 100644 --- a/src/components/ble/DeviceInformationService.h +++ b/src/components/ble/DeviceInformationService.h @@ -14,7 +14,7 @@ namespace Pinetime { DeviceInformationService(); void Init(); - int OnDeviceInfoRequested(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt); + int OnDeviceInfoRequested(struct ble_gatt_access_ctxt* ctxt); private: static constexpr uint16_t deviceInfoId {0x180a}; @@ -50,4 +50,4 @@ namespace Pinetime { struct ble_gatt_svc_def serviceDefinition[2]; }; } -}
\ No newline at end of file +} diff --git a/src/components/ble/HeartRateService.cpp b/src/components/ble/HeartRateService.cpp index d49a02c8..c522e67e 100644 --- a/src/components/ble/HeartRateService.cpp +++ b/src/components/ble/HeartRateService.cpp @@ -9,9 +9,9 @@ constexpr ble_uuid16_t HeartRateService::heartRateServiceUuid; constexpr ble_uuid16_t HeartRateService::heartRateMeasurementUuid; namespace { - int HeartRateServiceCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { + int HeartRateServiceCallback(uint16_t /*conn_handle*/, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { auto* heartRateService = static_cast<HeartRateService*>(arg); - return heartRateService->OnHeartRateRequested(conn_handle, attr_handle, ctxt); + return heartRateService->OnHeartRateRequested(attr_handle, ctxt); } } @@ -45,7 +45,7 @@ void HeartRateService::Init() { ASSERT(res == 0); } -int HeartRateService::OnHeartRateRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context) { +int HeartRateService::OnHeartRateRequested(uint16_t attributeHandle, ble_gatt_access_ctxt* context) { if (attributeHandle == heartRateMeasurementHandle) { NRF_LOG_INFO("HEARTRATE : handle = %d", heartRateMeasurementHandle); uint8_t buffer[2] = {0, heartRateController.HeartRate()}; // [0] = flags, [1] = hr value @@ -60,7 +60,7 @@ void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) { if (!heartRateMeasurementNotificationEnable) return; - uint8_t buffer[2] = {0, heartRateController.HeartRate()}; // [0] = flags, [1] = hr value + uint8_t buffer[2] = {0, heartRateValue}; // [0] = flags, [1] = hr value auto* om = ble_hs_mbuf_from_flat(buffer, 2); uint16_t connectionHandle = system.nimble().connHandle(); @@ -72,12 +72,12 @@ void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) { ble_gattc_notify_custom(connectionHandle, heartRateMeasurementHandle, om); } -void HeartRateService::SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) { +void HeartRateService::SubscribeNotification(uint16_t attributeHandle) { if (attributeHandle == heartRateMeasurementHandle) heartRateMeasurementNotificationEnable = true; } -void HeartRateService::UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) { +void HeartRateService::UnsubscribeNotification(uint16_t attributeHandle) { if (attributeHandle == heartRateMeasurementHandle) heartRateMeasurementNotificationEnable = false; -}
\ No newline at end of file +} diff --git a/src/components/ble/HeartRateService.h b/src/components/ble/HeartRateService.h index a60c12f6..003bdbd1 100644 --- a/src/components/ble/HeartRateService.h +++ b/src/components/ble/HeartRateService.h @@ -18,11 +18,11 @@ namespace Pinetime { public: HeartRateService(Pinetime::System::SystemTask& system, Controllers::HeartRateController& heartRateController); void Init(); - int OnHeartRateRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context); + int OnHeartRateRequested(uint16_t attributeHandle, ble_gatt_access_ctxt* context); void OnNewHeartRateValue(uint8_t hearRateValue); - void SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle); - void UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle); + void SubscribeNotification(uint16_t attributeHandle); + void UnsubscribeNotification(uint16_t attributeHandle); private: Pinetime::System::SystemTask& system; diff --git a/src/components/ble/ImmediateAlertService.cpp b/src/components/ble/ImmediateAlertService.cpp index c80b3783..b9de615a 100644 --- a/src/components/ble/ImmediateAlertService.cpp +++ b/src/components/ble/ImmediateAlertService.cpp @@ -9,9 +9,9 @@ constexpr ble_uuid16_t ImmediateAlertService::immediateAlertServiceUuid; constexpr ble_uuid16_t ImmediateAlertService::alertLevelUuid; namespace { - int AlertLevelCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { + int AlertLevelCallback(uint16_t /*conn_handle*/, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { auto* immediateAlertService = static_cast<ImmediateAlertService*>(arg); - return immediateAlertService->OnAlertLevelChanged(conn_handle, attr_handle, ctxt); + return immediateAlertService->OnAlertLevelChanged(attr_handle, ctxt); } const char* ToString(ImmediateAlertService::Levels level) { @@ -56,7 +56,7 @@ void ImmediateAlertService::Init() { ASSERT(res == 0); } -int ImmediateAlertService::OnAlertLevelChanged(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context) { +int ImmediateAlertService::OnAlertLevelChanged(uint16_t attributeHandle, ble_gatt_access_ctxt* context) { if (attributeHandle == alertLevelHandle) { if (context->op == BLE_GATT_ACCESS_OP_WRITE_CHR) { auto alertLevel = static_cast<Levels>(context->om->om_data[0]); diff --git a/src/components/ble/ImmediateAlertService.h b/src/components/ble/ImmediateAlertService.h index c54b63ec..47a05439 100644 --- a/src/components/ble/ImmediateAlertService.h +++ b/src/components/ble/ImmediateAlertService.h @@ -19,7 +19,7 @@ namespace Pinetime { ImmediateAlertService(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::NotificationManager& notificationManager); void Init(); - int OnAlertLevelChanged(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context); + int OnAlertLevelChanged(uint16_t attributeHandle, ble_gatt_access_ctxt* context); private: Pinetime::System::SystemTask& systemTask; diff --git a/src/components/ble/MotionService.cpp b/src/components/ble/MotionService.cpp index a7e95923..604f22d5 100644 --- a/src/components/ble/MotionService.cpp +++ b/src/components/ble/MotionService.cpp @@ -21,9 +21,9 @@ namespace { constexpr ble_uuid128_t stepCountCharUuid {CharUuid(0x01, 0x00)}; constexpr ble_uuid128_t motionValuesCharUuid {CharUuid(0x02, 0x00)}; - int MotionServiceCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { + int MotionServiceCallback(uint16_t /*conn_handle*/, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { auto* motionService = static_cast<MotionService*>(arg); - return motionService->OnStepCountRequested(conn_handle, attr_handle, ctxt); + return motionService->OnStepCountRequested(attr_handle, ctxt); } } @@ -59,7 +59,7 @@ void MotionService::Init() { ASSERT(res == 0); } -int MotionService::OnStepCountRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context) { +int MotionService::OnStepCountRequested(uint16_t attributeHandle, ble_gatt_access_ctxt* context) { if (attributeHandle == stepCountHandle) { NRF_LOG_INFO("Motion-stepcount : handle = %d", stepCountHandle); uint32_t buffer = motionController.NbSteps(); @@ -95,7 +95,7 @@ void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) { if (!motionValuesNoficationEnabled) return; - int16_t buffer[3] = {motionController.X(), motionController.Y(), motionController.Z()}; + int16_t buffer[3] = {x, y, z}; auto* om = ble_hs_mbuf_from_flat(buffer, 3 * sizeof(int16_t)); uint16_t connectionHandle = system.nimble().connHandle(); @@ -107,14 +107,14 @@ void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) { ble_gattc_notify_custom(connectionHandle, motionValuesHandle, om); } -void MotionService::SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) { +void MotionService::SubscribeNotification(uint16_t attributeHandle) { if (attributeHandle == stepCountHandle) stepCountNoficationEnabled = true; else if (attributeHandle == motionValuesHandle) motionValuesNoficationEnabled = true; } -void MotionService::UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle) { +void MotionService::UnsubscribeNotification(uint16_t attributeHandle) { if (attributeHandle == stepCountHandle) stepCountNoficationEnabled = false; else if (attributeHandle == motionValuesHandle) diff --git a/src/components/ble/MotionService.h b/src/components/ble/MotionService.h index c9483766..1b172528 100644 --- a/src/components/ble/MotionService.h +++ b/src/components/ble/MotionService.h @@ -18,12 +18,12 @@ namespace Pinetime { public: MotionService(Pinetime::System::SystemTask& system, Controllers::MotionController& motionController); void Init(); - int OnStepCountRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt* context); + int OnStepCountRequested(uint16_t attributeHandle, ble_gatt_access_ctxt* context); void OnNewStepCountValue(uint32_t stepCount); void OnNewMotionValues(int16_t x, int16_t y, int16_t z); - void SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle); - void UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle); + void SubscribeNotification(uint16_t attributeHandle); + void UnsubscribeNotification(uint16_t attributeHandle); private: Pinetime::System::SystemTask& system; diff --git a/src/components/ble/MusicService.cpp b/src/components/ble/MusicService.cpp index fc7cef01..403c957b 100644 --- a/src/components/ble/MusicService.cpp +++ b/src/components/ble/MusicService.cpp @@ -48,8 +48,8 @@ namespace { constexpr uint8_t MaxStringSize {40}; - int MusicCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { - return static_cast<Pinetime::Controllers::MusicService*>(arg)->OnCommand(conn_handle, attr_handle, ctxt); + int MusicCallback(uint16_t /*conn_handle*/, uint16_t /*attr_handle*/, struct ble_gatt_access_ctxt* ctxt, void* arg) { + return static_cast<Pinetime::Controllers::MusicService*>(arg)->OnCommand(ctxt); } } @@ -122,7 +122,7 @@ void Pinetime::Controllers::MusicService::Init() { ASSERT(res == 0); } -int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) { +int Pinetime::Controllers::MusicService::OnCommand(struct ble_gatt_access_ctxt* ctxt) { if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) { size_t notifSize = OS_MBUF_PKTLEN(ctxt->om); size_t bufferSize = notifSize; diff --git a/src/components/ble/MusicService.h b/src/components/ble/MusicService.h index 9f1042cc..6aebc3c5 100644 --- a/src/components/ble/MusicService.h +++ b/src/components/ble/MusicService.h @@ -38,7 +38,7 @@ namespace Pinetime { void Init(); - int OnCommand(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt); + int OnCommand(struct ble_gatt_access_ctxt* ctxt); void event(char event); diff --git a/src/components/ble/NavigationService.cpp b/src/components/ble/NavigationService.cpp index ea8f3a4d..5508d08c 100644 --- a/src/components/ble/NavigationService.cpp +++ b/src/components/ble/NavigationService.cpp @@ -39,9 +39,9 @@ namespace { constexpr ble_uuid128_t navManDistCharUuid {CharUuid(0x03, 0x00)}; constexpr ble_uuid128_t navProgressCharUuid {CharUuid(0x04, 0x00)}; - int NAVCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) { + int NAVCallback(uint16_t /*conn_handle*/, uint16_t /*attr_handle*/, struct ble_gatt_access_ctxt* ctxt, void* arg) { auto* navService = static_cast<Pinetime::Controllers::NavigationService*>(arg); - return navService->OnCommand(conn_handle, attr_handle, ctxt); + return navService->OnCommand(ctxt); } } // namespace @@ -81,7 +81,7 @@ void Pinetime::Controllers::NavigationService::Init() { ASSERT(res == 0); } -int Pinetime::Controllers::NavigationService::OnCommand(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt) { +int Pinetime::Controllers::NavigationService::OnCommand(struct ble_gatt_access_ctxt* ctxt) { if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) { size_t notifSize = OS_MBUF_PKTLEN(ctxt->om); diff --git a/src/components/ble/NavigationService.h b/src/components/ble/NavigationService.h index 78e7b888..1c1739ba 100644 --- a/src/components/ble/NavigationService.h +++ b/src/components/ble/NavigationService.h @@ -39,7 +39,7 @@ namespace Pinetime { void Init(); - int OnCommand(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt); + int OnCommand(struct ble_gatt_access_ctxt* ctxt); std::string getFlag(); diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp index 52f4e4ce..912f5927 100644 --- a/src/components/ble/NimbleController.cpp +++ b/src/components/ble/NimbleController.cpp @@ -322,14 +322,14 @@ int NimbleController::OnGAPEvent(ble_gap_event* event) { event->subscribe.prev_indicate); if (event->subscribe.reason == BLE_GAP_SUBSCRIBE_REASON_TERM) { - heartRateService.UnsubscribeNotification(event->subscribe.conn_handle, event->subscribe.attr_handle); - motionService.UnsubscribeNotification(event->subscribe.conn_handle, event->subscribe.attr_handle); + heartRateService.UnsubscribeNotification(event->subscribe.attr_handle); + motionService.UnsubscribeNotification(event->subscribe.attr_handle); } else if (event->subscribe.prev_notify == 0 && event->subscribe.cur_notify == 1) { - heartRateService.SubscribeNotification(event->subscribe.conn_handle, event->subscribe.attr_handle); - motionService.SubscribeNotification(event->subscribe.conn_handle, event->subscribe.attr_handle); + heartRateService.SubscribeNotification(event->subscribe.attr_handle); + motionService.SubscribeNotification(event->subscribe.attr_handle); } else if (event->subscribe.prev_notify == 1 && event->subscribe.cur_notify == 0) { - heartRateService.UnsubscribeNotification(event->subscribe.conn_handle, event->subscribe.attr_handle); - motionService.UnsubscribeNotification(event->subscribe.conn_handle, event->subscribe.attr_handle); + heartRateService.UnsubscribeNotification(event->subscribe.attr_handle); + motionService.UnsubscribeNotification(event->subscribe.attr_handle); } break; diff --git a/src/components/ble/weather/WeatherService.cpp b/src/components/ble/weather/WeatherService.cpp index 950b6dfd..e606d9bf 100644 --- a/src/components/ble/weather/WeatherService.cpp +++ b/src/components/ble/weather/WeatherService.cpp @@ -20,8 +20,8 @@ #include "libs/QCBOR/inc/qcbor/qcbor.h" #include "systemtask/SystemTask.h" -int WeatherCallback(uint16_t connHandle, uint16_t attrHandle, struct ble_gatt_access_ctxt* ctxt, void* arg) { - return static_cast<Pinetime::Controllers::WeatherService*>(arg)->OnCommand(connHandle, attrHandle, ctxt); +int WeatherCallback(uint16_t /*connHandle*/, uint16_t /*attrHandle*/, struct ble_gatt_access_ctxt* ctxt, void* arg) { + return static_cast<Pinetime::Controllers::WeatherService*>(arg)->OnCommand(ctxt); } namespace Pinetime { @@ -41,7 +41,7 @@ namespace Pinetime { ASSERT(res == 0); } - int WeatherService::OnCommand(uint16_t connHandle, uint16_t attrHandle, struct ble_gatt_access_ctxt* ctxt) { + int WeatherService::OnCommand(struct ble_gatt_access_ctxt* ctxt) { if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) { const uint8_t packetLen = OS_MBUF_PKTLEN(ctxt->om); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (packetLen <= 0) { diff --git a/src/components/ble/weather/WeatherService.h b/src/components/ble/weather/WeatherService.h index 786cad89..00650e90 100644 --- a/src/components/ble/weather/WeatherService.h +++ b/src/components/ble/weather/WeatherService.h @@ -48,7 +48,7 @@ namespace Pinetime { void Init(); - int OnCommand(uint16_t connHandle, uint16_t attrHandle, struct ble_gatt_access_ctxt* ctxt); + int OnCommand(struct ble_gatt_access_ctxt* ctxt); /* * Helper functions for quick access to currently valid data diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index 73364b2f..b744fbb2 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -20,14 +20,7 @@ void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, UpdateTime(previousSystickCounter); // Update internal state without updating the time } -void DateTime::SetTime(uint16_t year, - uint8_t month, - uint8_t day, - uint8_t dayOfWeek, - uint8_t hour, - uint8_t minute, - uint8_t second, - uint32_t systickCounter) { +void DateTime::SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t systickCounter) { std::tm tm = { /* .tm_sec = */ second, /* .tm_min = */ minute, diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h index 57ee3510..74ccf4da 100644 --- a/src/components/datetime/DateTimeController.h +++ b/src/components/datetime/DateTimeController.h @@ -31,14 +31,7 @@ namespace Pinetime { December }; - void SetTime(uint16_t year, - uint8_t month, - uint8_t day, - uint8_t dayOfWeek, - uint8_t hour, - uint8_t minute, - uint8_t second, - uint32_t systickCounter); + void SetTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t systickCounter); /* * setter corresponding to the BLE Set Local Time characteristic. diff --git a/src/components/fs/FS.cpp b/src/components/fs/FS.cpp index a67b6b3d..0bb59afa 100644 --- a/src/components/fs/FS.cpp +++ b/src/components/fs/FS.cpp @@ -115,7 +115,7 @@ lfs_ssize_t FS::GetFSSize() { ----------- Interface between littlefs and SpiNorFlash ----------- */ -int FS::SectorSync(const struct lfs_config* c) { +int FS::SectorSync(const struct lfs_config* /*c*/) { return 0; } @@ -147,7 +147,7 @@ int FS::SectorRead(const struct lfs_config* c, lfs_block_t block, lfs_off_t off, */ namespace { - lv_fs_res_t lvglOpen(lv_fs_drv_t* drv, void* file_p, const char* path, lv_fs_mode_t mode) { + lv_fs_res_t lvglOpen(lv_fs_drv_t* drv, void* file_p, const char* path, lv_fs_mode_t /*mode*/) { lfs_file_t* file = static_cast<lfs_file_t*>(file_p); FS* filesys = static_cast<FS*>(drv->user_data); int res = filesys->FileOpen(file, path, LFS_O_RDONLY); @@ -200,4 +200,4 @@ void FS::LVGLFileSystemInit() { fs_drv.user_data = this; lv_fs_drv_register(&fs_drv); -}
\ No newline at end of file +} diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp index db6103f4..4e392416 100644 --- a/src/components/motor/MotorController.cpp +++ b/src/components/motor/MotorController.cpp @@ -34,6 +34,6 @@ void MotorController::StopRinging() { nrf_gpio_pin_set(PinMap::Motor); } -void MotorController::StopMotor(TimerHandle_t xTimer) { +void MotorController::StopMotor(TimerHandle_t /*xTimer*/) { nrf_gpio_pin_set(PinMap::Motor); } |