Skip to content

Commit

Permalink
chore: apply clang-format (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardapeters authored Jan 2, 2024
1 parent 51ac835 commit c63f739
Show file tree
Hide file tree
Showing 15 changed files with 291 additions and 222 deletions.
2 changes: 1 addition & 1 deletion hal_st/middlewares/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion hal_st/middlewares/ble_middleware/BondStorageSt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

extern "C"
{
#include "ble_gap_aci.h"
#include "ble_gap_aci.h"
}

namespace hal
Expand Down
14 changes: 9 additions & 5 deletions hal_st/middlewares/ble_middleware/GapCentralSt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -46,7 +45,6 @@ namespace hal
connectionUpdateParameters.minConnIntMultiplier, connectionUpdateParameters.maxConnIntMultiplier,
connectionUpdateParameters.slaveLatency, connectionUpdateParameters.supervisorTimeoutMs,
minConnectionEventLength, maxConnectionEventLength);

}

void GapCentralSt::Disconnect()
Expand All @@ -65,7 +63,10 @@ namespace hal
{
aci_gap_start_general_discovery_proc(leScanInterval, leScanWindow, GAP_RESOLVABLE_PRIVATE_ADDR, filterDuplicatesEnabled);
discovering = true;
infra::Subject<services::GapCentralObserver>::NotifyObservers([](auto& observer) { observer.StateChanged(services::GapState::scanning); });
infra::Subject<services::GapCentralObserver>::NotifyObservers([](auto& observer)
{
observer.StateChanged(services::GapState::scanning);
});
}
}

Expand All @@ -86,7 +87,10 @@ namespace hal
{
GapSt::HandleHciDisconnectEvent(eventPacket);

infra::Subject<services::GapCentralObserver>::NotifyObservers([](auto& observer) { observer.StateChanged(services::GapState::standby); });
infra::Subject<services::GapCentralObserver>::NotifyObservers([](auto& observer)
{
observer.StateChanged(services::GapState::standby);
});
}

void GapCentralSt::HandleHciLeAdvertisingReportEvent(evt_le_meta_event* metaEvent)
Expand Down
14 changes: 10 additions & 4 deletions hal_st/middlewares/ble_middleware/GapPeripheralSt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)
Expand Down Expand Up @@ -133,8 +139,8 @@ namespace hal
{
aci_gap_add_devices_to_resolving_list(numberOfBondedAddress, reinterpret_cast<const Whitelist_Identity_Entry_t*>(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);
Expand Down
2 changes: 1 addition & 1 deletion hal_st/middlewares/ble_middleware/GapPeripheralSt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace hal
infra::BoundedVector<uint8_t>::WithMaxSize<maxAdvertisementDataSize> advertisementData;
infra::BoundedVector<uint8_t>::WithMaxSize<maxScanResponseDataSize> 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 } };
};
}

Expand Down
165 changes: 82 additions & 83 deletions hal_st/middlewares/ble_middleware/GapSt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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;
}
}

Expand All @@ -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>(peerAddressType))
{
switch (static_cast<PeerAddressType>(peerAddressType))
{
case PeerAddressType::PUBLIC:
case PeerAddressType::RANDOM:
return peerAddressType;
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions hal_st/middlewares/ble_middleware/GapSt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit c63f739

Please sign in to comment.