Skip to content

Commit

Permalink
Only inhibit sleep if motion notifications are enabled, not just Blue…
Browse files Browse the repository at this point in the history
…tooth
  • Loading branch information
apilat authored and FintasticMan committed Jan 23, 2024
1 parent 074df05 commit a6cd367
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/components/ble/MotionService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,7 @@ void MotionService::UnsubscribeNotification(uint16_t attributeHandle) {
else if (attributeHandle == motionValuesHandle)
motionValuesNoficationEnabled = false;
}

bool MotionService::IsMotionNotificationSubscribed() const {
return motionValuesNoficationEnabled;
}
1 change: 1 addition & 0 deletions src/components/ble/MotionService.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Pinetime {

void SubscribeNotification(uint16_t attributeHandle);
void UnsubscribeNotification(uint16_t attributeHandle);
bool IsMotionNotificationSubscribed() const;

private:
NimbleController& nimble;
Expand Down
4 changes: 4 additions & 0 deletions src/components/motion/MotionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ namespace Pinetime {
this->service = service;
}

Pinetime::Controllers::MotionService* GetService() const {
return service;
}

private:
uint32_t nbSteps = 0;
uint32_t currentTripSteps = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/systemtask/SystemTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ void SystemTask::UpdateMotion() {
return;
}

if (state == SystemTaskState::Sleeping &&
!(settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) ||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake) || bleController.IsConnected())) {
if (state == SystemTaskState::Sleeping && !(settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) ||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake) ||
motionController.GetService()->IsMotionNotificationSubscribed())) {
return;
}

Expand Down

0 comments on commit a6cd367

Please sign in to comment.