2020-04-19 15:26:09 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
2020-04-28 13:39:26 -04:00
|
|
|
#include "AlertNotificationService.h"
|
2020-04-25 07:09:47 -04:00
|
|
|
#include "AlertNotificationClient.h"
|
2020-04-23 14:34:38 -04:00
|
|
|
#include "DeviceInformationService.h"
|
2020-04-23 14:57:53 -04:00
|
|
|
#include "CurrentTimeClient.h"
|
2020-04-27 14:16:03 -04:00
|
|
|
#include "DfuService.h"
|
2020-05-04 16:43:51 -04:00
|
|
|
#include "CurrentTimeService.h"
|
2020-07-11 16:37:28 -04:00
|
|
|
#include "MusicService.h"
|
2020-04-19 15:26:09 -04:00
|
|
|
#include <host/ble_gap.h>
|
|
|
|
|
|
|
|
namespace Pinetime {
|
2020-05-11 12:50:37 -04:00
|
|
|
namespace Drivers {
|
|
|
|
class SpiNorFlash;
|
|
|
|
}
|
2020-04-19 15:26:09 -04:00
|
|
|
namespace Controllers {
|
2020-04-22 14:19:36 -04:00
|
|
|
class DateTime;
|
2020-07-20 16:28:21 -04:00
|
|
|
|
2020-04-19 15:26:09 -04:00
|
|
|
class NimbleController {
|
2020-04-25 09:52:00 -04:00
|
|
|
|
2020-04-19 15:26:09 -04:00
|
|
|
public:
|
2020-05-11 12:50:37 -04:00
|
|
|
NimbleController(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::Ble& bleController,
|
|
|
|
DateTime& dateTimeController, Pinetime::Controllers::NotificationManager& notificationManager,
|
|
|
|
Pinetime::Drivers::SpiNorFlash& spiNorFlash);
|
2020-04-19 15:26:09 -04:00
|
|
|
void Init();
|
|
|
|
void StartAdvertising();
|
|
|
|
int OnGAPEvent(ble_gap_event *event);
|
2020-04-23 14:57:53 -04:00
|
|
|
|
2020-04-25 07:09:47 -04:00
|
|
|
int OnDiscoveryEvent(uint16_t i, const ble_gatt_error *pError, const ble_gatt_svc *pSvc);
|
2020-04-25 09:52:00 -04: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 15:58:31 -04:00
|
|
|
|
|
|
|
void StartDiscovery();
|
2020-07-11 16:37:28 -04:00
|
|
|
|
|
|
|
Pinetime::Controllers::MusicService& music() {return musicService;};
|
|
|
|
|
2020-07-20 16:28:21 -04:00
|
|
|
uint16_t connHandle();
|
|
|
|
|
2020-04-19 15:26:09 -04:00
|
|
|
private:
|
|
|
|
static constexpr char* deviceName = "Pinetime-JF";
|
2020-04-25 07:09:47 -04:00
|
|
|
Pinetime::System::SystemTask& systemTask;
|
2020-04-27 14:13:27 -04:00
|
|
|
Pinetime::Controllers::Ble& bleController;
|
2020-04-22 14:19:36 -04:00
|
|
|
DateTime& dateTimeController;
|
2020-04-25 07:09:47 -04:00
|
|
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
2020-05-11 12:50:37 -04:00
|
|
|
Pinetime::Drivers::SpiNorFlash& spiNorFlash;
|
2020-05-02 08:16:57 -04:00
|
|
|
Pinetime::Controllers::DfuService dfuService;
|
2020-04-25 07:09:47 -04:00
|
|
|
|
2020-04-23 14:34:38 -04:00
|
|
|
DeviceInformationService deviceInformationService;
|
2020-04-23 14:57:53 -04:00
|
|
|
CurrentTimeClient currentTimeClient;
|
2020-04-28 13:39:26 -04:00
|
|
|
AlertNotificationService anService;
|
2020-04-25 07:09:47 -04:00
|
|
|
AlertNotificationClient alertNotificationClient;
|
2020-05-04 16:43:51 -04:00
|
|
|
CurrentTimeService currentTimeService;
|
2020-07-11 16:37:28 -04:00
|
|
|
MusicService musicService;
|
2020-04-28 13:39:26 -04:00
|
|
|
|
2020-06-08 15:51:34 -04:00
|
|
|
uint8_t addrType; // 1 = Random, 0 = PUBLIC
|
2020-07-20 16:28:21 -04:00
|
|
|
uint16_t connectionHandle = 0;
|
2020-04-27 14:16:03 -04: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 15:26:09 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|