Skip to content

Commit a6cd367

Browse files
apilatFintasticMan
authored andcommitted
Only inhibit sleep if motion notifications are enabled, not just Bluetooth
1 parent 074df05 commit a6cd367

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

src/components/ble/MotionService.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,7 @@ void MotionService::UnsubscribeNotification(uint16_t attributeHandle) {
120120
else if (attributeHandle == motionValuesHandle)
121121
motionValuesNoficationEnabled = false;
122122
}
123+
124+
bool MotionService::IsMotionNotificationSubscribed() const {
125+
return motionValuesNoficationEnabled;
126+
}

src/components/ble/MotionService.h

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace Pinetime {
2121

2222
void SubscribeNotification(uint16_t attributeHandle);
2323
void UnsubscribeNotification(uint16_t attributeHandle);
24+
bool IsMotionNotificationSubscribed() const;
2425

2526
private:
2627
NimbleController& nimble;

src/components/motion/MotionController.h

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ namespace Pinetime {
6262
this->service = service;
6363
}
6464

65+
Pinetime::Controllers::MotionService* GetService() const {
66+
return service;
67+
}
68+
6569
private:
6670
uint32_t nbSteps = 0;
6771
uint32_t currentTripSteps = 0;

src/systemtask/SystemTask.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ void SystemTask::UpdateMotion() {
417417
return;
418418
}
419419

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

0 commit comments

Comments
 (0)