Run the alert notification service and simplify trhe pinetime service
initialization
This commit is contained in:
parent
423a956d8f
commit
5df4c1016a
5 changed files with 20 additions and 18 deletions
|
@ -320,6 +320,7 @@ list(APPEND SOURCE_FILES
|
||||||
Components/Ble/CurrentTimeClient.cpp
|
Components/Ble/CurrentTimeClient.cpp
|
||||||
Components/Ble/AlertNotificationClient.cpp
|
Components/Ble/AlertNotificationClient.cpp
|
||||||
Components/Ble/PinetimeService.cpp
|
Components/Ble/PinetimeService.cpp
|
||||||
|
Components/Ble/AlertNotificationService.cpp
|
||||||
drivers/Cst816s.cpp
|
drivers/Cst816s.cpp
|
||||||
FreeRTOS/port.c
|
FreeRTOS/port.c
|
||||||
FreeRTOS/port_cmsis_systick.c
|
FreeRTOS/port_cmsis_systick.c
|
||||||
|
|
|
@ -28,7 +28,9 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
|
||||||
dateTimeController{dateTimeController},
|
dateTimeController{dateTimeController},
|
||||||
notificationManager{notificationManager},
|
notificationManager{notificationManager},
|
||||||
currentTimeClient{dateTimeController},
|
currentTimeClient{dateTimeController},
|
||||||
alertNotificationClient{systemTask, notificationManager} {
|
alertNotificationClient{systemTask, notificationManager},
|
||||||
|
anService{systemTask, notificationManager},
|
||||||
|
pinetimeService{dateTimeController} {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +75,8 @@ void NimbleController::Init() {
|
||||||
deviceInformationService.Init();
|
deviceInformationService.Init();
|
||||||
currentTimeClient.Init();
|
currentTimeClient.Init();
|
||||||
pinetimeService.Init();
|
pinetimeService.Init();
|
||||||
pinetimeService.setDateTimeController(&dateTimeController);
|
|
||||||
|
anService.Init();
|
||||||
|
|
||||||
int res;
|
int res;
|
||||||
res = ble_hs_util_ensure_addr(0);
|
res = ble_hs_util_ensure_addr(0);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include "AlertNotificationService.h"
|
||||||
#include "AlertNotificationClient.h"
|
#include "AlertNotificationClient.h"
|
||||||
#include "DeviceInformationService.h"
|
#include "DeviceInformationService.h"
|
||||||
#include "CurrentTimeClient.h"
|
#include "CurrentTimeClient.h"
|
||||||
|
@ -34,8 +35,10 @@ namespace Pinetime {
|
||||||
|
|
||||||
DeviceInformationService deviceInformationService;
|
DeviceInformationService deviceInformationService;
|
||||||
CurrentTimeClient currentTimeClient;
|
CurrentTimeClient currentTimeClient;
|
||||||
|
AlertNotificationService anService;
|
||||||
AlertNotificationClient alertNotificationClient;
|
AlertNotificationClient alertNotificationClient;
|
||||||
PinetimeService pinetimeService;
|
PinetimeService pinetimeService;
|
||||||
|
|
||||||
uint8_t addrType;
|
uint8_t addrType;
|
||||||
uint16_t connectionHandle;
|
uint16_t connectionHandle;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,22 +24,21 @@ int PinetimeService::OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handle,
|
||||||
NRF_LOG_INFO("Setting time...");
|
NRF_LOG_INFO("Setting time...");
|
||||||
|
|
||||||
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
|
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
|
||||||
if (m_dateTimeController) {
|
CtsData result;
|
||||||
CtsData result;
|
os_mbuf_copydata(ctxt->om, 0, sizeof(CtsData), &result);
|
||||||
os_mbuf_copydata(ctxt->om, 0, sizeof(CtsData), &result);
|
|
||||||
|
|
||||||
NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", result.year,
|
NRF_LOG_INFO("Received data: %d-%d-%d %d:%d:%d", result.year,
|
||||||
result.month, result.dayofmonth,
|
result.month, result.dayofmonth,
|
||||||
result.hour, result.minute, result.second);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PinetimeService::PinetimeService() :
|
PinetimeService::PinetimeService(DateTime &dateTimeController) : m_dateTimeController{dateTimeController},
|
||||||
characteristicDefinition{
|
characteristicDefinition{
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t *) &timeUuid,
|
.uuid = (ble_uuid_t *) &timeUuid,
|
||||||
|
@ -67,7 +66,3 @@ PinetimeService::PinetimeService() :
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PinetimeService::setDateTimeController(DateTime *dateTimeController)
|
|
||||||
{
|
|
||||||
m_dateTimeController = dateTimeController;
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
class PinetimeService {
|
class PinetimeService {
|
||||||
public:
|
public:
|
||||||
PinetimeService();
|
PinetimeService(DateTime &dateTimeController);
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
int OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handle,
|
int OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handle,
|
||||||
|
@ -44,7 +44,7 @@ namespace Pinetime {
|
||||||
uint8_t reason;
|
uint8_t reason;
|
||||||
} CtsData;
|
} CtsData;
|
||||||
|
|
||||||
DateTime *m_dateTimeController = nullptr;
|
DateTime &m_dateTimeController;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue