Skip to content

Commit bf970ca

Browse files
committed
Only inhibit sleep if motion notifications are enabled, not just Bluetooth
1 parent 1b4d34e commit bf970ca

6 files changed

Lines changed: 17 additions & 4 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ Testing/Temporary/
4747
#build files
4848
src/nRF5_SDK_15.3.0_59ac345
4949
src/arm-none-eabi
50+
51+
# clangd
52+
.cache/

src/components/ble/MotionService.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,7 @@ void MotionService::UnsubscribeNotification(uint16_t connectionHandle, uint16_t
119119
else if (attributeHandle == motionValuesHandle)
120120
motionValuesNoficationEnabled = false;
121121
}
122+
123+
bool MotionService::IsMotionNotificationSubscribed() const {
124+
return motionValuesNoficationEnabled;
125+
}

src/components/ble/MotionService.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace Pinetime {
2222

2323
void SubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle);
2424
void UnsubscribeNotification(uint16_t connectionHandle, uint16_t attributeHandle);
25+
bool IsMotionNotificationSubscribed() const;
2526

2627
private:
2728
Pinetime::System::SystemTask& system;

src/components/motion/MotionController.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,7 @@ void MotionController::Init(Pinetime::Drivers::Bma421::DeviceTypes types) {
8585
void MotionController::SetService(Pinetime::Controllers::MotionService* service) {
8686
this->service = service;
8787
}
88+
89+
Pinetime::Controllers::MotionService* MotionController::GetService() const {
90+
return this->service;
91+
}

src/components/motion/MotionController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ namespace Pinetime {
5050

5151
void Init(Pinetime::Drivers::Bma421::DeviceTypes types);
5252
void SetService(Pinetime::Controllers::MotionService* service);
53+
Pinetime::Controllers::MotionService* GetService() const;
5354

5455
private:
5556
uint32_t nbSteps;
@@ -69,4 +70,4 @@ namespace Pinetime {
6970
uint32_t lastShakeTime = 0;
7071
};
7172
}
72-
}
73+
}

src/systemtask/SystemTask.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ void SystemTask::UpdateMotion() {
468468
return;
469469
}
470470

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

0 commit comments

Comments
 (0)