From c63f739da1d8acc39c4a75177d01efcc04e0ba7e Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Tue, 2 Jan 2024 11:44:23 +0100 Subject: [PATCH] chore: apply clang-format (#241) --- hal_st/middlewares/CMakeLists.txt | 2 +- .../ble_middleware/BondStorageSt.hpp | 2 +- .../ble_middleware/GapCentralSt.cpp | 14 +- .../ble_middleware/GapPeripheralSt.cpp | 14 +- .../ble_middleware/GapPeripheralSt.hpp | 2 +- hal_st/middlewares/ble_middleware/GapSt.cpp | 165 +++++++++--------- hal_st/middlewares/ble_middleware/GapSt.hpp | 8 +- .../ble_middleware/GattClientSt.cpp | 123 ++++++++----- .../ble_middleware/GattClientSt.hpp | 2 +- .../ble_middleware/GattServerSt.cpp | 35 ++-- .../ble_middleware/SystemTransportLayer.cpp | 82 +++++---- .../ble_middleware/TracingGapCentralSt.cpp | 4 +- .../TracingSystemTransportLayer.cpp | 10 +- .../TracingSystemTransportLayer.hpp | 2 +- hal_st/stm32fxxx/UartStmDuplexDma.cpp | 48 +++-- 15 files changed, 291 insertions(+), 222 deletions(-) diff --git a/hal_st/middlewares/CMakeLists.txt b/hal_st/middlewares/CMakeLists.txt index 6890c622..6e805723 100644 --- a/hal_st/middlewares/CMakeLists.txt +++ b/hal_st/middlewares/CMakeLists.txt @@ -1,4 +1,4 @@ add_subdirectory(STM32_WPAN) add_subdirectory(ble_middleware) -emil_exclude_directory_from_clang_format(.) +emil_exclude_directory_from_clang_format(STM32_WPAN) diff --git a/hal_st/middlewares/ble_middleware/BondStorageSt.hpp b/hal_st/middlewares/ble_middleware/BondStorageSt.hpp index c4f473fb..6f246f94 100644 --- a/hal_st/middlewares/ble_middleware/BondStorageSt.hpp +++ b/hal_st/middlewares/ble_middleware/BondStorageSt.hpp @@ -5,7 +5,7 @@ extern "C" { - #include "ble_gap_aci.h" +#include "ble_gap_aci.h" } namespace hal diff --git a/hal_st/middlewares/ble_middleware/GapCentralSt.cpp b/hal_st/middlewares/ble_middleware/GapCentralSt.cpp index b46c5ca6..864be190 100644 --- a/hal_st/middlewares/ble_middleware/GapCentralSt.cpp +++ b/hal_st/middlewares/ble_middleware/GapCentralSt.cpp @@ -5,8 +5,7 @@ namespace hal { - const services::GapConnectionParameters GapCentralSt::connectionUpdateParameters - { + const services::GapConnectionParameters GapCentralSt::connectionUpdateParameters{ 6, // 7.5 ms 6, // 7.5 ms 0, @@ -46,7 +45,6 @@ namespace hal connectionUpdateParameters.minConnIntMultiplier, connectionUpdateParameters.maxConnIntMultiplier, connectionUpdateParameters.slaveLatency, connectionUpdateParameters.supervisorTimeoutMs, minConnectionEventLength, maxConnectionEventLength); - } void GapCentralSt::Disconnect() @@ -65,7 +63,10 @@ namespace hal { aci_gap_start_general_discovery_proc(leScanInterval, leScanWindow, GAP_RESOLVABLE_PRIVATE_ADDR, filterDuplicatesEnabled); discovering = true; - infra::Subject::NotifyObservers([](auto& observer) { observer.StateChanged(services::GapState::scanning); }); + infra::Subject::NotifyObservers([](auto& observer) + { + observer.StateChanged(services::GapState::scanning); + }); } } @@ -86,7 +87,10 @@ namespace hal { GapSt::HandleHciDisconnectEvent(eventPacket); - infra::Subject::NotifyObservers([](auto& observer) { observer.StateChanged(services::GapState::standby); }); + infra::Subject::NotifyObservers([](auto& observer) + { + observer.StateChanged(services::GapState::standby); + }); } void GapCentralSt::HandleHciLeAdvertisingReportEvent(evt_le_meta_event* metaEvent) diff --git a/hal_st/middlewares/ble_middleware/GapPeripheralSt.cpp b/hal_st/middlewares/ble_middleware/GapPeripheralSt.cpp index e687a544..39d4caaf 100644 --- a/hal_st/middlewares/ble_middleware/GapPeripheralSt.cpp +++ b/hal_st/middlewares/ble_middleware/GapPeripheralSt.cpp @@ -63,7 +63,7 @@ namespace hal void GapPeripheralSt::UpdateAdvertisementData() { - //First clear the data set by the aci_gap_set_discoverable call by default + // First clear the data set by the aci_gap_set_discoverable call by default aci_gap_delete_ad_type(AD_TYPE_TX_POWER_LEVEL); aci_gap_delete_ad_type(AD_TYPE_FLAGS); @@ -75,7 +75,13 @@ namespace hal void GapPeripheralSt::UpdateState(services::GapState newState) { state = newState; - infra::EventDispatcher::Instance().Schedule([this]() { GapPeripheral::NotifyObservers([this](auto& obs) { obs.StateChanged(state); }); }); + infra::EventDispatcher::Instance().Schedule([this]() + { + GapPeripheral::NotifyObservers([this](auto& obs) + { + obs.StateChanged(state); + }); + }); } void GapPeripheralSt::Advertise(services::GapAdvertisementType type, AdvertisementIntervalMultiplier multiplier) @@ -133,8 +139,8 @@ namespace hal { aci_gap_add_devices_to_resolving_list(numberOfBondedAddress, reinterpret_cast(bondedDevices.begin()), 1); - std::copy(std::begin(bondedDevices[numberOfBondedAddress-1].Address), std::end(bondedDevices[numberOfBondedAddress-1].Address), connectionContext.peerAddress.begin()); - connectionContext.peerAddressType = bondedDevices[numberOfBondedAddress-1].Address_Type; + std::copy(std::begin(bondedDevices[numberOfBondedAddress - 1].Address), std::end(bondedDevices[numberOfBondedAddress - 1].Address), connectionContext.peerAddress.begin()); + connectionContext.peerAddressType = bondedDevices[numberOfBondedAddress - 1].Address_Type; for (uint8_t i = 0; i < numberOfBondedAddress; i++) hci_le_set_privacy_mode(bondedDevices[i].Address_Type, bondedDevices[i].Address, HCI_PRIV_MODE_DEVICE); diff --git a/hal_st/middlewares/ble_middleware/GapPeripheralSt.hpp b/hal_st/middlewares/ble_middleware/GapPeripheralSt.hpp index 03bf397b..060dc769 100644 --- a/hal_st/middlewares/ble_middleware/GapPeripheralSt.hpp +++ b/hal_st/middlewares/ble_middleware/GapPeripheralSt.hpp @@ -46,7 +46,7 @@ namespace hal infra::BoundedVector::WithMaxSize advertisementData; infra::BoundedVector::WithMaxSize scanResponseData; - const Whitelist_Identity_Entry_t dummyPeer {0x01, {0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}}; + const Whitelist_Identity_Entry_t dummyPeer{ 0x01, { 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF } }; }; } diff --git a/hal_st/middlewares/ble_middleware/GapSt.cpp b/hal_st/middlewares/ble_middleware/GapSt.cpp index aee55cef..4511c9fc 100644 --- a/hal_st/middlewares/ble_middleware/GapSt.cpp +++ b/hal_st/middlewares/ble_middleware/GapSt.cpp @@ -77,34 +77,33 @@ namespace hal SHCI_C2_Ble_Init_Cmd_Packet_t bleInitCmdPacket = { { { 0, 0, 0 } }, // Header (unused) { - 0x00, // BLE buffer address (unused) - 0x00, // BLE buffer size (unused) - 0x44, // Maximum number of GATT Attributes - 0x08, // Maximum number of Services that can be stored in the GATT database - 0x540, // Size of the storage area for Attribute values + 0x00, // BLE buffer address (unused) + 0x00, // BLE buffer size (unused) + 0x44, // Maximum number of GATT Attributes + 0x08, // Maximum number of Services that can be stored in the GATT database + 0x540, // Size of the storage area for Attribute values maxNumberOfBleLinks, 0x01, // Enable or disable the Extended Packet length feature prepareWriteListSize, numberOfBleMemoryBlocks, configuration.maxAttMtuSize, - 0x1FA, // Sleep clock accuracy in Slave mode - 0x00, // Sleep clock accuracy in Master mode - RfWakeupClockSelection(configuration.rfWakeupClock), // Source for the low speed clock for RF wake-up - 0xFFFFFFFF, // Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) - 0x148, // Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) - 0x01, // Viterbi Mode + 0x1FA, // Sleep clock accuracy in Slave mode + 0x00, // Sleep clock accuracy in Master mode + RfWakeupClockSelection(configuration.rfWakeupClock), // Source for the low speed clock for RF wake-up + 0xFFFFFFFF, // Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) + 0x148, // Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) + 0x01, // Viterbi Mode bleStackOptions, - 0, // HW version (unused) - 32, // Maximum number of connection-oriented channels in initiator mode - -40, // Minimum transmit power in dBm supported by the Controller - 6, // Maximum transmit power in dBm supported by the Controller + 0, // HW version (unused) + 32, // Maximum number of connection-oriented channels in initiator mode + -40, // Minimum transmit power in dBm supported by the Controller + 6, // Maximum transmit power in dBm supported by the Controller SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY, - 3, // Maximum number of advertising sets. - 1650, // Maximum advertising data length (in bytes) - 0, // RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. - 0, // RF RX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. - SHCI_C2_BLE_INIT_BLE_CORE_5_3 - } + 3, // Maximum number of advertising sets. + 1650, // Maximum advertising data length (in bytes) + 0, // RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. + 0, // RF RX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. + SHCI_C2_BLE_INIT_BLE_CORE_5_3 } }; if (SHCI_C2_BLE_Init(&bleInitCmdPacket) != SHCI_Success) @@ -308,17 +307,17 @@ namespace hal { switch (event.evt) { - case HCI_DISCONNECTION_COMPLETE_EVT_CODE: - HandleHciDisconnectEvent(event); - break; - case HCI_LE_META_EVT_CODE: - HandleHciLeMetaEvent(event); - break; - case HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE: - HandleHciVendorSpecificDebugEvent(event); - break; - default: - break; + case HCI_DISCONNECTION_COMPLETE_EVT_CODE: + HandleHciDisconnectEvent(event); + break; + case HCI_LE_META_EVT_CODE: + HandleHciLeMetaEvent(event); + break; + case HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE: + HandleHciVendorSpecificDebugEvent(event); + break; + default: + break; } } @@ -328,26 +327,26 @@ namespace hal switch (metaEvent->subevent) { - case HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE: - HandleHciLeConnectionCompleteEvent(metaEvent); - break; - case HCI_LE_ADVERTISING_REPORT_SUBEVT_CODE: - HandleHciLeAdvertisingReportEvent(metaEvent); - break; - case HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE: - HandleHciLeConnectionUpdateCompleteEvent(metaEvent); - break; - case HCI_LE_DATA_LENGTH_CHANGE_SUBEVT_CODE: - HandleHciLeDataLengthChangeEvent(metaEvent); - break; - case HCI_LE_PHY_UPDATE_COMPLETE_SUBEVT_CODE: - HandleHciLePhyUpdateCompleteEvent(metaEvent); - break; - case HCI_LE_ENHANCED_CONNECTION_COMPLETE_SUBEVT_CODE: - HandleHciLeEnhancedConnectionCompleteEvent(metaEvent); - break; - default: - break; + case HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE: + HandleHciLeConnectionCompleteEvent(metaEvent); + break; + case HCI_LE_ADVERTISING_REPORT_SUBEVT_CODE: + HandleHciLeAdvertisingReportEvent(metaEvent); + break; + case HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE: + HandleHciLeConnectionUpdateCompleteEvent(metaEvent); + break; + case HCI_LE_DATA_LENGTH_CHANGE_SUBEVT_CODE: + HandleHciLeDataLengthChangeEvent(metaEvent); + break; + case HCI_LE_PHY_UPDATE_COMPLETE_SUBEVT_CODE: + HandleHciLePhyUpdateCompleteEvent(metaEvent); + break; + case HCI_LE_ENHANCED_CONNECTION_COMPLETE_SUBEVT_CODE: + HandleHciLeEnhancedConnectionCompleteEvent(metaEvent); + break; + default: + break; } } @@ -357,43 +356,43 @@ namespace hal switch (vendorEvent->ecode) { - case ACI_GAP_PAIRING_COMPLETE_VSEVT_CODE: - HandlePairingCompleteEvent(vendorEvent); - break; - case ACI_GAP_BOND_LOST_VSEVT_CODE: - HandleBondLostEvent(vendorEvent); - break; - case ACI_GAP_PROC_COMPLETE_VSEVT_CODE: - HandleGapProcedureCompleteEvent(vendorEvent); - break; - case ACI_GATT_PROC_COMPLETE_VSEVT_CODE: - HandleGattCompleteEvent(vendorEvent); - break; - case ACI_L2CAP_CONNECTION_UPDATE_REQ_VSEVT_CODE: - HandleL2capConnectionUpdateRequestEvent(vendorEvent); - break; - case ACI_ATT_EXCHANGE_MTU_RESP_VSEVT_CODE: - HandleMtuExchangeResponseEvent(vendorEvent); - break; - default: - break; + case ACI_GAP_PAIRING_COMPLETE_VSEVT_CODE: + HandlePairingCompleteEvent(vendorEvent); + break; + case ACI_GAP_BOND_LOST_VSEVT_CODE: + HandleBondLostEvent(vendorEvent); + break; + case ACI_GAP_PROC_COMPLETE_VSEVT_CODE: + HandleGapProcedureCompleteEvent(vendorEvent); + break; + case ACI_GATT_PROC_COMPLETE_VSEVT_CODE: + HandleGattCompleteEvent(vendorEvent); + break; + case ACI_L2CAP_CONNECTION_UPDATE_REQ_VSEVT_CODE: + HandleL2capConnectionUpdateRequestEvent(vendorEvent); + break; + case ACI_ATT_EXCHANGE_MTU_RESP_VSEVT_CODE: + HandleMtuExchangeResponseEvent(vendorEvent); + break; + default: + break; } } void GapSt::SetConnectionContext(uint16_t connectionHandle, uint8_t peerAddressType, uint8_t* peerAddress) { static constexpr auto deducePeerAddressType = [](auto peerAddressType) + { + enum class PeerAddressType : uint8_t { - enum class PeerAddressType : uint8_t - { - PUBLIC, - RANDOM, - RESOLVED_PUBLIC_IDENTITY, - RESOLVED_RANDOM_STATIC_IDENTITY - }; + PUBLIC, + RANDOM, + RESOLVED_PUBLIC_IDENTITY, + RESOLVED_RANDOM_STATIC_IDENTITY + }; - switch (static_cast(peerAddressType)) - { + switch (static_cast(peerAddressType)) + { case PeerAddressType::PUBLIC: case PeerAddressType::RANDOM: return peerAddressType; @@ -404,8 +403,8 @@ namespace hal case PeerAddressType::RESOLVED_RANDOM_STATIC_IDENTITY: default: return infra::enum_cast(PeerAddressType::RANDOM); - } - }; + } + }; connectionContext.connectionHandle = connectionHandle; connectionContext.peerAddressType = deducePeerAddressType(peerAddressType); diff --git a/hal_st/middlewares/ble_middleware/GapSt.hpp b/hal_st/middlewares/ble_middleware/GapSt.hpp index f27791ca..4012bc9f 100644 --- a/hal_st/middlewares/ble_middleware/GapSt.hpp +++ b/hal_st/middlewares/ble_middleware/GapSt.hpp @@ -75,10 +75,10 @@ namespace hal virtual void HandleHciDisconnectEvent(hci_event_pckt& eventPacket); virtual void HandleHciLeConnectionCompleteEvent(evt_le_meta_event* metaEvent); - virtual void HandleHciLeAdvertisingReportEvent(evt_le_meta_event* metaEvent) {}; - virtual void HandleHciLeConnectionUpdateCompleteEvent(evt_le_meta_event* metaEvent) {}; - virtual void HandleHciLeDataLengthChangeEvent(evt_le_meta_event* metaEvent) {}; - virtual void HandleHciLePhyUpdateCompleteEvent(evt_le_meta_event* metaEvent) {}; + virtual void HandleHciLeAdvertisingReportEvent(evt_le_meta_event* metaEvent){}; + virtual void HandleHciLeConnectionUpdateCompleteEvent(evt_le_meta_event* metaEvent){}; + virtual void HandleHciLeDataLengthChangeEvent(evt_le_meta_event* metaEvent){}; + virtual void HandleHciLePhyUpdateCompleteEvent(evt_le_meta_event* metaEvent){}; virtual void HandleHciLeEnhancedConnectionCompleteEvent(evt_le_meta_event* metaEvent); virtual void HandlePairingCompleteEvent(evt_blecore_aci* vendorEvent); diff --git a/hal_st/middlewares/ble_middleware/GattClientSt.cpp b/hal_st/middlewares/ble_middleware/GattClientSt.cpp index 2284689a..650d610c 100644 --- a/hal_st/middlewares/ble_middleware/GattClientSt.cpp +++ b/hal_st/middlewares/ble_middleware/GattClientSt.cpp @@ -19,21 +19,30 @@ namespace hal void GattClientSt::StartServiceDiscovery() { - onDiscoveryCompletion = [](services::GattClientDiscoveryObserver& observer) { observer.ServiceDiscoveryComplete(); }; + onDiscoveryCompletion = [](services::GattClientDiscoveryObserver& observer) + { + observer.ServiceDiscoveryComplete(); + }; aci_gatt_disc_all_primary_services(connectionHandle); } void GattClientSt::StartCharacteristicDiscovery(const services::GattService& service) { - onDiscoveryCompletion = [](services::GattClientDiscoveryObserver& observer) { observer.CharacteristicDiscoveryComplete(); }; + onDiscoveryCompletion = [](services::GattClientDiscoveryObserver& observer) + { + observer.CharacteristicDiscoveryComplete(); + }; aci_gatt_disc_all_char_of_service(connectionHandle, service.Handle(), service.EndHandle()); } void GattClientSt::StartDescriptorDiscovery(const services::GattService& service) { - onDiscoveryCompletion = [](services::GattClientDiscoveryObserver& observer) { observer.DescriptorDiscoveryComplete(); }; + onDiscoveryCompletion = [](services::GattClientDiscoveryObserver& observer) + { + observer.DescriptorDiscoveryComplete(); + }; aci_gatt_disc_all_char_desc(connectionHandle, service.Handle(), service.EndHandle()); } @@ -89,17 +98,17 @@ namespace hal { switch (event.evt) { - case HCI_DISCONNECTION_COMPLETE_EVT_CODE: - HandleHciDisconnectEvent(event); - break; - case HCI_LE_META_EVT_CODE: - HandleHciLeMetaEvent(event); - break; - case HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE: - HandleHciVendorSpecificDebugEvent(event); - break; - default: - break; + case HCI_DISCONNECTION_COMPLETE_EVT_CODE: + HandleHciDisconnectEvent(event); + break; + case HCI_LE_META_EVT_CODE: + HandleHciLeMetaEvent(event); + break; + case HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE: + HandleHciVendorSpecificDebugEvent(event); + break; + default: + break; } } @@ -109,14 +118,14 @@ namespace hal switch (metaEvent->subevent) { - case HCI_LE_ENHANCED_CONNECTION_COMPLETE_SUBEVT_CODE: - HandleHciLeEnhancedConnectionCompleteEvent(metaEvent); - break; - case HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE: - HandleHciLeConnectionCompleteEvent(metaEvent); - break; - default: - break; + case HCI_LE_ENHANCED_CONNECTION_COMPLETE_SUBEVT_CODE: + HandleHciLeEnhancedConnectionCompleteEvent(metaEvent); + break; + case HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE: + HandleHciLeConnectionCompleteEvent(metaEvent); + break; + default: + break; } } @@ -126,26 +135,26 @@ namespace hal switch (vendorEvent->ecode) { - case ACI_ATT_READ_BY_GROUP_TYPE_RESP_VSEVT_CODE: - HandleAttReadByGroupTypeResponse(vendorEvent); - break; - case ACI_ATT_READ_BY_TYPE_RESP_VSEVT_CODE: - HandleAttReadByTypeResponse(vendorEvent); - break; - case ACI_ATT_FIND_INFO_RESP_VSEVT_CODE: - HandleAttFindInfoResponse(vendorEvent); - break; - case ACI_GATT_PROC_COMPLETE_VSEVT_CODE: - HandleGattCompleteResponse(vendorEvent); - break; - case ACI_GATT_INDICATION_VSEVT_CODE: - HandleGattIndicationEvent(vendorEvent); - break; - case ACI_GATT_NOTIFICATION_VSEVT_CODE: - HandleGattNotificationEvent(vendorEvent); - break; - default: - break; + case ACI_ATT_READ_BY_GROUP_TYPE_RESP_VSEVT_CODE: + HandleAttReadByGroupTypeResponse(vendorEvent); + break; + case ACI_ATT_READ_BY_TYPE_RESP_VSEVT_CODE: + HandleAttReadByTypeResponse(vendorEvent); + break; + case ACI_ATT_FIND_INFO_RESP_VSEVT_CODE: + HandleAttFindInfoResponse(vendorEvent); + break; + case ACI_GATT_PROC_COMPLETE_VSEVT_CODE: + HandleGattCompleteResponse(vendorEvent); + break; + case ACI_GATT_INDICATION_VSEVT_CODE: + HandleGattIndicationEvent(vendorEvent); + break; + case ACI_GATT_NOTIFICATION_VSEVT_CODE: + HandleGattNotificationEvent(vendorEvent); + break; + default: + break; } } @@ -248,9 +257,15 @@ namespace hal really_assert(gattIndicationEvent.Connection_Handle == connectionHandle); - infra::Subject::NotifyObservers([&gattIndicationEvent, &data](auto& observer) { observer.UpdateReceived(gattIndicationEvent.Attribute_Handle, data); }); + infra::Subject::NotifyObservers([&gattIndicationEvent, &data](auto& observer) + { + observer.UpdateReceived(gattIndicationEvent.Attribute_Handle, data); + }); - infra::EventDispatcherWithWeakPtr::Instance().Schedule([this, &gattIndicationEvent]() { this->HandleGattConfirmIndication(gattIndicationEvent.Attribute_Handle); }); + infra::EventDispatcherWithWeakPtr::Instance().Schedule([this, &gattIndicationEvent]() + { + this->HandleGattConfirmIndication(gattIndicationEvent.Attribute_Handle); + }); } void GattClientSt::HandleGattNotificationEvent(evt_blecore_aci* vendorEvent) @@ -261,7 +276,10 @@ namespace hal really_assert(gattNotificationEvent.Connection_Handle == connectionHandle); - infra::Subject::NotifyObservers([&gattNotificationEvent, &data](auto& observer) { observer.UpdateReceived(gattNotificationEvent.Attribute_Handle, data); }); + infra::Subject::NotifyObservers([&gattNotificationEvent, &data](auto& observer) + { + observer.UpdateReceived(gattNotificationEvent.Attribute_Handle, data); + }); } void GattClientSt::HandleGattConfirmIndication(services::AttAttribute::Handle handle) @@ -281,7 +299,10 @@ namespace hal really_assert(!stream.Failed()); - infra::Subject::NotifyObservers([&attributes](auto& observer) { observer.ServiceDiscovered(attributes.type, attributes.startHandle, attributes.endHandle); }); + infra::Subject::NotifyObservers([&attributes](auto& observer) + { + observer.ServiceDiscovered(attributes.type, attributes.startHandle, attributes.endHandle); + }); } } @@ -297,7 +318,10 @@ namespace hal really_assert(!stream.Failed()); - infra::Subject::NotifyObservers([&attributes](auto& observer) { observer.CharacteristicDiscovered(attributes.type, attributes.startHandle, attributes.endHandle, attributes.properties); }); + infra::Subject::NotifyObservers([&attributes](auto& observer) + { + observer.CharacteristicDiscovered(attributes.type, attributes.startHandle, attributes.endHandle, attributes.properties); + }); } } @@ -313,7 +337,10 @@ namespace hal really_assert(!stream.Failed()); - infra::Subject::NotifyObservers([&attributes](auto& observer) { observer.DescriptorDiscovered(attributes.type, attributes.startHandle); }); + infra::Subject::NotifyObservers([&attributes](auto& observer) + { + observer.DescriptorDiscovered(attributes.type, attributes.startHandle); + }); } } diff --git a/hal_st/middlewares/ble_middleware/GattClientSt.hpp b/hal_st/middlewares/ble_middleware/GattClientSt.hpp index 0af7ecfa..64f164fa 100644 --- a/hal_st/middlewares/ble_middleware/GattClientSt.hpp +++ b/hal_st/middlewares/ble_middleware/GattClientSt.hpp @@ -3,9 +3,9 @@ #include "ble/ble.h" #include "hal_st/middlewares/ble_middleware/HciEventObserver.hpp" +#include "infra/stream/ByteInputStream.hpp" #include "infra/util/AutoResetFunction.hpp" #include "infra/util/BoundedVector.hpp" -#include "infra/stream/ByteInputStream.hpp" #include "services/ble/GattClient.hpp" namespace hal diff --git a/hal_st/middlewares/ble_middleware/GattServerSt.cpp b/hal_st/middlewares/ble_middleware/GattServerSt.cpp index 7c6b57ec..5da904a2 100644 --- a/hal_st/middlewares/ble_middleware/GattServerSt.cpp +++ b/hal_st/middlewares/ble_middleware/GattServerSt.cpp @@ -2,7 +2,7 @@ extern "C" { - #include "ble/core/ble_core.h" +#include "ble/core/ble_core.h" } namespace @@ -65,10 +65,10 @@ namespace hal { constexpr uint8_t valueOffset = 0; auto result = aci_gatt_update_char_value(characteristic.ServiceHandle(), - characteristic.CharacteristicHandle(), - valueOffset, - data.size(), - data.begin()); + characteristic.CharacteristicHandle(), + valueOffset, + data.size(), + data.begin()); if (result != BLE_STATUS_SUCCESS) ReportError(result); @@ -105,15 +105,15 @@ namespace hal constexpr uint8_t variableLength = 0x01; auto result = aci_gatt_add_char(characteristic.ServiceHandle(), - UuidToType(characteristic.Type()), - ConvertUuid(characteristic.Type()), - characteristic.ValueLength(), - ConvertProperties(characteristic.Properties()), - ConvertPermissions(characteristic.Permissions()), - notifyAttributeWrite, - encryptionKeySize, - variableLength, - &characteristic.Handle()); + UuidToType(characteristic.Type()), + ConvertUuid(characteristic.Type()), + characteristic.ValueLength(), + ConvertProperties(characteristic.Properties()), + ConvertPermissions(characteristic.Permissions()), + notifyAttributeWrite, + encryptionKeySize, + variableLength, + &characteristic.Handle()); if (result == BLE_STATUS_SUCCESS) characteristic.Attach(*this); @@ -124,12 +124,15 @@ namespace hal void GattServerSt::HandleGattAttributeModified(aci_gatt_attribute_modified_event_rp0& event) { constexpr uint16_t valueAttributeOffset = 1; - infra::ByteRange data{event.Attr_Data, event.Attr_Data + event.Attr_Data_Length}; + infra::ByteRange data{ event.Attr_Data, event.Attr_Data + event.Attr_Data_Length }; for (auto& service : services) for (auto& characteristic : service.Characteristics()) if (event.Attr_Handle == characteristic.Handle() + valueAttributeOffset) - characteristic.NotifyObservers([data](auto& observer) { observer.DataReceived(data); }); + characteristic.NotifyObservers([data](auto& observer) + { + observer.DataReceived(data); + }); } void GattServerSt::ReportError(tBleStatus status) const diff --git a/hal_st/middlewares/ble_middleware/SystemTransportLayer.cpp b/hal_st/middlewares/ble_middleware/SystemTransportLayer.cpp index 5c91bdbb..ed26be5c 100644 --- a/hal_st/middlewares/ble_middleware/SystemTransportLayer.cpp +++ b/hal_st/middlewares/ble_middleware/SystemTransportLayer.cpp @@ -1,8 +1,8 @@ #include "hal_st/middlewares/ble_middleware/SystemTransportLayer.hpp" +#include "hci_tl.h" #include "infra/event/EventDispatcherWithWeakPtr.hpp" #include "shci.h" #include "shci_tl.h" -#include "hci_tl.h" #include extern "C" @@ -22,10 +22,11 @@ extern "C" static std::atomic_bool notificationScheduled{ false }; if (!notificationScheduled.exchange(true)) - infra::EventDispatcher::Instance().Schedule([]() { - notificationScheduled = false; - hci_user_evt_proc(); - }); + infra::EventDispatcher::Instance().Schedule([]() + { + notificationScheduled = false; + hci_user_evt_proc(); + }); } void shci_notify_asynch_evt(void* data) @@ -33,10 +34,11 @@ extern "C" static std::atomic_bool notificationScheduled{ false }; if (!notificationScheduled.exchange(true)) - infra::EventDispatcher::Instance().Schedule([]() { - notificationScheduled = false; - shci_user_evt_proc(); - }); + infra::EventDispatcher::Instance().Schedule([]() + { + notificationScheduled = false; + shci_user_evt_proc(); + }); } } @@ -103,13 +105,14 @@ namespace hal WirelessFwInfo_t wirelessInfo; SHCI_GetWirelessFwInfo(&wirelessInfo); - return {wirelessInfo.VersionMajor, - wirelessInfo.VersionMinor, - wirelessInfo.VersionSub, - wirelessInfo.VersionReleaseType, - wirelessInfo.FusVersionMajor, - wirelessInfo.FusVersionMinor, - wirelessInfo.FusVersionSub, + return { + wirelessInfo.VersionMajor, + wirelessInfo.VersionMinor, + wirelessInfo.VersionSub, + wirelessInfo.VersionReleaseType, + wirelessInfo.FusVersionMajor, + wirelessInfo.FusVersionMinor, + wirelessInfo.FusVersionSub, }; } @@ -130,24 +133,27 @@ namespace hal switch (event->subevtcode) { - case SHCI_SUB_EVT_CODE_READY: - HandleReadyEvent(payload); - break; - case SHCI_SUB_EVT_ERROR_NOTIF: - HandleErrorNotifyEvent(event); - break; - case SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE: - HandleBleNvmRamUpdateEvent(event); - break; - default: - HandleUnknownEvent(event); - break; + case SHCI_SUB_EVT_CODE_READY: + HandleReadyEvent(payload); + break; + case SHCI_SUB_EVT_ERROR_NOTIF: + HandleErrorNotifyEvent(event); + break; + case SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE: + HandleBleNvmRamUpdateEvent(event); + break; + default: + HandleUnknownEvent(event); + break; } } void SystemTransportLayer::HciEventHandler(hci_event_pckt& event) { - infra::Subject::NotifyObservers([&event](auto& observer) { observer.HciEvent(event); }); + infra::Subject::NotifyObservers([&event](auto& observer) + { + observer.HciEvent(event); + }); } void SystemTransportLayer::HandleWirelessFwEvent(void* payload) @@ -170,15 +176,15 @@ namespace hal switch (readyEvent->sysevt_ready_rsp) { - case WIRELESS_FW_RUNNING: - HandleWirelessFwEvent(payload); - break; - case FUS_FW_RUNNING: - HandleFusFwEvent(payload); - break; - default: - HandleUnknwownReadyEvent(payload); - break; + case WIRELESS_FW_RUNNING: + HandleWirelessFwEvent(payload); + break; + case FUS_FW_RUNNING: + HandleFusFwEvent(payload); + break; + default: + HandleUnknwownReadyEvent(payload); + break; } } diff --git a/hal_st/middlewares/ble_middleware/TracingGapCentralSt.cpp b/hal_st/middlewares/ble_middleware/TracingGapCentralSt.cpp index 51a404ad..6c2d425c 100644 --- a/hal_st/middlewares/ble_middleware/TracingGapCentralSt.cpp +++ b/hal_st/middlewares/ble_middleware/TracingGapCentralSt.cpp @@ -180,7 +180,7 @@ namespace hal auto gapProcedureEvent = *reinterpret_cast(vendorEvent->data); if (gapProcedureEvent.Procedure_Code == GAP_DIRECT_CONNECTION_ESTABLISHMENT_PROC) - tracer.Trace() << "TracingGapCentralSt::HandleGapProcedureCompleteEvent Direct Connection establishment status: 0x" << infra::hex <(vendorEvent->data); tracer.Trace() << "TracingGapCentralSt::HandleL2capConnectionUpdateRequestEvent"; - tracer.Trace() << "\tConnection handle : 0x" << infra::hex << connectionUpdateEvent.Connection_Handle; + tracer.Trace() << "\tConnection handle : 0x" << infra::hex << connectionUpdateEvent.Connection_Handle; tracer.Trace() << "\tIdentifier : 0x" << infra::hex << connectionUpdateEvent.Identifier; tracer.Trace() << "\tL2CAP length : " << connectionUpdateEvent.L2CAP_Length; tracer.Trace() << "\tInterval min : " << connectionUpdateEvent.Interval_Min; diff --git a/hal_st/middlewares/ble_middleware/TracingSystemTransportLayer.cpp b/hal_st/middlewares/ble_middleware/TracingSystemTransportLayer.cpp index 2df877ea..50827149 100644 --- a/hal_st/middlewares/ble_middleware/TracingSystemTransportLayer.cpp +++ b/hal_st/middlewares/ble_middleware/TracingSystemTransportLayer.cpp @@ -1,13 +1,13 @@ #include "hal_st/middlewares/ble_middleware/TracingSystemTransportLayer.hpp" +#include "ble/svc/Inc/svc_ctl.h" +#include "hci_tl.h" #include "shci.h" #include "shci_tl.h" -#include "hci_tl.h" -#include "ble/svc/Inc/svc_ctl.h" extern "C" { - #include "app_conf.h" - #include "ble.h" +#include "app_conf.h" +#include "ble.h" } namespace hal @@ -43,7 +43,7 @@ namespace hal void TracingSystemTransportLayer::HandleBleNvmRamUpdateEvent(TL_AsynchEvt_t* sysEvent) { auto& bleNvmRamUpdateEvent = *reinterpret_cast(sysEvent->payload); - tracer.Trace() << "SystemTransportLayer::UserEventHandler: SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE : size: " << bleNvmRamUpdateEvent.Size << ", address: 0x" << infra::hex << bleNvmRamUpdateEvent.StartAddress; + tracer.Trace() << "SystemTransportLayer::UserEventHandler: SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE : size: " << bleNvmRamUpdateEvent.Size << ", address: 0x" << infra::hex << bleNvmRamUpdateEvent.StartAddress; SystemTransportLayer::HandleBleNvmRamUpdateEvent(sysEvent); } diff --git a/hal_st/middlewares/ble_middleware/TracingSystemTransportLayer.hpp b/hal_st/middlewares/ble_middleware/TracingSystemTransportLayer.hpp index 74ec212a..139ca0ee 100644 --- a/hal_st/middlewares/ble_middleware/TracingSystemTransportLayer.hpp +++ b/hal_st/middlewares/ble_middleware/TracingSystemTransportLayer.hpp @@ -6,7 +6,7 @@ namespace hal { - class TracingSystemTransportLayer + class TracingSystemTransportLayer : public SystemTransportLayer { public: diff --git a/hal_st/stm32fxxx/UartStmDuplexDma.cpp b/hal_st/stm32fxxx/UartStmDuplexDma.cpp index 6bb139b8..ba5bd1e0 100644 --- a/hal_st/stm32fxxx/UartStmDuplexDma.cpp +++ b/hal_st/stm32fxxx/UartStmDuplexDma.cpp @@ -44,20 +44,32 @@ namespace hal , dma(dma) #if defined(STM32F0) || defined(STM32F1) || defined(STM32F3) || defined(STM32F7) || defined(STM32WB) || defined(STM32G4) , transmitDmaChannel(dma, config.dmaChannelTx.ValueOr(defaultTxDmaChannelId[uartIndex]), &peripheralUart[uartIndex]->TDR, [this]() - { TransferComplete(); }) + { + TransferComplete(); + }) , receiveDmaChannel( dma, config.dmaChannelRx.ValueOr(defaultRxDmaChannelId[uartIndex]), &peripheralUart[uartIndex]->RDR, [this]() - { ReceiveComplete(this->rxBuffer.size() / 2); }, + { + ReceiveComplete(this->rxBuffer.size() / 2); + }, [this]() - { ReceiveComplete(this->rxBuffer.size()); }) + { + ReceiveComplete(this->rxBuffer.size()); + }) #else , transmitDmaChannel(dma, config.dmaChannelTx.ValueOr(defaultTxDmaChannelId[uartIndex]), &peripheralUart[uartIndex]->DR, [this]() - { TransferComplete(); }) + { + TransferComplete(); + }) , receiveDmaChannel( dma, config.dmaChannelRx.ValueOr(defaultRxDmaChannelId[uartIndex]), &peripheralUart[uartIndex]->DR, [this]() - { ReceiveComplete(this->rxBuffer.size() / 2); }, + { + ReceiveComplete(this->rxBuffer.size() / 2); + }, [this]() - { ReceiveComplete(this->rxBuffer.size()); }) + { + ReceiveComplete(this->rxBuffer.size()); + }) #endif { Configure(config); @@ -74,20 +86,32 @@ namespace hal , dma(dma) #if defined(STM32F0) || defined(STM32F1) || defined(STM32F3) || defined(STM32F7) || defined(STM32WB) || defined(STM32G4) , transmitDmaChannel(dma, config.dmaChannelTx.ValueOr(defaultTxDmaChannelId[uartIndex]), &peripheralUart[uartIndex]->TDR, [this]() - { TransferComplete(); }) + { + TransferComplete(); + }) , receiveDmaChannel( dma, config.dmaChannelRx.ValueOr(defaultRxDmaChannelId[uartIndex]), &peripheralUart[uartIndex]->RDR, [this]() - { ReceiveComplete(this->rxBuffer.size() / 2); }, + { + ReceiveComplete(this->rxBuffer.size() / 2); + }, [this]() - { ReceiveComplete(this->rxBuffer.size()); }) + { + ReceiveComplete(this->rxBuffer.size()); + }) #else , transmitDmaChannel(dma, config.dmaChannelTx.ValueOr(defaultTxDmaChannelId[uartIndex]), &peripheralUart[uartIndex]->DR, [this]() - { TransferComplete(); }) + { + TransferComplete(); + }) , receiveDmaChannel( dma, config.dmaChannelRx.ValueOr(defaultRxDmaChannelId[uartIndex]), &peripheralUart[uartIndex]->DR, [this]() - { ReceiveComplete(this->rxBuffer.size() / 2); }, + { + ReceiveComplete(this->rxBuffer.size() / 2); + }, [this]() - { ReceiveComplete(this->rxBuffer.size()); }) + { + ReceiveComplete(this->rxBuffer.size()); + }) #endif { Configure(config);