Compare commits
2 Commits
rei/develo
...
hid
Author | SHA1 | Date |
---|---|---|
JF | cdbcff1a99 | |
JF | e805570984 |
|
@ -89,6 +89,9 @@ set(SDK_SOURCE_FILES
|
|||
set(TINYCRYPT_SRC
|
||||
libs/mynewt-nimble/ext/tinycrypt/src/aes_encrypt.c
|
||||
libs/mynewt-nimble/ext/tinycrypt/src/utils.c
|
||||
libs/mynewt-nimble/ext/tinycrypt/src/ecc.c
|
||||
libs/mynewt-nimble/ext/tinycrypt/src/cmac_mode.c
|
||||
libs/mynewt-nimble/ext/tinycrypt/src/ecc_dh.c
|
||||
)
|
||||
|
||||
set(NIMBLE_SRC
|
||||
|
@ -161,6 +164,10 @@ set(NIMBLE_SRC
|
|||
libs/mynewt-nimble/nimble/host/services/gap/src/ble_svc_gap.c
|
||||
libs/mynewt-nimble/nimble/host/services/gatt/src/ble_svc_gatt.c
|
||||
libs/mynewt-nimble/nimble/host/util/src/addr.c
|
||||
libs/mynewt-nimble/nimble/host/src/ble_sm.c
|
||||
libs/mynewt-nimble/nimble/host/src/ble_sm_sc.c
|
||||
libs/mynewt-nimble/nimble/host/src/ble_sm_alg.c
|
||||
|
||||
)
|
||||
|
||||
set(LVGL_SRC
|
||||
|
@ -339,6 +346,9 @@ list(APPEND SOURCE_FILES
|
|||
DisplayApp/Screens/Label.cpp
|
||||
DisplayApp/Screens/FirmwareUpdate.cpp
|
||||
DisplayApp/Screens/Music.cpp
|
||||
Components/Ble/HidService.cpp
|
||||
Components/Ble/BatteryInformationService.cpp
|
||||
Components/Ble/BleMouse.cpp
|
||||
DisplayApp/Screens/FirmwareValidation.cpp
|
||||
DisplayApp/Screens/ApplicationList.cpp
|
||||
main.cpp
|
||||
|
@ -434,6 +444,8 @@ set(INCLUDE_FILES
|
|||
Components/Ble/CurrentTimeClient.h
|
||||
Components/Ble/AlertNotificationClient.h
|
||||
Components/Ble/DfuService.h
|
||||
Components/Ble/BleMouse.h
|
||||
|
||||
Components/FirmwareValidator/FirmwareValidator.h
|
||||
drivers/Cst816s.h
|
||||
FreeRTOS/portmacro.h
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
#include "BatteryInformationService.h"
|
||||
|
||||
using namespace Pinetime::Controllers;
|
||||
|
||||
constexpr ble_uuid16_t BatteryInformationService::batteryInformationServiceUuid;
|
||||
constexpr ble_uuid16_t BatteryInformationService::batteryLevelUuid;
|
||||
|
||||
|
||||
|
||||
int BatteryInformationServiceCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
|
||||
auto* batteryInformationService = static_cast<BatteryInformationService*>(arg);
|
||||
return batteryInformationService->OnBatteryServiceRequested(conn_handle, attr_handle, ctxt);
|
||||
}
|
||||
|
||||
BatteryInformationService::BatteryInformationService() :
|
||||
characteristicDefinition{
|
||||
{
|
||||
.uuid = (ble_uuid_t *) &batteryLevelUuid,
|
||||
.access_cb = BatteryInformationServiceCallback,
|
||||
.arg = this,
|
||||
.flags = BLE_GATT_CHR_F_READ,
|
||||
.val_handle = &batteryLevelHandle
|
||||
},
|
||||
{
|
||||
0
|
||||
}
|
||||
},
|
||||
serviceDefinition{
|
||||
{
|
||||
/* Device Information Service */
|
||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||
.uuid = (ble_uuid_t *) &batteryInformationServiceUuid,
|
||||
.characteristics = characteristicDefinition
|
||||
},
|
||||
{
|
||||
0
|
||||
},
|
||||
}{
|
||||
|
||||
}
|
||||
|
||||
void BatteryInformationService::Init() {
|
||||
int res = 0;
|
||||
res = ble_gatts_count_cfg(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
|
||||
res = ble_gatts_add_svcs(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
}
|
||||
|
||||
int BatteryInformationService::OnBatteryServiceRequested(uint16_t connectionHandle, uint16_t attributeHandle,
|
||||
ble_gatt_access_ctxt *context) {
|
||||
if(attributeHandle == batteryLevelHandle) {
|
||||
NRF_LOG_INFO("BATTERY : handle = %d", batteryLevelHandle);
|
||||
static uint8_t batteryValue = 50;
|
||||
int res = os_mbuf_append(context->om, &batteryValue, 1);
|
||||
return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
#pragma once
|
||||
#include <host/ble_gap.h>
|
||||
|
||||
namespace Pinetime {
|
||||
namespace System {
|
||||
class SystemTask;
|
||||
}
|
||||
namespace Controllers {
|
||||
class BatteryInformationService {
|
||||
public:
|
||||
BatteryInformationService();
|
||||
void Init();
|
||||
|
||||
int
|
||||
OnBatteryServiceRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context);
|
||||
|
||||
private:
|
||||
static constexpr uint16_t batteryInformationServiceId {0x180F};
|
||||
static constexpr uint16_t batteryLevelId {0x2A19};
|
||||
|
||||
static constexpr ble_uuid16_t batteryInformationServiceUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = batteryInformationServiceId
|
||||
};
|
||||
|
||||
static constexpr ble_uuid16_t batteryLevelUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = batteryLevelId
|
||||
};
|
||||
|
||||
struct ble_gatt_chr_def characteristicDefinition[3];
|
||||
struct ble_gatt_svc_def serviceDefinition[2];
|
||||
|
||||
uint16_t batteryLevelHandle;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
#include "BleMouse.h"
|
||||
#include "HidService.h"
|
||||
|
||||
using namespace Pinetime::Controllers;
|
||||
|
||||
BleMouse::BleMouse(HidService& hidService) : hidService{hidService} {
|
||||
|
||||
}
|
||||
|
||||
void BleMouse::Move(uint8_t x, uint8_t y) {
|
||||
hidService.SendMoveReport(x, y);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
class HidService;
|
||||
class BleMouse {
|
||||
public:
|
||||
explicit BleMouse(HidService& hidService);
|
||||
|
||||
void Move(uint8_t x, uint8_t y);
|
||||
|
||||
private:
|
||||
HidService& hidService;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -8,6 +8,7 @@ constexpr ble_uuid16_t DeviceInformationService::serialNumberUuid;
|
|||
constexpr ble_uuid16_t DeviceInformationService::fwRevisionUuid;
|
||||
constexpr ble_uuid16_t DeviceInformationService::deviceInfoUuid;
|
||||
constexpr ble_uuid16_t DeviceInformationService::hwRevisionUuid;
|
||||
constexpr ble_uuid16_t DeviceInformationService::pnpIdUuid;;
|
||||
|
||||
int DeviceInformationCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
|
||||
auto deviceInformationService = static_cast<DeviceInformationService*>(arg);
|
||||
|
@ -27,7 +28,7 @@ void DeviceInformationService::Init() {
|
|||
int DeviceInformationService::OnDeviceInfoRequested(uint16_t conn_handle, uint16_t attr_handle,
|
||||
struct ble_gatt_access_ctxt *ctxt) {
|
||||
const char *str;
|
||||
|
||||
size_t size = 0;
|
||||
switch (ble_uuid_u16(ctxt->chr->uuid)) {
|
||||
case manufacturerNameId:
|
||||
str = manufacturerName;
|
||||
|
@ -44,11 +45,15 @@ int DeviceInformationService::OnDeviceInfoRequested(uint16_t conn_handle, uint16
|
|||
case hwRevisionId:
|
||||
str = hwRevision;
|
||||
break;
|
||||
case pnpIdId:
|
||||
str = reinterpret_cast<const char *>(pnpIdBuf);
|
||||
size = 7;
|
||||
break;
|
||||
default:
|
||||
return BLE_ATT_ERR_UNLIKELY;
|
||||
}
|
||||
|
||||
int res = os_mbuf_append(ctxt->om, str, strlen(str));
|
||||
int res = os_mbuf_append(ctxt->om, str, (size!=0) ? size : strlen(str));
|
||||
return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
|
||||
}
|
||||
|
||||
|
@ -84,6 +89,12 @@ DeviceInformationService::DeviceInformationService() :
|
|||
.arg = this,
|
||||
.flags = BLE_GATT_CHR_F_READ,
|
||||
},
|
||||
{
|
||||
.uuid = (ble_uuid_t *) &pnpIdUuid,
|
||||
.access_cb = DeviceInformationCallback,
|
||||
.arg = this,
|
||||
.flags = BLE_GATT_CHR_F_READ,
|
||||
},
|
||||
{
|
||||
0
|
||||
}
|
||||
|
|
|
@ -21,12 +21,14 @@ namespace Pinetime {
|
|||
static constexpr uint16_t serialNumberId {0x2a25};
|
||||
static constexpr uint16_t fwRevisionId {0x2a26};
|
||||
static constexpr uint16_t hwRevisionId {0x2a27};
|
||||
static constexpr uint16_t pnpIdId {0x2a50};
|
||||
|
||||
static constexpr const char* manufacturerName = "Codingfield";
|
||||
static constexpr const char* modelNumber = "1";
|
||||
static constexpr const char* serialNumber = "9.8.7.6.5.4";
|
||||
static constexpr const char* fwRevision = "0.7.0";
|
||||
static constexpr const char* hwRevision = "1.0.0";
|
||||
uint8_t pnpIdBuf[7] {0x02, 0xc4, 0x10, 0x01, 0x00, 0x01, 0x00};
|
||||
|
||||
static constexpr ble_uuid16_t deviceInfoUuid {
|
||||
.u { .type = BLE_UUID_TYPE_16 },
|
||||
|
@ -58,7 +60,12 @@ namespace Pinetime {
|
|||
.value = hwRevisionId
|
||||
};
|
||||
|
||||
struct ble_gatt_chr_def characteristicDefinition[6];
|
||||
static constexpr ble_uuid16_t pnpIdUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = pnpIdId
|
||||
};
|
||||
|
||||
struct ble_gatt_chr_def characteristicDefinition[7];
|
||||
struct ble_gatt_svc_def serviceDefinition[2];
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,416 @@
|
|||
#include "HidService.h"
|
||||
|
||||
using namespace Pinetime::Controllers;
|
||||
|
||||
constexpr ble_uuid16_t HidService::hidServiceUuid;
|
||||
constexpr ble_uuid16_t HidService::protocolModeUuid;
|
||||
constexpr ble_uuid16_t HidService::reportUuid;
|
||||
constexpr ble_uuid16_t HidService::reportMapUuid;
|
||||
constexpr ble_uuid16_t HidService::bootKeyboardInputReportUuid;
|
||||
constexpr ble_uuid16_t HidService::bootKeyboardOutputReportUuid;
|
||||
constexpr ble_uuid16_t HidService::bootMouseInputReportUuid;
|
||||
constexpr ble_uuid16_t HidService::informationUuid;
|
||||
constexpr ble_uuid16_t HidService::controlPointUuid;
|
||||
constexpr ble_uuid16_t HidService::descriptorUuid;
|
||||
constexpr ble_uuid16_t HidService::descriptorMapUuid;
|
||||
|
||||
namespace {
|
||||
char* OperationToString(uint8_t op) {
|
||||
char* operation;
|
||||
switch(op) {
|
||||
case BLE_GATT_ACCESS_OP_READ_CHR: operation = "READ CHR"; break;
|
||||
case BLE_GATT_ACCESS_OP_WRITE_CHR: operation = "WRITE CHR"; break;
|
||||
case BLE_GATT_ACCESS_OP_READ_DSC: operation = "READ DSC"; break;
|
||||
case BLE_GATT_ACCESS_OP_WRITE_DSC: operation = "WRITE DSC"; break;
|
||||
default: operation = "?"; break;
|
||||
}
|
||||
return operation;
|
||||
}
|
||||
|
||||
int HidServiceCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
|
||||
auto* hidService = static_cast<HidService*>(arg);
|
||||
return hidService->OnHidServiceRequested(conn_handle, attr_handle, ctxt);
|
||||
}
|
||||
|
||||
int HidServiceReportDescriptorCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
|
||||
auto* hidService = static_cast<HidService*>(arg);
|
||||
return hidService->OnReportDescriptorRequested(conn_handle, attr_handle, ctxt);
|
||||
}
|
||||
|
||||
int HidServiceReportMouseDescriptorCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
|
||||
auto* hidService = static_cast<HidService*>(arg);
|
||||
return hidService->OnReportDescriptorMouseRequested(conn_handle, attr_handle, ctxt);
|
||||
}
|
||||
|
||||
|
||||
int HidServiceReportMapDescriptorCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
|
||||
auto* hidService = static_cast<HidService*>(arg);
|
||||
return hidService->OnReportMapDescriptorRequested(conn_handle, attr_handle, ctxt);
|
||||
}
|
||||
|
||||
|
||||
static const uint8_t report_map_data[] =
|
||||
{0x05, 0x01, // Usage Pg (Generic Desktop)
|
||||
0x09, 0x06, // Usage (Keyboard)
|
||||
0xA1, 0x01, // Collection: (Application)
|
||||
0x85, 0x01, // Report Id (1)
|
||||
//
|
||||
0x05, 0x07, // Usage Pg (Key Codes)
|
||||
0x19, 0xE0, // Usage Min (224)
|
||||
0x29, 0xE7, // Usage Max (231)
|
||||
0x15, 0x00, // Log Min (0)
|
||||
0x25, 0x01, // Log Max (1)
|
||||
//
|
||||
// Modifier byte
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x95, 0x08, // Report Count (8)
|
||||
0x81, 0x02, // Input: (Data, Variable, Absolute)
|
||||
//
|
||||
// Reserved byte
|
||||
0x95, 0x01, // Report Count (1)
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x81, 0x01, // Input: (Constant)
|
||||
//
|
||||
// LED report
|
||||
0x95, 0x05, // Report Count (5)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x05, 0x08, // Usage Pg (LEDs)
|
||||
0x19, 0x01, // Usage Min (1)
|
||||
0x29, 0x05, // Usage Max (5)
|
||||
0x91, 0x02, // Output: (Data, Variable, Absolute)
|
||||
//
|
||||
// LED report padding
|
||||
0x95, 0x01, // Report Count (1)
|
||||
0x75, 0x03, // Report Size (3)
|
||||
0x91, 0x01, // Output: (Constant)
|
||||
//
|
||||
// Key arrays (6 bytes)
|
||||
0x95, 0x06, // Report Count (6)
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x15, 0x00, // Log Min (0)
|
||||
0x25, 0x65, // Log Max (101)
|
||||
0x05, 0x07, // Usage Pg (Key Codes)
|
||||
0x19, 0x00, // Usage Min (0)
|
||||
0x29, 0x65, // Usage Max (101)
|
||||
0x81, 0x00, // Input: (Data, Array)
|
||||
//
|
||||
0xC0, // End Collection
|
||||
|
||||
|
||||
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0
|
||||
0x09, 0x02, // USAGE (Mouse) 2
|
||||
0xa1, 0x01, // COLLECTION (Application) 4
|
||||
0x85, 0x02, // REPORT_ID (Mouse) 6
|
||||
0x09, 0x01, // USAGE (Pointer) 8
|
||||
0xa1, 0x00, // COLLECTION (Physical) 10
|
||||
0x05, 0x09, // USAGE_PAGE (Button) 12
|
||||
0x19, 0x01, // USAGE_MINIMUM (Button 1) 14
|
||||
0x29, 0x02, // USAGE_MAXIMUM (Button 2) 16
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0) 18
|
||||
0x25, 0x01, // LOGICAL_MAXIMUM (1) 20
|
||||
0x75, 0x01, // REPORT_SIZE (1) 22
|
||||
0x95, 0x02, // REPORT_COUNT (2) 24
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs) 26
|
||||
0x95, 0x06, // REPORT_COUNT (6) 28
|
||||
0x81, 0x03, // INPUT (Cnst,Var,Abs) 30
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop) 32
|
||||
0x09, 0x30, // USAGE (X) 34
|
||||
0x09, 0x31, // USAGE (Y) 36
|
||||
0x15, 0x81, // LOGICAL_MINIMUM (-127) 38
|
||||
0x25, 0x7f, // LOGICAL_MAXIMUM (127) 40
|
||||
0x75, 0x08, // REPORT_SIZE (8) 42
|
||||
0x95, 0x02, // REPORT_COUNT (2) 44
|
||||
0x81, 0x06, // INPUT (Data,Var,Rel) 46
|
||||
0xc0, // END_COLLECTION 48
|
||||
0xc0 // END_COLLECTION 49/50
|
||||
};
|
||||
}
|
||||
|
||||
HidService::HidService() :
|
||||
reportInDescriptorDefinition {
|
||||
{
|
||||
.uuid = (const ble_uuid_t *) &descriptorUuid,
|
||||
.att_flags = 5,
|
||||
.access_cb = HidServiceCallback,
|
||||
},
|
||||
{0}
|
||||
},
|
||||
reportOutDescriptorDefinition {
|
||||
{
|
||||
.uuid = (const ble_uuid_t *) &descriptorUuid,
|
||||
.att_flags = 5,
|
||||
.access_cb = HidServiceCallback,
|
||||
},
|
||||
{0}
|
||||
},
|
||||
reportKeyboardDescriptorDefinition{{
|
||||
.uuid = (const ble_uuid_t *) &descriptorUuid,
|
||||
.att_flags = 5,
|
||||
.access_cb = HidServiceReportDescriptorCallback,
|
||||
}, {0}
|
||||
},
|
||||
reportMouseDescriptorDefinition{{
|
||||
.uuid = (const ble_uuid_t *) &descriptorUuid,
|
||||
.att_flags = 5,
|
||||
.access_cb = HidServiceReportMouseDescriptorCallback,
|
||||
}, {0}
|
||||
},
|
||||
reportMapDescriptorDefinitions{
|
||||
{
|
||||
.uuid = (const ble_uuid_t *) &descriptorMapUuid,
|
||||
.att_flags = 5,
|
||||
.access_cb = HidServiceReportMapDescriptorCallback,
|
||||
},{0}
|
||||
},
|
||||
characteristicDefinition{
|
||||
{
|
||||
.uuid = (ble_uuid_t *) &protocolModeUuid,
|
||||
.access_cb = HidServiceCallback,
|
||||
.arg = this,
|
||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_WRITE_NO_RSP,
|
||||
.val_handle = &protocolModeHandle
|
||||
|
||||
},
|
||||
{
|
||||
.uuid = (ble_uuid_t *) &reportUuid,
|
||||
.access_cb = HidServiceCallback,
|
||||
.arg = this,
|
||||
.descriptors = reportKeyboardDescriptorDefinition,
|
||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY | BLE_GATT_CHR_F_WRITE,
|
||||
.val_handle = &reportKeyboardHandle
|
||||
},
|
||||
{
|
||||
.uuid = (ble_uuid_t *) &reportUuid,
|
||||
.access_cb = HidServiceCallback,
|
||||
.arg = this,
|
||||
.descriptors = reportMouseDescriptorDefinition,
|
||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY | BLE_GATT_CHR_F_WRITE,
|
||||
.val_handle = &reportMouseHandle
|
||||
},
|
||||
{
|
||||
.uuid = (ble_uuid_t *) &reportMapUuid,
|
||||
.access_cb = HidServiceCallback,
|
||||
.arg = this,
|
||||
.descriptors = reportMapDescriptorDefinitions,
|
||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_ENC,
|
||||
.val_handle = &reportMapHandle
|
||||
},
|
||||
/*{
|
||||
.uuid = (ble_uuid_t *) &bootKeyboardInputReportUuid,
|
||||
.access_cb = HidServiceCallback,
|
||||
.arg = this,
|
||||
.descriptors = reportInDescriptorDefinition,
|
||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
|
||||
},
|
||||
{
|
||||
.uuid = (ble_uuid_t *) &bootKeyboardOutputReportUuid,
|
||||
.access_cb = HidServiceCallback,
|
||||
.arg = this,
|
||||
.descriptors = reportOutDescriptorDefinition,
|
||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_WRITE_NO_RSP,
|
||||
},
|
||||
{
|
||||
.uuid = (ble_uuid_t *) &bootMouseInputReportUuid,
|
||||
.access_cb = HidServiceCallback,
|
||||
.arg = this,
|
||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
|
||||
},*/
|
||||
{
|
||||
.uuid = (ble_uuid_t *) &informationUuid,
|
||||
.access_cb = HidServiceCallback,
|
||||
.arg = this,
|
||||
.flags = BLE_GATT_CHR_F_READ,
|
||||
.val_handle = &informationHandle
|
||||
},
|
||||
{
|
||||
.uuid = (ble_uuid_t *) &controlPointUuid,
|
||||
.access_cb = HidServiceCallback,
|
||||
.arg = this,
|
||||
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
||||
.val_handle = &controlPointHandle
|
||||
},
|
||||
{
|
||||
0
|
||||
}
|
||||
},
|
||||
serviceDefinition{
|
||||
{
|
||||
/* Device Information Service */
|
||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||
.uuid = (ble_uuid_t *) &hidServiceUuid,
|
||||
.characteristics = characteristicDefinition
|
||||
},
|
||||
{
|
||||
0
|
||||
},
|
||||
}{
|
||||
|
||||
}
|
||||
|
||||
void HidService::Init() {
|
||||
int res = 0;
|
||||
res = ble_gatts_count_cfg(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
|
||||
res = ble_gatts_add_svcs(serviceDefinition);
|
||||
ASSERT(res == 0);
|
||||
asm("nop");
|
||||
}
|
||||
|
||||
int
|
||||
HidService::OnHidServiceRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context) {
|
||||
char* operation = ::OperationToString(context->op);
|
||||
|
||||
int res = 0;
|
||||
char* attribute;
|
||||
if(attributeHandle == protocolModeHandle) {
|
||||
attribute = "protocolModeHandle";
|
||||
static uint8_t protcoleModeValue = 1;
|
||||
res = os_mbuf_append(context->om, &protcoleModeValue, 1);
|
||||
} else if(attributeHandle == reportKeyboardHandle) {
|
||||
attribute = "reportHandle";
|
||||
} else if(attributeHandle == reportMapHandle) {
|
||||
attribute = "reportMapHandle";
|
||||
res = os_mbuf_append(context->om, &report_map_data, sizeof(report_map_data));
|
||||
}
|
||||
else if(attributeHandle == informationHandle) {
|
||||
attribute = "informationHandle";
|
||||
static uint32_t infoValue = 0x01110002;
|
||||
res = os_mbuf_append(context->om, &infoValue, 4);
|
||||
|
||||
}
|
||||
else if(attributeHandle == controlPointHandle) {
|
||||
attribute = "controlPointHandle";
|
||||
}
|
||||
else {
|
||||
attribute = "???";
|
||||
}
|
||||
|
||||
NRF_LOG_INFO("HID : Attribute = %d = %s, operation = %s",attributeHandle, attribute, operation);
|
||||
return res;
|
||||
}
|
||||
|
||||
int HidService::OnReportDescriptorRequested(uint16_t connectionHandle, uint16_t attributeHandle,
|
||||
ble_gatt_access_ctxt *context) {
|
||||
NRF_LOG_INFO("HID : Attribute = %d = Callback report descriptor, operation = %s",attributeHandle, ::OperationToString(context->op));
|
||||
int res = 0;
|
||||
static uint16_t reportValue = 0x0101;
|
||||
|
||||
res = os_mbuf_append(context->om, &reportValue, 2);
|
||||
return res;
|
||||
}
|
||||
|
||||
int HidService::OnReportDescriptorMouseRequested(uint16_t connectionHandle, uint16_t attributeHandle,
|
||||
ble_gatt_access_ctxt *context) {
|
||||
NRF_LOG_INFO("HID : Attribute = %d = Callback report descriptor Mouse, operation = %s",attributeHandle, ::OperationToString(context->op));
|
||||
int res = 0;
|
||||
static uint16_t reportValue = 0x0102;
|
||||
|
||||
res = os_mbuf_append(context->om, &reportValue, 2);
|
||||
return res;
|
||||
}
|
||||
|
||||
int HidService::OnReportMapDescriptorRequested(uint16_t connectionHandle, uint16_t attributeHandle,
|
||||
ble_gatt_access_ctxt *context) {
|
||||
NRF_LOG_INFO("HID : Attribute = %d = Callback report map descriptor, operation = %s",attributeHandle, ::OperationToString(context->op));
|
||||
int res = 0;
|
||||
static uint16_t externalReportValue = 0x0036;
|
||||
|
||||
res = os_mbuf_append(context->om, &externalReportValue, 2);
|
||||
return res;
|
||||
}
|
||||
|
||||
uint8_t helloWorld[] {
|
||||
0x0b,
|
||||
0x08,
|
||||
0x0f,
|
||||
0x0f,
|
||||
0x12,
|
||||
0x2c,
|
||||
0x1d,
|
||||
0x12,
|
||||
0x15,
|
||||
0x0f,
|
||||
0x07,
|
||||
0x25
|
||||
};
|
||||
uint8_t testIndex = 0;
|
||||
bool push = true;
|
||||
void HidService::Test() {
|
||||
# if 0
|
||||
uint8_t modif = (testIndex == 0) ? (1<<1) : 0;
|
||||
if(push && testIndex < 12) {
|
||||
uint8_t buf[9]{modif, 0x0, 0x00, helloWorld[testIndex], 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
auto *om = ble_hs_mbuf_from_flat(&buf, 9);
|
||||
|
||||
uint16_t connectionHandle = 1;
|
||||
|
||||
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
|
||||
return;
|
||||
}
|
||||
ble_gattc_notify_custom(1, reportKeyboardHandle, om);
|
||||
testIndex++;
|
||||
push = false;
|
||||
NRF_LOG_INFO("PUSH %d %d", helloWorld[testIndex], modif);
|
||||
} else {
|
||||
static uint8_t buf[9]{0, 0x0, 0x00, 0, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
auto *om = ble_hs_mbuf_from_flat(&buf, 9);
|
||||
|
||||
uint16_t connectionHandle = 1;
|
||||
|
||||
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
|
||||
return;
|
||||
}
|
||||
ble_gattc_notify_custom(1, reportKeyboardHandle, om);
|
||||
NRF_LOG_INFO("Release");
|
||||
push = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if(testIndex%2 == 0) {
|
||||
uint8_t buf[3]{0, 2, 0};
|
||||
auto *om = ble_hs_mbuf_from_flat(&buf, 3);
|
||||
|
||||
uint16_t connectionHandle = 1;
|
||||
|
||||
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
|
||||
return;
|
||||
}
|
||||
ble_gattc_notify_custom(1, reportMouseHandle, om);
|
||||
testIndex++;
|
||||
push = false;
|
||||
NRF_LOG_INFO("UNPUSH");
|
||||
} else {
|
||||
uint8_t buf[3]{0, 0, 2};
|
||||
auto *om = ble_hs_mbuf_from_flat(&buf, 3);
|
||||
|
||||
uint16_t connectionHandle = 1;
|
||||
|
||||
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
|
||||
return;
|
||||
}
|
||||
ble_gattc_notify_custom(1, reportMouseHandle, om);
|
||||
testIndex++;
|
||||
push = false;
|
||||
NRF_LOG_INFO("PUSH");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void HidService::SendMoveReport(uint8_t x, uint8_t y) {
|
||||
uint8_t buf[3]{0, x, y};
|
||||
auto *om = ble_hs_mbuf_from_flat(&buf, 3);
|
||||
|
||||
uint16_t connectionHandle = 1;
|
||||
|
||||
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
|
||||
return;
|
||||
}
|
||||
ble_gattc_notify_custom(1, reportMouseHandle, om);
|
||||
NRF_LOG_INFO("move");
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
#pragma once
|
||||
#include <host/ble_gap.h>
|
||||
|
||||
namespace Pinetime {
|
||||
namespace System {
|
||||
class SystemTask;
|
||||
}
|
||||
namespace Controllers {
|
||||
class HidService {
|
||||
public:
|
||||
HidService();
|
||||
void Init();
|
||||
|
||||
int OnHidServiceRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context);
|
||||
|
||||
int OnReportDescriptorRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context);
|
||||
int OnReportDescriptorMouseRequested(uint16_t connectionHandle, uint16_t attributeHandle, ble_gatt_access_ctxt *context);
|
||||
|
||||
int OnReportMapDescriptorRequested(uint16_t connectionHandle, uint16_t attributeHandle,
|
||||
ble_gatt_access_ctxt *context);
|
||||
|
||||
void Test();
|
||||
|
||||
void SendMoveReport(uint8_t x, uint8_t y);
|
||||
|
||||
private:
|
||||
static constexpr uint16_t hidServiceId {0x1812};
|
||||
static constexpr uint16_t protocolModeId {0x2A4E};
|
||||
static constexpr uint16_t reportId {0x2A4D};
|
||||
static constexpr uint16_t reportMapId {0x2A4B};
|
||||
static constexpr uint16_t bootKeyboardInputReportId {0x2A22};
|
||||
static constexpr uint16_t bootKeyboardOutputReportId {0x2A32};
|
||||
static constexpr uint16_t bootMouseInputReportId {0x2A33};
|
||||
static constexpr uint16_t informationId {0x2A4A};
|
||||
static constexpr uint16_t controlPointId {0x2A4C};
|
||||
|
||||
static constexpr uint16_t descriptorId {0x2908};
|
||||
static constexpr uint16_t reportMapDescriptorId {0x2907};
|
||||
|
||||
static constexpr ble_uuid16_t hidServiceUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = hidServiceId
|
||||
};
|
||||
|
||||
static constexpr ble_uuid16_t protocolModeUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = protocolModeId
|
||||
};
|
||||
|
||||
static constexpr ble_uuid16_t reportUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = reportId
|
||||
};
|
||||
|
||||
static constexpr ble_uuid16_t reportMapUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = reportMapId
|
||||
};
|
||||
|
||||
static constexpr ble_uuid16_t bootKeyboardInputReportUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = bootKeyboardInputReportId
|
||||
};
|
||||
|
||||
static constexpr ble_uuid16_t bootKeyboardOutputReportUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = bootKeyboardOutputReportId
|
||||
};
|
||||
|
||||
static constexpr ble_uuid16_t bootMouseInputReportUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = bootMouseInputReportId
|
||||
};
|
||||
|
||||
static constexpr ble_uuid16_t informationUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = informationId
|
||||
};
|
||||
|
||||
static constexpr ble_uuid16_t controlPointUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = controlPointId
|
||||
};
|
||||
|
||||
static constexpr ble_uuid16_t descriptorUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = descriptorId
|
||||
};
|
||||
|
||||
|
||||
static constexpr ble_uuid16_t descriptorMapUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = reportMapDescriptorId
|
||||
};
|
||||
|
||||
|
||||
struct ble_gatt_dsc_def reportInDescriptorDefinition[2];
|
||||
struct ble_gatt_dsc_def reportOutDescriptorDefinition[2];
|
||||
struct ble_gatt_dsc_def reportKeyboardDescriptorDefinition[2];
|
||||
struct ble_gatt_dsc_def reportMouseDescriptorDefinition[2];
|
||||
struct ble_gatt_dsc_def reportMapDescriptorDefinitions[2];
|
||||
struct ble_gatt_chr_def characteristicDefinition[9];
|
||||
struct ble_gatt_svc_def serviceDefinition[2];
|
||||
|
||||
uint16_t protocolModeHandle;
|
||||
uint16_t reportKeyboardHandle;
|
||||
uint16_t reportMouseHandle;
|
||||
uint16_t reportMapHandle;
|
||||
uint16_t informationHandle;
|
||||
uint16_t controlPointHandle;
|
||||
|
||||
char *OperationToString(uint8_t op);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,8 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
|
|||
anService{systemTask, notificationManager},
|
||||
alertNotificationClient{systemTask, notificationManager},
|
||||
currentTimeService{dateTimeController},
|
||||
musicService{systemTask} {
|
||||
musicService{systemTask},
|
||||
hidService{}{
|
||||
|
||||
}
|
||||
|
||||
|
@ -83,6 +84,8 @@ void NimbleController::Init() {
|
|||
currentTimeClient.Init();
|
||||
currentTimeService.Init();
|
||||
musicService.Init();
|
||||
hidService.Init();
|
||||
batteryInformationService.Init();
|
||||
|
||||
anService.Init();
|
||||
|
||||
|
@ -133,7 +136,12 @@ void NimbleController::StartAdvertising() {
|
|||
fields.uuids128 = &dfuServiceUuid;
|
||||
fields.num_uuids128 = 1;
|
||||
fields.uuids128_is_complete = 1;
|
||||
fields.uuids16 = &hidServiceUuid;
|
||||
fields.num_uuids16 = 1;
|
||||
fields.uuids16_is_complete = 1;
|
||||
fields.tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO;
|
||||
fields.appearance = 962;
|
||||
fields.appearance_is_present = 1;
|
||||
|
||||
rsp_fields.name = (uint8_t *)"Pinetime-JF";
|
||||
rsp_fields.name_len = strlen("Pinetime-JF");
|
||||
|
@ -185,6 +193,7 @@ int NimbleController::OnGAPEvent(ble_gap_event *event) {
|
|||
bleController.Connect();
|
||||
systemTask.PushMessage(Pinetime::System::SystemTask::Messages::BleConnected);
|
||||
connectionHandle = event->connect.conn_handle;
|
||||
ble_gap_security_initiate(connectionHandle);
|
||||
// Service discovery is deffered via systemtask
|
||||
}
|
||||
}
|
||||
|
@ -332,3 +341,7 @@ uint16_t NimbleController::connHandle() {
|
|||
return connectionHandle;
|
||||
}
|
||||
|
||||
void NimbleController::Test() {
|
||||
hidService.Test();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include "DfuService.h"
|
||||
#include "CurrentTimeService.h"
|
||||
#include "MusicService.h"
|
||||
#include "HidService.h"
|
||||
#include "BatteryInformationService.h"
|
||||
#include <host/ble_gap.h>
|
||||
|
||||
namespace Pinetime {
|
||||
|
@ -42,6 +44,10 @@ namespace Pinetime {
|
|||
|
||||
uint16_t connHandle();
|
||||
|
||||
void Test();
|
||||
|
||||
HidService& GetHidService() { return hidService;}
|
||||
|
||||
private:
|
||||
static constexpr const char* deviceName = "Pinetime-JF";
|
||||
Pinetime::System::SystemTask& systemTask;
|
||||
|
@ -57,6 +63,8 @@ namespace Pinetime {
|
|||
AlertNotificationClient alertNotificationClient;
|
||||
CurrentTimeService currentTimeService;
|
||||
MusicService musicService;
|
||||
HidService hidService;
|
||||
BatteryInformationService batteryInformationService;
|
||||
|
||||
uint8_t addrType; // 1 = Random, 0 = PUBLIC
|
||||
uint16_t connectionHandle = 0;
|
||||
|
@ -66,6 +74,11 @@ namespace Pinetime {
|
|||
.value = {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15,
|
||||
0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00}
|
||||
};
|
||||
|
||||
ble_uuid16_t hidServiceUuid {
|
||||
.u {.type = BLE_UUID_TYPE_16},
|
||||
.value = 0x1812
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver
|
|||
Controllers::Battery &batteryController, Controllers::Ble &bleController,
|
||||
Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog,
|
||||
System::SystemTask &systemTask,
|
||||
Pinetime::Controllers::NotificationManager& notificationManager) :
|
||||
Pinetime::Controllers::NotificationManager& notificationManager,
|
||||
Controllers::BleMouse& bleMouse) :
|
||||
lcd{lcd},
|
||||
lvgl{lvgl},
|
||||
batteryController{batteryController},
|
||||
|
@ -34,6 +35,7 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver
|
|||
dateTimeController{dateTimeController},
|
||||
watchdog{watchdog},
|
||||
touchPanel{touchPanel},
|
||||
bleMouse{bleMouse},
|
||||
currentScreen{new Screens::Clock(this, dateTimeController, batteryController, bleController) },
|
||||
systemTask{systemTask},
|
||||
notificationManager{notificationManager} {
|
||||
|
@ -197,7 +199,7 @@ void DisplayApp::RunningState() {
|
|||
case Apps::SysInfo: currentScreen.reset(new Screens::SystemInfo(this, dateTimeController, batteryController, brightnessController, bleController, watchdog)); break;
|
||||
case Apps::Meter: currentScreen.reset(new Screens::Meter(this)); break;
|
||||
case Apps::Gauge: currentScreen.reset(new Screens::Gauge(this)); break;
|
||||
case Apps::Paint: currentScreen.reset(new Screens::InfiniPaint(this, lvgl)); break;
|
||||
case Apps::Paint: currentScreen.reset(new Screens::InfiniPaint(this, lvgl, bleMouse)); break;
|
||||
case Apps::Brightness : currentScreen.reset(new Screens::Brightness(this, brightnessController)); break;
|
||||
case Apps::Music : currentScreen.reset(new Screens::Music(this, systemTask.nimble().music())); break;
|
||||
case Apps::FirmwareValidation: currentScreen.reset(new Screens::FirmwareValidation(this, validator)); break;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <DisplayApp/Screens/Modal.h>
|
||||
#include <Components/Ble/NotificationManager.h>
|
||||
#include <Components/FirmwareValidator/FirmwareValidator.h>
|
||||
#include <Components/Ble/BleMouse.h>
|
||||
#include "TouchEvents.h"
|
||||
#include "Apps.h"
|
||||
|
||||
|
@ -40,7 +41,8 @@ namespace Pinetime {
|
|||
Controllers::Battery &batteryController, Controllers::Ble &bleController,
|
||||
Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog,
|
||||
System::SystemTask &systemTask,
|
||||
Pinetime::Controllers::NotificationManager& notificationManager);
|
||||
Pinetime::Controllers::NotificationManager& notificationManager,
|
||||
Controllers::BleMouse& bleMouse);
|
||||
void Start();
|
||||
void PushMessage(Messages msg);
|
||||
|
||||
|
@ -72,6 +74,7 @@ namespace Pinetime {
|
|||
|
||||
Pinetime::Drivers::Cst816S& touchPanel;
|
||||
TouchEvents OnTouchEvent();
|
||||
Controllers::BleMouse& bleMouse;
|
||||
|
||||
std::unique_ptr<Screens::Screen> currentScreen;
|
||||
|
||||
|
|
|
@ -7,7 +7,10 @@ using namespace Pinetime::Applications::Screens;
|
|||
extern lv_font_t jetbrains_mono_extrabold_compressed;
|
||||
extern lv_font_t jetbrains_mono_bold_20;
|
||||
|
||||
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp *app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl{lvgl} {
|
||||
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp *app,
|
||||
Pinetime::Components::LittleVgl& lvgl,
|
||||
Controllers::BleMouse& bleMouse) :
|
||||
Screen(app), lvgl{lvgl}, bleMouse{bleMouse} {
|
||||
app->SetTouchMode(DisplayApp::TouchModes::Polling);
|
||||
std::fill(b, b+bufferSize, LV_COLOR_WHITE);
|
||||
}
|
||||
|
@ -19,6 +22,10 @@ InfiniPaint::~InfiniPaint() {
|
|||
}
|
||||
|
||||
bool InfiniPaint::Refresh() {
|
||||
timeout--;
|
||||
if(timeout == 0) {
|
||||
moving = false;
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
|
@ -28,10 +35,13 @@ bool InfiniPaint::OnButtonPushed() {
|
|||
}
|
||||
|
||||
bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
NRF_LOG_INFO("TOUCH %d", event);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InfiniPaint::OnTouchEvent(uint16_t x, uint16_t y) {
|
||||
NRF_LOG_INFO("TOUCH %d, %d", x, y);
|
||||
|
||||
lv_area_t area;
|
||||
area.x1 = x-(width/2);
|
||||
area.y1 = y-(height/2);
|
||||
|
@ -39,6 +49,20 @@ bool InfiniPaint::OnTouchEvent(uint16_t x, uint16_t y) {
|
|||
area.y2 = y+(height/2)-1;
|
||||
lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::None);
|
||||
lvgl.FlushDisplay(&area, b);
|
||||
|
||||
if(!moving) {
|
||||
moving = true;
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
|
||||
} else {
|
||||
|
||||
bleMouse.Move((x - lastX)*2, (y - lastY)*2);
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
timeout = 20;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <libs/lvgl/src/lv_core/lv_obj.h>
|
||||
#include <drivers/St7789.h>
|
||||
#include <DisplayApp/LittleVgl.h>
|
||||
#include <Components/Ble/BleMouse.h>
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Applications {
|
||||
|
@ -14,7 +15,7 @@ namespace Pinetime {
|
|||
|
||||
class InfiniPaint : public Screen{
|
||||
public:
|
||||
InfiniPaint(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
|
||||
InfiniPaint(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl, Controllers::BleMouse& bleMouse);
|
||||
~InfiniPaint() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
@ -29,6 +30,12 @@ namespace Pinetime {
|
|||
static constexpr uint16_t bufferSize = width*height;
|
||||
lv_color_t b[bufferSize];
|
||||
bool running = true;
|
||||
Controllers::BleMouse& bleMouse;
|
||||
|
||||
bool moving = false;
|
||||
uint8_t lastX;
|
||||
uint8_t lastY;
|
||||
uint8_t timeout = 10;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ SystemTask::SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd,
|
|||
twiMaster{twiMaster}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController},
|
||||
bleController{bleController}, dateTimeController{dateTimeController},
|
||||
watchdog{}, watchdogView{watchdog}, notificationManager{notificationManager},
|
||||
nimbleController(*this, bleController,dateTimeController, notificationManager, spiNorFlash) {
|
||||
nimbleController(*this, bleController,dateTimeController, notificationManager, spiNorFlash),
|
||||
bleMouse{nimbleController.GetHidService()}{
|
||||
systemTaksMsgQueue = xQueueCreate(10, 1);
|
||||
}
|
||||
|
||||
|
@ -67,7 +68,7 @@ void SystemTask::Work() {
|
|||
batteryController.Init();
|
||||
|
||||
displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController,
|
||||
dateTimeController, watchdogView, *this, notificationManager));
|
||||
dateTimeController, watchdogView, *this, notificationManager, bleMouse));
|
||||
displayApp->Start();
|
||||
|
||||
batteryController.Update();
|
||||
|
@ -101,7 +102,7 @@ void SystemTask::Work() {
|
|||
|
||||
while(true) {
|
||||
uint8_t msg;
|
||||
if (xQueueReceive(systemTaksMsgQueue, &msg, isSleeping?2500 : 1000)) {
|
||||
if (xQueueReceive(systemTaksMsgQueue, &msg, isSleeping?100 : 100)) {
|
||||
Messages message = static_cast<Messages >(msg);
|
||||
switch(message) {
|
||||
case Messages::GoToRunning:
|
||||
|
@ -126,7 +127,7 @@ void SystemTask::Work() {
|
|||
case Messages::BleConnected:
|
||||
ReloadIdleTimer();
|
||||
isBleDiscoveryTimerRunning = true;
|
||||
bleDiscoveryTimer = 5;
|
||||
bleDiscoveryTimer = 50;
|
||||
break;
|
||||
case Messages::BleFirmwareUpdateStarted:
|
||||
doNotGoToSleep = true;
|
||||
|
@ -159,10 +160,12 @@ void SystemTask::Work() {
|
|||
|
||||
if(isBleDiscoveryTimerRunning) {
|
||||
if(bleDiscoveryTimer == 0) {
|
||||
isBleDiscoveryTimerRunning = false;
|
||||
//isBleDiscoveryTimerRunning = false;
|
||||
// Services discovery is deffered from 3 seconds to avoid the conflicts between the host communicating with the
|
||||
// tharget and vice-versa. I'm not sure if this is the right way to handle this...
|
||||
nimbleController.StartDiscovery();
|
||||
//nimbleController.StartDiscovery();
|
||||
nimbleController.Test();
|
||||
bleDiscoveryTimer = 0;
|
||||
} else {
|
||||
bleDiscoveryTimer--;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <DisplayApp/DisplayApp.h>
|
||||
#include <drivers/Watchdog.h>
|
||||
#include <drivers/SpiNorFlash.h>
|
||||
#include <Components/Ble/BleMouse.h>
|
||||
#include "SystemMonitor.h"
|
||||
#include "Components/Ble/NimbleController.h"
|
||||
#include "timers.h"
|
||||
|
@ -59,6 +60,7 @@ namespace Pinetime {
|
|||
Pinetime::Drivers::WatchdogView watchdogView;
|
||||
Pinetime::Controllers::NotificationManager& notificationManager;
|
||||
Pinetime::Controllers::NimbleController nimbleController;
|
||||
Pinetime::Controllers::BleMouse bleMouse;
|
||||
|
||||
|
||||
static constexpr uint8_t pinSpiSck = 2;
|
||||
|
|
|
@ -695,7 +695,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_BONDING
|
||||
#define MYNEWT_VAL_BLE_SM_BONDING (0)
|
||||
#define MYNEWT_VAL_BLE_SM_BONDING (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_IO_CAP
|
||||
|
@ -723,27 +723,27 @@
|
|||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_OUR_KEY_DIST
|
||||
#define MYNEWT_VAL_BLE_SM_OUR_KEY_DIST (0)
|
||||
#define MYNEWT_VAL_BLE_SM_OUR_KEY_DIST (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_SC
|
||||
#define MYNEWT_VAL_BLE_SM_SC (0)
|
||||
#define MYNEWT_VAL_BLE_SM_SC (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_SC_DEBUG_KEYS
|
||||
#define MYNEWT_VAL_BLE_SM_SC_DEBUG_KEYS (0)
|
||||
#define MYNEWT_VAL_BLE_SM_SC_DEBUG_KEYS (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_THEIR_KEY_DIST
|
||||
#define MYNEWT_VAL_BLE_SM_THEIR_KEY_DIST (0)
|
||||
#define MYNEWT_VAL_BLE_SM_THEIR_KEY_DIST (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_STORE_MAX_BONDS
|
||||
#define MYNEWT_VAL_BLE_STORE_MAX_BONDS (3)
|
||||
#define MYNEWT_VAL_BLE_STORE_MAX_BONDS (6)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_STORE_MAX_CCCDS
|
||||
#define MYNEWT_VAL_BLE_STORE_MAX_CCCDS (8)
|
||||
#define MYNEWT_VAL_BLE_STORE_MAX_CCCDS (20)
|
||||
#endif
|
||||
|
||||
/*** @apache-mynewt-nimble/nimble/host/services/ans */
|
||||
|
|
|
@ -46,6 +46,6 @@ nimble_port_freertos_init(TaskFunction_t host_task_fn)
|
|||
* have separate task for NimBLE host, but since something needs to handle
|
||||
* default queue it is just easier to make separate task which does this.
|
||||
*/
|
||||
xTaskCreate(host_task_fn, "ble", configMINIMAL_STACK_SIZE + 200,
|
||||
xTaskCreate(host_task_fn, "ble", configMINIMAL_STACK_SIZE + 300,
|
||||
NULL, tskIDLE_PRIORITY + 1, &host_task_h);
|
||||
}
|
||||
|
|
|
@ -8460,15 +8460,15 @@
|
|||
// <e> NRF_LOG_ENABLED - nrf_log - Logger
|
||||
//==========================================================
|
||||
#ifndef NRF_LOG_ENABLED
|
||||
#define NRF_LOG_ENABLED 0
|
||||
#define NRF_LOG_ENABLED 1
|
||||
#endif
|
||||
|
||||
#ifndef NRF_LOG_BACKEND_RTT_ENABLED
|
||||
#define NRF_LOG_BACKEND_RTT_ENABLED 0
|
||||
#define NRF_LOG_BACKEND_RTT_ENABLED 1
|
||||
#endif
|
||||
|
||||
#ifndef NRF_LOG_BACKEND_SERIAL_USES_RTT
|
||||
#define NRF_LOG_BACKEND_SERIAL_USES_RTT 0
|
||||
#define NRF_LOG_BACKEND_SERIAL_USES_RTT 1
|
||||
#endif
|
||||
// <h> Log message pool - Configuration of log message pool
|
||||
|
||||
|
|
Loading…
Reference in New Issue