summaryrefslogtreecommitdiff
path: root/src/Components/Ble
diff options
context:
space:
mode:
Diffstat (limited to 'src/Components/Ble')
-rw-r--r--src/Components/Ble/NimbleController.cpp7
-rw-r--r--src/Components/Ble/NimbleController.h3
-rw-r--r--src/Components/Ble/PinetimeService.cpp23
-rw-r--r--src/Components/Ble/PinetimeService.h4
4 files changed, 19 insertions, 18 deletions
diff --git a/src/Components/Ble/NimbleController.cpp b/src/Components/Ble/NimbleController.cpp
index 77bab5de..eb765b80 100644
--- a/src/Components/Ble/NimbleController.cpp
+++ b/src/Components/Ble/NimbleController.cpp
@@ -30,7 +30,9 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
dateTimeController{dateTimeController},
notificationManager{notificationManager},
currentTimeClient{dateTimeController},
- alertNotificationClient{systemTask, notificationManager} {
+ alertNotificationClient{systemTask, notificationManager},
+ anService{systemTask, notificationManager},
+ pinetimeService{dateTimeController} {
}
@@ -75,7 +77,8 @@ void NimbleController::Init() {
deviceInformationService.Init();
currentTimeClient.Init();
pinetimeService.Init();
- pinetimeService.setDateTimeController(&dateTimeController);
+
+ anService.Init();
int res;
res = ble_hs_util_ensure_addr(0);
diff --git a/src/Components/Ble/NimbleController.h b/src/Components/Ble/NimbleController.h
index d315e97b..820b1c77 100644
--- a/src/Components/Ble/NimbleController.h
+++ b/src/Components/Ble/NimbleController.h
@@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
+#include "AlertNotificationService.h"
#include "AlertNotificationClient.h"
#include "DeviceInformationService.h"
#include "CurrentTimeClient.h"
@@ -35,8 +36,10 @@ namespace Pinetime {
DeviceInformationService deviceInformationService;
CurrentTimeClient currentTimeClient;
+ AlertNotificationService anService;
AlertNotificationClient alertNotificationClient;
PinetimeService pinetimeService;
+
uint8_t addrType;
uint16_t connectionHandle;
};
diff --git a/src/Components/Ble/PinetimeService.cpp b/src/Components/Ble/PinetimeService.cpp
index 5bcb36d1..e18d78aa 100644
--- a/src/Components/Ble/PinetimeService.cpp
+++ b/src/Components/Ble/PinetimeService.cpp
@@ -24,22 +24,21 @@ int PinetimeService::OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handle,
NRF_LOG_INFO("Setting time...");
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
- if (m_dateTimeController) {
- CtsData result;
- os_mbuf_copydata(ctxt->om, 0, sizeof(CtsData), &result);
+ CtsData result;
+ os_mbuf_copydata(ctxt->om, 0, sizeof(CtsData), &result);
- NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", result.year,
- result.month, result.dayofmonth,
- result.hour, result.minute, result.second);
+ NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", result.year,
+ result.month, result.dayofmonth,
+ result.hour, result.minute, result.second);
+
+ m_dateTimeController.SetTime(result.year, result.month, result.dayofmonth,
+ 0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG));
- m_dateTimeController->SetTime(result.year, result.month, result.dayofmonth,
- 0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG));
- }
}
return 0;
}
-PinetimeService::PinetimeService() :
+PinetimeService::PinetimeService(DateTime &dateTimeController) : m_dateTimeController{dateTimeController},
characteristicDefinition{
{
.uuid = (ble_uuid_t *) &timeUuid,
@@ -67,7 +66,3 @@ PinetimeService::PinetimeService() :
}
-void PinetimeService::setDateTimeController(DateTime *dateTimeController)
-{
- m_dateTimeController = dateTimeController;
-}
diff --git a/src/Components/Ble/PinetimeService.h b/src/Components/Ble/PinetimeService.h
index d4f8ee2b..0cae8345 100644
--- a/src/Components/Ble/PinetimeService.h
+++ b/src/Components/Ble/PinetimeService.h
@@ -8,7 +8,7 @@ namespace Pinetime {
namespace Controllers {
class PinetimeService {
public:
- PinetimeService();
+ PinetimeService(DateTime &dateTimeController);
void Init();
int OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handle,
@@ -44,7 +44,7 @@ namespace Pinetime {
uint8_t reason;
} CtsData;
- DateTime *m_dateTimeController = nullptr;
+ DateTime &m_dateTimeController;
};
}
}