Remove unnecessary C-style casts with BLE UUIDs
Instead of casting the UUID object to the ble_uuid_t* used throughout the NimBLE API just pass the address of the ble_uuid_t member that's at the start of each of the UUID structs.
This commit is contained in:
parent
1ba99d2427
commit
487ae478ad
|
@ -55,7 +55,7 @@ bool AlertNotificationClient::OnDiscoveryEvent(uint16_t connectionHandle, const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service != nullptr && ble_uuid_cmp(((ble_uuid_t*) &ansServiceUuid), &service->uuid.u) == 0) {
|
if (service != nullptr && ble_uuid_cmp(&ansServiceUuid.u, &service->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS discovered : 0x%x - 0x%x", service->start_handle, service->end_handle);
|
NRF_LOG_INFO("ANS discovered : 0x%x - 0x%x", service->start_handle, service->end_handle);
|
||||||
ansStartHandle = service->start_handle;
|
ansStartHandle = service->start_handle;
|
||||||
ansEndHandle = service->end_handle;
|
ansEndHandle = service->end_handle;
|
||||||
|
@ -80,21 +80,21 @@ int AlertNotificationClient::OnCharacteristicsDiscoveryEvent(uint16_t connection
|
||||||
} else
|
} else
|
||||||
onServiceDiscovered(connectionHandle);
|
onServiceDiscovered(connectionHandle);
|
||||||
} else {
|
} else {
|
||||||
if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) &supportedNewAlertCategoryUuid), &characteristic->uuid.u) == 0) {
|
if (characteristic != nullptr && ble_uuid_cmp(&supportedNewAlertCategoryUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS Characteristic discovered : supportedNewAlertCategoryUuid");
|
NRF_LOG_INFO("ANS Characteristic discovered : supportedNewAlertCategoryUuid");
|
||||||
supportedNewAlertCategoryHandle = characteristic->val_handle;
|
supportedNewAlertCategoryHandle = characteristic->val_handle;
|
||||||
} else if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) &supportedUnreadAlertCategoryUuid), &characteristic->uuid.u) == 0) {
|
} else if (characteristic != nullptr && ble_uuid_cmp(&supportedUnreadAlertCategoryUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS Characteristic discovered : supportedUnreadAlertCategoryUuid");
|
NRF_LOG_INFO("ANS Characteristic discovered : supportedUnreadAlertCategoryUuid");
|
||||||
supportedUnreadAlertCategoryHandle = characteristic->val_handle;
|
supportedUnreadAlertCategoryHandle = characteristic->val_handle;
|
||||||
} else if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) &newAlertUuid), &characteristic->uuid.u) == 0) {
|
} else if (characteristic != nullptr && ble_uuid_cmp(&newAlertUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS Characteristic discovered : newAlertUuid");
|
NRF_LOG_INFO("ANS Characteristic discovered : newAlertUuid");
|
||||||
newAlertHandle = characteristic->val_handle;
|
newAlertHandle = characteristic->val_handle;
|
||||||
newAlertDefHandle = characteristic->def_handle;
|
newAlertDefHandle = characteristic->def_handle;
|
||||||
isCharacteristicDiscovered = true;
|
isCharacteristicDiscovered = true;
|
||||||
} else if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) &unreadAlertStatusUuid), &characteristic->uuid.u) == 0) {
|
} else if (characteristic != nullptr && ble_uuid_cmp(&unreadAlertStatusUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS Characteristic discovered : unreadAlertStatusUuid");
|
NRF_LOG_INFO("ANS Characteristic discovered : unreadAlertStatusUuid");
|
||||||
unreadAlertStatusHandle = characteristic->val_handle;
|
unreadAlertStatusHandle = characteristic->val_handle;
|
||||||
} else if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) &controlPointUuid), &characteristic->uuid.u) == 0) {
|
} else if (characteristic != nullptr && ble_uuid_cmp(&controlPointUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("ANS Characteristic discovered : controlPointUuid");
|
NRF_LOG_INFO("ANS Characteristic discovered : controlPointUuid");
|
||||||
controlPointHandle = characteristic->val_handle;
|
controlPointHandle = characteristic->val_handle;
|
||||||
} else
|
} else
|
||||||
|
@ -119,7 +119,7 @@ int AlertNotificationClient::OnDescriptorDiscoveryEventCallback(uint16_t connect
|
||||||
uint16_t characteristicValueHandle,
|
uint16_t characteristicValueHandle,
|
||||||
const ble_gatt_dsc* descriptor) {
|
const ble_gatt_dsc* descriptor) {
|
||||||
if (error->status == 0) {
|
if (error->status == 0) {
|
||||||
if (characteristicValueHandle == newAlertHandle && ble_uuid_cmp(((ble_uuid_t*) &newAlertUuid), &descriptor->uuid.u)) {
|
if (characteristicValueHandle == newAlertHandle && ble_uuid_cmp(&newAlertUuid.u, &descriptor->uuid.u)) {
|
||||||
if (newAlertDescriptorHandle == 0) {
|
if (newAlertDescriptorHandle == 0) {
|
||||||
NRF_LOG_INFO("ANS Descriptor discovered : %d", descriptor->handle);
|
NRF_LOG_INFO("ANS Descriptor discovered : %d", descriptor->handle);
|
||||||
newAlertDescriptorHandle = descriptor->handle;
|
newAlertDescriptorHandle = descriptor->handle;
|
||||||
|
|
|
@ -26,11 +26,8 @@ void AlertNotificationService::Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertNotificationService::AlertNotificationService(System::SystemTask& systemTask, NotificationManager& notificationManager)
|
AlertNotificationService::AlertNotificationService(System::SystemTask& systemTask, NotificationManager& notificationManager)
|
||||||
: characteristicDefinition {{.uuid = (ble_uuid_t*) &ansCharUuid,
|
: characteristicDefinition {{.uuid = &ansCharUuid.u, .access_cb = AlertNotificationCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE},
|
||||||
.access_cb = AlertNotificationCallback,
|
{.uuid = ¬ificationEventUuid.u,
|
||||||
.arg = this,
|
|
||||||
.flags = BLE_GATT_CHR_F_WRITE},
|
|
||||||
{.uuid = (ble_uuid_t*) ¬ificationEventUuid,
|
|
||||||
.access_cb = AlertNotificationCallback,
|
.access_cb = AlertNotificationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_NOTIFY,
|
.flags = BLE_GATT_CHR_F_NOTIFY,
|
||||||
|
@ -39,7 +36,7 @@ AlertNotificationService::AlertNotificationService(System::SystemTask& systemTas
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &ansUuid,
|
.uuid = &ansUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
},
|
},
|
||||||
|
@ -123,4 +120,4 @@ void AlertNotificationService::MuteIncomingCall() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ble_gattc_notify_custom(connectionHandle, eventHandle, om);
|
ble_gattc_notify_custom(connectionHandle, eventHandle, om);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ int BatteryInformationServiceCallback(uint16_t conn_handle, uint16_t attr_handle
|
||||||
|
|
||||||
BatteryInformationService::BatteryInformationService(Controllers::Battery& batteryController)
|
BatteryInformationService::BatteryInformationService(Controllers::Battery& batteryController)
|
||||||
: batteryController {batteryController},
|
: batteryController {batteryController},
|
||||||
characteristicDefinition {{.uuid = (ble_uuid_t*) &batteryLevelUuid,
|
characteristicDefinition {{.uuid = &batteryLevelUuid.u,
|
||||||
.access_cb = BatteryInformationServiceCallback,
|
.access_cb = BatteryInformationServiceCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
|
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
|
||||||
|
@ -23,7 +23,7 @@ BatteryInformationService::BatteryInformationService(Controllers::Battery& batte
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &batteryInformationServiceUuid,
|
.uuid = &batteryInformationServiceUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -47,7 +47,7 @@ bool CurrentTimeClient::OnDiscoveryEvent(uint16_t connectionHandle, const ble_ga
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service != nullptr && ble_uuid_cmp(((ble_uuid_t*) &ctsServiceUuid), &service->uuid.u) == 0) {
|
if (service != nullptr && ble_uuid_cmp(&ctsServiceUuid.u, &service->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("CTS discovered : 0x%x - 0x%x", service->start_handle, service->end_handle);
|
NRF_LOG_INFO("CTS discovered : 0x%x - 0x%x", service->start_handle, service->end_handle);
|
||||||
isDiscovered = true;
|
isDiscovered = true;
|
||||||
ctsStartHandle = service->start_handle;
|
ctsStartHandle = service->start_handle;
|
||||||
|
@ -72,7 +72,7 @@ int CurrentTimeClient::OnCharacteristicDiscoveryEvent(uint16_t conn_handle,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (characteristic != nullptr && ble_uuid_cmp(((ble_uuid_t*) ¤tTimeCharacteristicUuid), &characteristic->uuid.u) == 0) {
|
if (characteristic != nullptr && ble_uuid_cmp(¤tTimeCharacteristicUuid.u, &characteristic->uuid.u) == 0) {
|
||||||
NRF_LOG_INFO("CTS Characteristic discovered : 0x%x", characteristic->val_handle);
|
NRF_LOG_INFO("CTS Characteristic discovered : 0x%x", characteristic->val_handle);
|
||||||
isCharacteristicDiscovered = true;
|
isCharacteristicDiscovered = true;
|
||||||
currentTimeHandle = characteristic->val_handle;
|
currentTimeHandle = characteristic->val_handle;
|
||||||
|
|
|
@ -53,7 +53,7 @@ int CurrentTimeService::OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handl
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentTimeService::CurrentTimeService(DateTime& dateTimeController)
|
CurrentTimeService::CurrentTimeService(DateTime& dateTimeController)
|
||||||
: characteristicDefinition {{.uuid = (ble_uuid_t*) &ctChrUuid,
|
: characteristicDefinition {{.uuid = &ctChrUuid.u,
|
||||||
.access_cb = CTSCallback,
|
.access_cb = CTSCallback,
|
||||||
|
|
||||||
.arg = this,
|
.arg = this,
|
||||||
|
@ -62,7 +62,7 @@ CurrentTimeService::CurrentTimeService(DateTime& dateTimeController)
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &ctsUuid,
|
.uuid = &ctsUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
},
|
},
|
||||||
|
|
|
@ -56,37 +56,37 @@ int DeviceInformationService::OnDeviceInfoRequested(uint16_t conn_handle, uint16
|
||||||
|
|
||||||
DeviceInformationService::DeviceInformationService()
|
DeviceInformationService::DeviceInformationService()
|
||||||
: characteristicDefinition {{
|
: characteristicDefinition {{
|
||||||
.uuid = (ble_uuid_t*) &manufacturerNameUuid,
|
.uuid = &manufacturerNameUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &modelNumberUuid,
|
.uuid = &modelNumberUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &serialNumberUuid,
|
.uuid = &serialNumberUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &fwRevisionUuid,
|
.uuid = &fwRevisionUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &hwRevisionUuid,
|
.uuid = &hwRevisionUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &swRevisionUuid,
|
.uuid = &swRevisionUuid.u,
|
||||||
.access_cb = DeviceInformationCallback,
|
.access_cb = DeviceInformationCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
|
@ -95,7 +95,7 @@ DeviceInformationService::DeviceInformationService()
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &deviceInfoUuid,
|
.uuid = &deviceInfoUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -33,21 +33,21 @@ DfuService::DfuService(Pinetime::System::SystemTask& systemTask,
|
||||||
bleController {bleController},
|
bleController {bleController},
|
||||||
dfuImage {spiNorFlash},
|
dfuImage {spiNorFlash},
|
||||||
characteristicDefinition {{
|
characteristicDefinition {{
|
||||||
.uuid = (ble_uuid_t*) &packetCharacteristicUuid,
|
.uuid = &packetCharacteristicUuid.u,
|
||||||
.access_cb = DfuServiceCallback,
|
.access_cb = DfuServiceCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
||||||
.val_handle = nullptr,
|
.val_handle = nullptr,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &controlPointCharacteristicUuid,
|
.uuid = &controlPointCharacteristicUuid.u,
|
||||||
.access_cb = DfuServiceCallback,
|
.access_cb = DfuServiceCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_NOTIFY,
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_NOTIFY,
|
||||||
.val_handle = nullptr,
|
.val_handle = nullptr,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.uuid = (ble_uuid_t*) &revisionCharacteristicUuid,
|
.uuid = &revisionCharacteristicUuid.u,
|
||||||
.access_cb = DfuServiceCallback,
|
.access_cb = DfuServiceCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ,
|
.flags = BLE_GATT_CHR_F_READ,
|
||||||
|
@ -60,7 +60,7 @@ DfuService::DfuService(Pinetime::System::SystemTask& systemTask,
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &serviceUuid,
|
.uuid = &serviceUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
} {
|
} {
|
||||||
|
@ -81,9 +81,9 @@ int DfuService::OnServiceData(uint16_t connectionHandle, uint16_t attributeHandl
|
||||||
xTimerStart(timeoutTimer, 0);
|
xTimerStart(timeoutTimer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ble_gatts_find_chr((ble_uuid_t*) &serviceUuid, (ble_uuid_t*) &packetCharacteristicUuid, nullptr, &packetCharacteristicHandle);
|
ble_gatts_find_chr(&serviceUuid.u, &packetCharacteristicUuid.u, nullptr, &packetCharacteristicHandle);
|
||||||
ble_gatts_find_chr((ble_uuid_t*) &serviceUuid, (ble_uuid_t*) &controlPointCharacteristicUuid, nullptr, &controlPointCharacteristicHandle);
|
ble_gatts_find_chr(&serviceUuid.u, &controlPointCharacteristicUuid.u, nullptr, &controlPointCharacteristicHandle);
|
||||||
ble_gatts_find_chr((ble_uuid_t*) &serviceUuid, (ble_uuid_t*) &revisionCharacteristicUuid, nullptr, &revisionCharacteristicHandle);
|
ble_gatts_find_chr(&serviceUuid.u, &revisionCharacteristicUuid.u, nullptr, &revisionCharacteristicHandle);
|
||||||
|
|
||||||
if (attributeHandle == packetCharacteristicHandle) {
|
if (attributeHandle == packetCharacteristicHandle) {
|
||||||
if (context->op == BLE_GATT_ACCESS_OP_WRITE_CHR)
|
if (context->op == BLE_GATT_ACCESS_OP_WRITE_CHR)
|
||||||
|
@ -164,10 +164,10 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
|
||||||
|
|
||||||
if ((nbPacketReceived % nbPacketsToNotify) == 0 && bytesReceived != applicationSize) {
|
if ((nbPacketReceived % nbPacketsToNotify) == 0 && bytesReceived != applicationSize) {
|
||||||
uint8_t data[5] {static_cast<uint8_t>(Opcodes::PacketReceiptNotification),
|
uint8_t data[5] {static_cast<uint8_t>(Opcodes::PacketReceiptNotification),
|
||||||
(uint8_t) (bytesReceived & 0x000000FFu),
|
(uint8_t)(bytesReceived & 0x000000FFu),
|
||||||
(uint8_t) (bytesReceived >> 8u),
|
(uint8_t)(bytesReceived >> 8u),
|
||||||
(uint8_t) (bytesReceived >> 16u),
|
(uint8_t)(bytesReceived >> 16u),
|
||||||
(uint8_t) (bytesReceived >> 24u)};
|
(uint8_t)(bytesReceived >> 24u)};
|
||||||
NRF_LOG_INFO("[DFU] -> Send packet notification: %d bytes received", bytesReceived);
|
NRF_LOG_INFO("[DFU] -> Send packet notification: %d bytes received", bytesReceived);
|
||||||
notificationManager.Send(connectionHandle, controlPointCharacteristicHandle, data, 5);
|
notificationManager.Send(connectionHandle, controlPointCharacteristicHandle, data, 5);
|
||||||
}
|
}
|
||||||
|
@ -422,9 +422,9 @@ uint16_t DfuService::DfuImage::ComputeCrc(uint8_t const* p_data, uint32_t size,
|
||||||
uint16_t crc = (p_crc == NULL) ? 0xFFFF : *p_crc;
|
uint16_t crc = (p_crc == NULL) ? 0xFFFF : *p_crc;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < size; i++) {
|
for (uint32_t i = 0; i < size; i++) {
|
||||||
crc = (uint8_t) (crc >> 8) | (crc << 8);
|
crc = (uint8_t)(crc >> 8) | (crc << 8);
|
||||||
crc ^= p_data[i];
|
crc ^= p_data[i];
|
||||||
crc ^= (uint8_t) (crc & 0xFF) >> 4;
|
crc ^= (uint8_t)(crc & 0xFF) >> 4;
|
||||||
crc ^= (crc << 8) << 4;
|
crc ^= (crc << 8) << 4;
|
||||||
crc ^= ((crc & 0xFF) << 4) << 1;
|
crc ^= ((crc & 0xFF) << 4) << 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace {
|
||||||
HeartRateService::HeartRateService(Pinetime::System::SystemTask& system, Controllers::HeartRateController& heartRateController)
|
HeartRateService::HeartRateService(Pinetime::System::SystemTask& system, Controllers::HeartRateController& heartRateController)
|
||||||
: system {system},
|
: system {system},
|
||||||
heartRateController {heartRateController},
|
heartRateController {heartRateController},
|
||||||
characteristicDefinition {{.uuid = (ble_uuid_t*) &heartRateMeasurementUuid,
|
characteristicDefinition {{.uuid = &heartRateMeasurementUuid.u,
|
||||||
.access_cb = HeartRateServiceServiceCallback,
|
.access_cb = HeartRateServiceServiceCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
|
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
|
||||||
|
@ -27,7 +27,7 @@ HeartRateService::HeartRateService(Pinetime::System::SystemTask& system, Control
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &heartRateServiceUuid,
|
.uuid = &heartRateServiceUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -32,7 +32,7 @@ ImmediateAlertService::ImmediateAlertService(Pinetime::System::SystemTask& syste
|
||||||
Pinetime::Controllers::NotificationManager& notificationManager)
|
Pinetime::Controllers::NotificationManager& notificationManager)
|
||||||
: systemTask {systemTask},
|
: systemTask {systemTask},
|
||||||
notificationManager {notificationManager},
|
notificationManager {notificationManager},
|
||||||
characteristicDefinition {{.uuid = (ble_uuid_t*) &alertLevelUuid,
|
characteristicDefinition {{.uuid = &alertLevelUuid.u,
|
||||||
.access_cb = AlertLevelCallback,
|
.access_cb = AlertLevelCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
||||||
|
@ -41,7 +41,7 @@ ImmediateAlertService::ImmediateAlertService(Pinetime::System::SystemTask& syste
|
||||||
serviceDefinition {
|
serviceDefinition {
|
||||||
{/* Device Information Service */
|
{/* Device Information Service */
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t*) &immediateAlertServiceUuid,
|
.uuid = &immediateAlertServiceUuid.u,
|
||||||
.characteristics = characteristicDefinition},
|
.characteristics = characteristicDefinition},
|
||||||
{0},
|
{0},
|
||||||
} {
|
} {
|
||||||
|
@ -72,4 +72,4 @@ int ImmediateAlertService::OnAlertLevelChanged(uint16_t connectionHandle, uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,24 +50,18 @@ Pinetime::Controllers::NavigationService::NavigationService(Pinetime::System::Sy
|
||||||
navProgressCharUuid.value[15] = navId[1];
|
navProgressCharUuid.value[15] = navId[1];
|
||||||
|
|
||||||
characteristicDefinition[0] = {
|
characteristicDefinition[0] = {
|
||||||
.uuid = (ble_uuid_t*) (&navFlagCharUuid), .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
.uuid = &navFlagCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
||||||
|
|
||||||
characteristicDefinition[1] = {.uuid = (ble_uuid_t*) (&navNarrativeCharUuid),
|
characteristicDefinition[1] = {
|
||||||
.access_cb = NAVCallback,
|
.uuid = &navNarrativeCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
||||||
.arg = this,
|
characteristicDefinition[2] = {
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
.uuid = &navManDistCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
||||||
characteristicDefinition[2] = {.uuid = (ble_uuid_t*) (&navManDistCharUuid),
|
characteristicDefinition[3] = {
|
||||||
.access_cb = NAVCallback,
|
.uuid = &navProgressCharUuid.u, .access_cb = NAVCallback, .arg = this, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
||||||
.arg = this,
|
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
|
||||||
characteristicDefinition[3] = {.uuid = (ble_uuid_t*) (&navProgressCharUuid),
|
|
||||||
.access_cb = NAVCallback,
|
|
||||||
.arg = this,
|
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ};
|
|
||||||
|
|
||||||
characteristicDefinition[4] = {0};
|
characteristicDefinition[4] = {0};
|
||||||
|
|
||||||
serviceDefinition[0] = {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = (ble_uuid_t*) &navUuid, .characteristics = characteristicDefinition};
|
serviceDefinition[0] = {.type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &navUuid.u, .characteristics = characteristicDefinition};
|
||||||
serviceDefinition[1] = {0};
|
serviceDefinition[1] = {0};
|
||||||
|
|
||||||
m_progress = 0;
|
m_progress = 0;
|
||||||
|
@ -90,13 +84,13 @@ int Pinetime::Controllers::NavigationService::OnCommand(uint16_t conn_handle, ui
|
||||||
data[notifSize] = '\0';
|
data[notifSize] = '\0';
|
||||||
os_mbuf_copydata(ctxt->om, 0, notifSize, data);
|
os_mbuf_copydata(ctxt->om, 0, notifSize, data);
|
||||||
char* s = (char*) &data[0];
|
char* s = (char*) &data[0];
|
||||||
if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t*) &navFlagCharUuid) == 0) {
|
if (ble_uuid_cmp(ctxt->chr->uuid, &navFlagCharUuid.u) == 0) {
|
||||||
m_flag = s;
|
m_flag = s;
|
||||||
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t*) &navNarrativeCharUuid) == 0) {
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, &navNarrativeCharUuid.u) == 0) {
|
||||||
m_narrative = s;
|
m_narrative = s;
|
||||||
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t*) &navManDistCharUuid) == 0) {
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, &navManDistCharUuid.u) == 0) {
|
||||||
m_manDist = s;
|
m_manDist = s;
|
||||||
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t*) &navProgressCharUuid) == 0) {
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, &navProgressCharUuid.u) == 0) {
|
||||||
m_progress = data[0];
|
m_progress = data[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue