Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions services/ble/Gap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ namespace services
});
}

void GapCentralDecorator::Connect(hal::MacAddress macAddress, GapDeviceAddressType addressType, infra::Duration initiatingTimeout)
void GapCentralDecorator::Connect(GapAddress address, const GapConnectionParameters& connectionParameters, infra::Duration initiatingTimeout)
{
GapCentralObserver::Subject().Connect(macAddress, addressType, initiatingTimeout);
GapCentralObserver::Subject().Connect(address, connectionParameters, initiatingTimeout);
}

void GapCentralDecorator::Standby()
Expand Down
4 changes: 2 additions & 2 deletions services/ble/Gap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ namespace services
: public infra::Subject<GapCentralObserver>
{
public:
virtual void Connect(hal::MacAddress macAddress, GapDeviceAddressType addressType, infra::Duration initiatingTimeout) = 0;
virtual void Connect(GapAddress address, const GapConnectionParameters& connectionParameters, infra::Duration initiatingTimeout) = 0;
virtual void Standby() = 0;
virtual void SetIdentityAddress(hal::MacAddress macAddress, GapDeviceAddressType addressType) = 0;
virtual void StartDeviceDiscovery() = 0;
Expand All @@ -419,7 +419,7 @@ namespace services
void StateChanged(GapState state) override;

// Implementation of GapCentral
void Connect(hal::MacAddress macAddress, GapDeviceAddressType addressType, infra::Duration initiatingTimeout) override;
void Connect(GapAddress address, const GapConnectionParameters& connectionParameters, infra::Duration initiatingTimeout) override;
void Standby() override;
void SetIdentityAddress(hal::MacAddress macAddress, GapDeviceAddressType addressType) override;
void StartDeviceDiscovery() override;
Expand Down
25 changes: 22 additions & 3 deletions services/ble/Gap.proto
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,36 @@ message SecurityModeAndLevel
SecurityLevelEnum level = 2;
}

// Link layer connection parameters, as defined in Bluetooth Core Specification v6.3, Vol 6, Part B, Section 4.5.1.
message ConnectionParameters
{
// Minimum and maximum connection interval, in units of 1.25 ms.

@heinwessels-philips heinwessels (heinwessels-philips) Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could add sensible defaults to these values? I could imagine that an customer would see this and not know what to fill it. Similar to what we did for AdvertisementMode. This is something a customer requested.

Same goes for the other values in ConnectionParameters.

Additionally, do we need this change now to fix the bug your solving? Or could it be planned with the upcoming changes to reduce breaking changes? MiquelJayson-Philips

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be taken offline due to Philips policy.

uint32 minConnectionIntervalMultiplier = 1;
uint32 maxConnectionIntervalMultiplier = 2;

// Number of consecutive connection events the peripheral is allowed to skip.
uint32 peripheralLatency = 3;

// Time without a successful connection event after which the link is considered lost, in milliseconds.
// Must outlast the slowest operation the peer performs while connected. A peripheral without a hardware
// ECC engine can block for well over a second computing LE Secure Connections key material.
uint32 supervisionTimeoutInMs = 4;
}

message ConnectRequest
{
// The address of the peripheral to connect to, as discovered during scanning (e.g. from DiscoveredDevice).
AddressWithType addressWithType = 1;

// The link layer parameters requested for this connection.
ConnectionParameters connectionParameters = 2;

// How long the central will wait for the peripheral to respond to the connection request, in milliseconds.
// After the central sends the connection request, the peripheral may take time to process and confirm it.
// If the peripheral does not respond within this timeout, the connection attempt is aborted.
// A value of zero waits indefinitely.
// Recommended: set to at least several multiples of the peripheral's advertising interval.
uint32 initiatingTimeoutInMs = 2;
uint32 initiatingTimeoutInMs = 3;
}

message AdvertisingReportType
Expand All @@ -422,7 +441,7 @@ message AdvertisingReportType

message DiscoveredDevice
{
// The address as received in the advertising packet. Use this address directly when connecting via ConnectionParameters.
// The address as received in the advertising packet. Use this address directly when connecting via ConnectRequest.
// If the peripheral uses a resolvable private address (RPA), the controller will resolve it automatically
// after a bond has been established and the peer's IRK is stored.
AddressWithType addressWithType = 1;
Expand Down Expand Up @@ -518,7 +537,7 @@ service GapCentral
// For successful connection establishment, state will follow: standby -> initiating -> connected
// For failed connection establishment, state will follow: standby -> initiating -> standby
// Results in GapCentralResponse.CurrentState
rpc Connect(ConnectionParameters) returns (Nothing) { option (method_id) = 4; }
rpc Connect(ConnectRequest) returns (Nothing) { option (method_id) = 4; }

// Allowed states: scanning, initiating, connected
// Terminates the current (or initiating) connection.
Expand Down
11 changes: 9 additions & 2 deletions services/ble/test/TestGapCentral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ namespace services
return x.reportType == arg.reportType && x.gapAddress == arg.gapAddress && x.rssi == arg.rssi;
}

MATCHER_P(ConnectionParametersEqual, x, negation ? "Contents not equal" : "Contents are equal")
{
return x.minConnIntMultiplier == arg.minConnIntMultiplier && x.maxConnIntMultiplier == arg.maxConnIntMultiplier && x.slaveLatency == arg.slaveLatency && x.supervisorTimeoutMs == arg.supervisorTimeoutMs;
}

TEST_F(GapCentralDecoratorTest, forward_all_state_changed_events_to_observers)
{
EXPECT_CALL(gapObserver, StateChanged(GapState::connected));
Expand Down Expand Up @@ -66,9 +71,11 @@ namespace services
TEST_F(GapCentralDecoratorTest, forward_all_calls_to_subject)
{
hal::MacAddress macAddress{ 0, 1, 2, 3, 4, 5 };
const GapAddress address{ macAddress, GapDeviceAddressType::publicAddress };
const GapConnectionParameters connectionParameters{ 6, 6, 0, 500 };

EXPECT_CALL(gap, Connect(MacAddressContentsEqual(macAddress), services::GapDeviceAddressType::publicAddress, infra::Duration{ 0 }));
decorator.Connect(macAddress, services::GapDeviceAddressType::publicAddress, std::chrono::seconds(0));
EXPECT_CALL(gap, Connect(address, ConnectionParametersEqual(connectionParameters), infra::Duration{ 0 }));
decorator.Connect(address, connectionParameters, std::chrono::seconds(0));

EXPECT_CALL(gap, Standby());
decorator.Standby();
Expand Down
2 changes: 1 addition & 1 deletion services/ble/test_doubles/GapCentralMock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace services
: public GapCentral
{
public:
MOCK_METHOD(void, Connect, (hal::MacAddress macAddress, GapDeviceAddressType addressType, infra::Duration initiatingTimeout));
MOCK_METHOD(void, Connect, (GapAddress address, const GapConnectionParameters& connectionParameters, infra::Duration initiatingTimeout));
MOCK_METHOD(void, Standby, ());
MOCK_METHOD(void, SetIdentityAddress, (hal::MacAddress macAddress, GapDeviceAddressType addressType));
MOCK_METHOD(void, StartDeviceDiscovery, ());
Expand Down
Loading