2020-04-19 19:26:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
2020-04-25 11:09:47 +00:00
|
|
|
#include "AlertNotificationClient.h"
|
2020-04-23 18:34:38 +00:00
|
|
|
#include "DeviceInformationService.h"
|
2020-04-23 18:57:53 +00:00
|
|
|
#include "CurrentTimeClient.h"
|
2020-04-19 19:26:09 +00:00
|
|
|
#include <host/ble_gap.h>
|
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Controllers {
|
2020-04-22 18:19:36 +00:00
|
|
|
class DateTime;
|
2020-04-19 19:26:09 +00:00
|
|
|
class NimbleController {
|
2020-04-25 13:52:00 +00:00
|
|
|
|
2020-04-19 19:26:09 +00:00
|
|
|
public:
|
2020-04-25 11:09:47 +00:00
|
|
|
NimbleController(Pinetime::System::SystemTask& systemTask, DateTime& dateTimeController, Pinetime::Controllers::NotificationManager& notificationManager);
|
2020-04-19 19:26:09 +00:00
|
|
|
void Init();
|
|
|
|
void StartAdvertising();
|
|
|
|
int OnGAPEvent(ble_gap_event *event);
|
2020-04-23 18:57:53 +00:00
|
|
|
|
2020-04-25 11:09:47 +00:00
|
|
|
int OnDiscoveryEvent(uint16_t i, const ble_gatt_error *pError, const ble_gatt_svc *pSvc);
|
2020-04-25 13:52:00 +00: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 19:26:09 +00:00
|
|
|
private:
|
|
|
|
static constexpr char* deviceName = "Pinetime-JF";
|
2020-04-25 11:09:47 +00:00
|
|
|
Pinetime::System::SystemTask& systemTask;
|
2020-04-22 18:19:36 +00:00
|
|
|
DateTime& dateTimeController;
|
2020-04-25 11:09:47 +00:00
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
|
|
|
|
2020-04-23 18:34:38 +00:00
|
|
|
DeviceInformationService deviceInformationService;
|
2020-04-23 18:57:53 +00:00
|
|
|
CurrentTimeClient currentTimeClient;
|
2020-04-25 11:09:47 +00:00
|
|
|
AlertNotificationClient alertNotificationClient;
|
2020-04-19 19:26:09 +00:00
|
|
|
uint8_t addrType;
|
2020-04-22 18:19:36 +00:00
|
|
|
uint16_t connectionHandle;
|
2020-04-19 19:26:09 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|