HeartRateService: Remove SystemTask dependency
This commit is contained in:
parent
7c98f26f12
commit
829ab86f37
|
@ -1,6 +1,6 @@
|
|||
#include "components/ble/HeartRateService.h"
|
||||
#include "components/heartrate/HeartRateController.h"
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "components/ble/NimbleController.h"
|
||||
#include <nrf_log.h>
|
||||
|
||||
using namespace Pinetime::Controllers;
|
||||
|
@ -16,8 +16,8 @@ namespace {
|
|||
}
|
||||
|
||||
// TODO Refactoring - remove dependency to SystemTask
|
||||
HeartRateService::HeartRateService(Pinetime::System::SystemTask& system, Controllers::HeartRateController& heartRateController)
|
||||
: system {system},
|
||||
HeartRateService::HeartRateService(NimbleController& nimble, Controllers::HeartRateController& heartRateController)
|
||||
: nimble {nimble},
|
||||
heartRateController {heartRateController},
|
||||
characteristicDefinition {{.uuid = &heartRateMeasurementUuid.u,
|
||||
.access_cb = HeartRateServiceCallback,
|
||||
|
@ -63,7 +63,7 @@ void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) {
|
|||
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();
|
||||
uint16_t connectionHandle = nimble.connHandle();
|
||||
|
||||
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
|
||||
return;
|
||||
|
|
|
@ -7,16 +7,13 @@
|
|||
#undef min
|
||||
|
||||
namespace Pinetime {
|
||||
namespace System {
|
||||
class SystemTask;
|
||||
}
|
||||
|
||||
namespace Controllers {
|
||||
class HeartRateController;
|
||||
class NimbleController;
|
||||
|
||||
class HeartRateService {
|
||||
public:
|
||||
HeartRateService(Pinetime::System::SystemTask& system, Controllers::HeartRateController& heartRateController);
|
||||
HeartRateService(NimbleController& nimble, Controllers::HeartRateController& heartRateController);
|
||||
void Init();
|
||||
int OnHeartRateRequested(uint16_t attributeHandle, ble_gatt_access_ctxt* context);
|
||||
void OnNewHeartRateValue(uint8_t hearRateValue);
|
||||
|
@ -25,7 +22,7 @@ namespace Pinetime {
|
|||
void UnsubscribeNotification(uint16_t attributeHandle);
|
||||
|
||||
private:
|
||||
Pinetime::System::SystemTask& system;
|
||||
NimbleController& nimble;
|
||||
Controllers::HeartRateController& heartRateController;
|
||||
static constexpr uint16_t heartRateServiceId {0x180D};
|
||||
static constexpr uint16_t heartRateMeasurementId {0x2A37};
|
||||
|
|
|
@ -46,7 +46,7 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
|
|||
weatherService {dateTimeController},
|
||||
batteryInformationService {batteryController},
|
||||
immediateAlertService {systemTask, notificationManager},
|
||||
heartRateService {systemTask, heartRateController},
|
||||
heartRateService {*this, heartRateController},
|
||||
motionService {*this, motionController},
|
||||
fsService {systemTask, fs},
|
||||
serviceDiscovery({¤tTimeClient, &alertNotificationClient}) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user