Skip to content

Commit a9df781

Browse files
XavierBernhardt-PhilipsMiquelJayson-Philipsrichardapeters
authored
feat: rename Pair to PairAndBond (#907)
* Work towards improving pairing security requirements * Better enum naming for ConnectionMode and ManInTheMiddleMode * Renamed notRequired to Disabled * Rename values in SecureConnectionMode enum * Refactoring SecureConnectionMode and MITMMODE into 2 functions * refactoring * fixed compile error * Removed bracket * Merge commit 'c20c83ea909ca2e1a7ef8a07bb5cfe91144bf3a7' * Refactored Pair to Bond in Gap.proto * revert changes to gap * cleanup * cleanup * Renamed to PairAndBond * pr comments * Added some void trace functions * Renamed to PairAndBond * Moving logging functions away from root class * Update services/ble/Gap.hpp Co-authored-by: Richard Peters <richard.peters@philips.com> --------- Co-authored-by: MiquelJayson-Philips <miqueljayson.de.leeuw@philips.com> Co-authored-by: Richard Peters <richard.peters@philips.com>
1 parent 6d4cdc1 commit a9df781

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

services/ble/Gap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ namespace services
4444
});
4545
}
4646

47-
void GapPairingDecorator::Pair()
47+
void GapPairingDecorator::PairAndBond()
4848
{
49-
GapPairingObserver::Subject().Pair();
49+
GapPairingObserver::Subject().PairAndBond();
5050
}
5151

5252
void GapPairingDecorator::AllowPairing(bool allow)

services/ble/Gap.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ namespace services
128128
level4,
129129
};
130130

131-
virtual void Pair() = 0;
131+
// 1. If there is a pre-existing bond, then the connection will be encrypted.
132+
// 2. If there is no pre-existing bond, then pairing, encrypting, and bonding (storing the keys) will take place.
133+
virtual void PairAndBond() = 0;
132134

133135
virtual void AllowPairing(bool allow) = 0;
134-
135136
virtual void SetSecurityMode(SecurityMode mode, SecurityLevel level) = 0;
136137
virtual void SetIoCapabilities(IoCapabilities caps) = 0;
137-
138138
virtual void AuthenticateWithPasskey(uint32_t passkey) = 0;
139139
virtual void NumericComparisonConfirm(bool accept) = 0;
140140
};
@@ -152,7 +152,7 @@ namespace services
152152
void PairingFailed(PairingErrorType error) override;
153153

154154
// Implementation of GapPairing
155-
void Pair() override;
155+
void PairAndBond() override;
156156
void AllowPairing(bool allow) override;
157157
void SetSecurityMode(SecurityMode mode, SecurityLevel level) override;
158158
void SetIoCapabilities(IoCapabilities caps) override;

services/ble/Gap.proto

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,22 @@ service GapCentral
222222
// Allowed states: connected
223223
rpc Disconnect(Nothing) returns (Nothing) { option (method_id) = 5; }
224224

225-
// Allowed states: connected
226-
rpc Pair(Nothing) returns (Nothing) { option (method_id) = 6; }
225+
// Allowed states: connected
226+
// 1. If there is a pre-existing bond, then the connection will be encrypted.
227+
// 2. If there is no pre-existing bond, then pairing, encrypting, and bonding (storing the keys) will take place.
228+
rpc PairAndBond(Nothing) returns (Nothing) { option (method_id) = 6; }
227229

228230
rpc SetSecurityMode(SecurityModeAndLevel) returns (Nothing) { option (method_id) = 7; }
229231
rpc SetIoCapabilities(IoCapabilities) returns (Nothing) { option (method_id) = 8; }
230232
rpc AuthenticateWithPasskey(UInt32Value) returns (Nothing) { option (method_id) = 9; }
231233
rpc NumericComparisonConfirm(BoolValue) returns (Nothing) { option (method_id) = 10; }
232234
rpc RemoveAllBonds(Nothing) returns (Nothing) { option (method_id) = 11; }
233235
rpc SetDeviceDiscoveryFilter(DeviceDiscoveryFilter) returns (Nothing) { option (method_id) = 12; }
234-
rpc ResolvePrivateAddress(Address) returns (Nothing) { option (method_id) = 13; }
236+
237+
// This will only succeed if Address is a private resolvable address, and if the device is bonded
238+
rpc ResolvePrivateAddress(Address) returns (Nothing) { option (method_id) = 13; }
239+
240+
// This will work with both public and random addresses
235241
rpc IsDeviceBonded(PeerNodeParameters) returns (Nothing) { option (method_id) = 14; }
236242
}
237243

services/ble/test/TestGapPairing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ namespace services
3434

3535
TEST_F(GapPairingDecoratorTest, forward_all_calls_to_subject)
3636
{
37-
EXPECT_CALL(gapPairing, Pair());
38-
decorator.Pair();
37+
EXPECT_CALL(gapPairing, PairAndBond());
38+
decorator.PairAndBond();
3939

4040
EXPECT_CALL(gapPairing, AllowPairing(::testing::IsTrue()));
4141
decorator.AllowPairing(true);

services/ble/test_doubles/GapPairingMock.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace services
1010
: public GapPairing
1111
{
1212
public:
13-
MOCK_METHOD(void, Pair, ());
13+
MOCK_METHOD(void, PairAndBond, ());
1414
MOCK_METHOD(void, AllowPairing, (bool allow));
1515
MOCK_METHOD(void, SetSecurityMode, (SecurityMode mode, SecurityLevel level));
1616
MOCK_METHOD(void, SetIoCapabilities, (IoCapabilities caps));

0 commit comments

Comments
 (0)