2020-04-19 21:26:09 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
2020-04-25 13:09:47 +02:00
|
|
|
#include "AlertNotificationClient.h"
|
2020-04-23 20:34:38 +02:00
|
|
|
#include "DeviceInformationService.h"
|
2020-04-23 20:57:53 +02:00
|
|
|
#include "CurrentTimeClient.h"
|
2020-04-28 12:21:35 +02:00
|
|
|
#include "PinetimeService.h"
|
2020-04-19 21:26:09 +02:00
|
|
|
#include <host/ble_gap.h>
|
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Controllers {
|
2020-04-22 20:19:36 +02:00
|
|
|
class DateTime;
|
2020-04-19 21:26:09 +02:00
|
|
|
class NimbleController {
|
2020-04-25 15:52:00 +02:00
|
|
|
|
2020-04-19 21:26:09 +02:00
|
|
|
public:
|
2020-04-27 20:13:27 +02:00
|
|
|
NimbleController(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::Ble& bleController, DateTime& dateTimeController, Pinetime::Controllers::NotificationManager& notificationManager);
|
2020-04-19 21:26:09 +02:00
|
|
|
void Init();
|
|
|
|
void StartAdvertising();
|
|
|
|
int OnGAPEvent(ble_gap_event *event);
|
2020-04-23 20:57:53 +02:00
|
|
|
|
2020-04-25 13:09:47 +02:00
|
|
|
int OnDiscoveryEvent(uint16_t i, const ble_gatt_error *pError, const ble_gatt_svc *pSvc);
|
2020-04-25 15:52:00 +02:00
|
|
|
int OnCTSCharacteristicDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error,
|
|
|
|
const ble_gatt_chr *characteristic);
|
|
|
|
int OnANSCharacteristicDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error,
|
|
|
|
const ble_gatt_chr *characteristic);
|
|
|
|
int OnCurrentTimeReadResult(uint16_t connectionHandle, const ble_gatt_error *error, ble_gatt_attr *attribute);
|
|
|
|
int OnANSDescriptorDiscoveryEventCallback(uint16_t connectionHandle, const ble_gatt_error *error,
|
|
|
|
uint16_t characteristicValueHandle, const ble_gatt_dsc *descriptor);
|
2020-04-19 21:26:09 +02:00
|
|
|
private:
|
|
|
|
static constexpr char* deviceName = "Pinetime-JF";
|
2020-04-25 13:09:47 +02:00
|
|
|
Pinetime::System::SystemTask& systemTask;
|
2020-04-27 20:13:27 +02:00
|
|
|
Pinetime::Controllers::Ble& bleController;
|
2020-04-22 20:19:36 +02:00
|
|
|
DateTime& dateTimeController;
|
2020-04-25 13:09:47 +02:00
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
|
|
|
|
2020-04-23 20:34:38 +02:00
|
|
|
DeviceInformationService deviceInformationService;
|
2020-04-23 20:57:53 +02:00
|
|
|
CurrentTimeClient currentTimeClient;
|
2020-04-25 13:09:47 +02:00
|
|
|
AlertNotificationClient alertNotificationClient;
|
2020-04-28 12:21:35 +02:00
|
|
|
PinetimeService pinetimeService;
|
2020-04-19 21:26:09 +02:00
|
|
|
uint8_t addrType;
|
2020-04-22 20:19:36 +02:00
|
|
|
uint16_t connectionHandle;
|
2020-04-19 21:26:09 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|