Skip to content

Commit 7c98f26

Browse files
committed
MotionService: Remove SystemTask dependency
1 parent ca5e7d1 commit 7c98f26

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

src/components/ble/MotionService.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "components/ble/MotionService.h"
22
#include "components/motion/MotionController.h"
3-
#include "systemtask/SystemTask.h"
3+
#include "components/ble/NimbleController.h"
44
#include <nrf_log.h>
55

66
using namespace Pinetime::Controllers;
@@ -28,8 +28,8 @@ namespace {
2828
}
2929

3030
// TODO Refactoring - remove dependency to SystemTask
31-
MotionService::MotionService(Pinetime::System::SystemTask& system, Controllers::MotionController& motionController)
32-
: system {system},
31+
MotionService::MotionService(NimbleController& nimble, Controllers::MotionController& motionController)
32+
: nimble {nimble},
3333
motionController {motionController},
3434
characteristicDefinition {{.uuid = &stepCountCharUuid.u,
3535
.access_cb = MotionServiceCallback,
@@ -82,7 +82,7 @@ void MotionService::OnNewStepCountValue(uint32_t stepCount) {
8282
uint32_t buffer = stepCount;
8383
auto* om = ble_hs_mbuf_from_flat(&buffer, 4);
8484

85-
uint16_t connectionHandle = system.nimble().connHandle();
85+
uint16_t connectionHandle = nimble.connHandle();
8686

8787
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
8888
return;
@@ -98,7 +98,7 @@ void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) {
9898
int16_t buffer[3] = {x, y, z};
9999
auto* om = ble_hs_mbuf_from_flat(buffer, 3 * sizeof(int16_t));
100100

101-
uint16_t connectionHandle = system.nimble().connHandle();
101+
uint16_t connectionHandle = nimble.connHandle();
102102

103103
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
104104
return;

src/components/ble/MotionService.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77
#undef min
88

99
namespace Pinetime {
10-
namespace System {
11-
class SystemTask;
12-
}
13-
1410
namespace Controllers {
11+
class NimbleController;
1512
class MotionController;
1613

1714
class MotionService {
1815
public:
19-
MotionService(Pinetime::System::SystemTask& system, Controllers::MotionController& motionController);
16+
MotionService(NimbleController& nimble, Controllers::MotionController& motionController);
2017
void Init();
2118
int OnStepCountRequested(uint16_t attributeHandle, ble_gatt_access_ctxt* context);
2219
void OnNewStepCountValue(uint32_t stepCount);
@@ -26,7 +23,7 @@ namespace Pinetime {
2623
void UnsubscribeNotification(uint16_t attributeHandle);
2724

2825
private:
29-
Pinetime::System::SystemTask& system;
26+
NimbleController& nimble;
3027
Controllers::MotionController& motionController;
3128

3229
struct ble_gatt_chr_def characteristicDefinition[3];

src/components/ble/NimbleController.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
4747
batteryInformationService {batteryController},
4848
immediateAlertService {systemTask, notificationManager},
4949
heartRateService {systemTask, heartRateController},
50-
motionService {systemTask, motionController},
50+
motionService {*this, motionController},
5151
fsService {systemTask, fs},
5252
serviceDiscovery({&currentTimeClient, &alertNotificationClient}) {
5353
}

0 commit comments

Comments
 (0)