2020-04-19 19:26:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
2020-04-28 17:39:26 +00:00
|
|
|
#include "AlertNotificationService.h"
|
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-27 18:16:03 +00:00
|
|
|
#include "DfuService.h"
|
2020-05-04 20:43:51 +00:00
|
|
|
#include "CurrentTimeService.h"
|
2020-07-11 20:37:28 +00:00
|
|
|
#include "MusicService.h"
|
2020-09-27 18:02:47 +00:00
|
|
|
#include "BatteryInformationService.h"
|
2020-09-27 18:59:06 +00:00
|
|
|
#include "ImmediateAlertService.h"
|
2020-04-19 19:26:09 +00:00
|
|
|
#include <host/ble_gap.h>
|
|
|
|
|
|
|
|
namespace Pinetime {
|
2020-05-11 16:50:37 +00:00
|
|
|
namespace Drivers {
|
|
|
|
class SpiNorFlash;
|
|
|
|
}
|
2020-04-19 19:26:09 +00:00
|
|
|
namespace Controllers {
|
2020-04-22 18:19:36 +00:00
|
|
|
class DateTime;
|
2020-07-20 20:28:21 +00:00
|
|
|
|
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-05-11 16:50:37 +00:00
|
|
|
NimbleController(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::Ble& bleController,
|
|
|
|
DateTime& dateTimeController, Pinetime::Controllers::NotificationManager& notificationManager,
|
2020-09-27 18:02:47 +00:00
|
|
|
Controllers::Battery& batteryController, Pinetime::Drivers::SpiNorFlash& spiNorFlash);
|
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-05-01 19:58:31 +00:00
|
|
|
|
|
|
|
void StartDiscovery();
|
2020-07-11 20:37:28 +00:00
|
|
|
|
|
|
|
Pinetime::Controllers::MusicService& music() {return musicService;};
|
|
|
|
|
2020-07-20 20:28:21 +00:00
|
|
|
uint16_t connHandle();
|
|
|
|
|
2020-04-19 19:26:09 +00:00
|
|
|
private:
|
2020-09-20 09:09:50 +00:00
|
|
|
static constexpr const char* deviceName = "InfiniTime";
|
2020-04-25 11:09:47 +00:00
|
|
|
Pinetime::System::SystemTask& systemTask;
|
2020-04-27 18:13:27 +00:00
|
|
|
Pinetime::Controllers::Ble& bleController;
|
2020-04-22 18:19:36 +00:00
|
|
|
DateTime& dateTimeController;
|
2020-04-25 11:09:47 +00:00
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
2020-05-11 16:50:37 +00:00
|
|
|
Pinetime::Drivers::SpiNorFlash& spiNorFlash;
|
2020-05-02 12:16:57 +00:00
|
|
|
Pinetime::Controllers::DfuService dfuService;
|
2020-04-25 11:09:47 +00:00
|
|
|
|
2020-04-23 18:34:38 +00:00
|
|
|
DeviceInformationService deviceInformationService;
|
2020-04-23 18:57:53 +00:00
|
|
|
CurrentTimeClient currentTimeClient;
|
2020-04-28 17:39:26 +00:00
|
|
|
AlertNotificationService anService;
|
2020-04-25 11:09:47 +00:00
|
|
|
AlertNotificationClient alertNotificationClient;
|
2020-05-04 20:43:51 +00:00
|
|
|
CurrentTimeService currentTimeService;
|
2020-07-11 20:37:28 +00:00
|
|
|
MusicService musicService;
|
2020-09-27 18:02:47 +00:00
|
|
|
BatteryInformationService batteryInformationService;
|
2020-09-27 18:59:06 +00:00
|
|
|
ImmediateAlertService immediateAlertService;
|
2020-04-28 17:39:26 +00:00
|
|
|
|
2020-06-08 19:51:34 +00:00
|
|
|
uint8_t addrType; // 1 = Random, 0 = PUBLIC
|
2020-07-20 20:28:21 +00:00
|
|
|
uint16_t connectionHandle = 0;
|
2020-04-27 18:16:03 +00:00
|
|
|
|
|
|
|
ble_uuid128_t dfuServiceUuid {
|
|
|
|
.u { .type = BLE_UUID_TYPE_128},
|
|
|
|
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15,
|
|
|
|
0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}
|
|
|
|
};
|
2020-04-19 19:26:09 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|