Skip to content

Commit 749fa2e

Browse files
chore: give characteristic operation observer access to value handle (#1039)
Allow gatt char observer to access value handle
1 parent 4494b45 commit 749fa2e

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

services/ble/GattServer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace services
4040

4141
virtual AttAttribute::Handle ServiceHandle() const = 0;
4242
virtual AttAttribute::Handle CharacteristicHandle() const = 0;
43+
virtual AttAttribute::Handle CharacteristicValueHandle() const = 0;
4344
};
4445

4546
class GattServerCharacteristicOperations

services/ble/GattServerCharacteristicImpl.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ namespace services
4242
return handle;
4343
}
4444

45+
AttAttribute::Handle GattServerCharacteristicImpl::CharacteristicValueHandle() const
46+
{
47+
return valueHandle;
48+
}
49+
4550
void GattServerCharacteristicImpl::UpdateValue()
4651
{
4752
auto status = GattServerCharacteristicOperationsObserver::Subject().Update(*this, updateContext->data);

services/ble/GattServerCharacteristicImpl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace services
2222
// Implementation of GattServerCharacteristicOperationsObserver
2323
AttAttribute::Handle ServiceHandle() const override;
2424
AttAttribute::Handle CharacteristicHandle() const override;
25+
AttAttribute::Handle CharacteristicValueHandle() const override;
2526

2627
private:
2728
struct UpdateContext

services/ble/test/TestGattServer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ TEST(GattServerTest, characteristic_implementation_handles_are_accesible)
2222
s.Handle() = 0xAB;
2323
services::GattServerCharacteristicImpl c{ s, uuid16, valueSize };
2424
c.Handle() = 0xCD;
25+
c.ValueHandle() = 0xEF;
2526

2627
EXPECT_EQ(0xAB, c.ServiceHandle());
2728
EXPECT_EQ(0xCD, c.CharacteristicHandle());
29+
EXPECT_EQ(0xEF, c.CharacteristicValueHandle());
2830
}
2931

3032
TEST(GattServerTest, characteristic_implementation_supports_different_uuid_lengths)

services/ble/test_doubles/GattServerMock.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace services
3535
public:
3636
MOCK_METHOD(AttAttribute::Handle, ServiceHandle, (), (const));
3737
MOCK_METHOD(AttAttribute::Handle, CharacteristicHandle, (), (const));
38+
MOCK_METHOD(AttAttribute::Handle, CharacteristicValueHandle, (), (const));
3839
MOCK_METHOD(void, Update, (infra::ConstByteRange data, infra::Function<void()> onDone));
3940
};
4041
}

0 commit comments

Comments
 (0)