pw_bluetooth: Move LocalService handle to LocalServiceInfo
For improved ergonomics, let the client specify LocalService
handles in LocalServiceInfo instead of assigning a handle to
services and returning them in LocalService::GetHandle().
Change-Id: If1a05814eaae00376f3e89e27810546ab333b1bb
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/112450
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Ben Lawson <benlawson@google.com>
diff --git a/pw_bluetooth/public/pw_bluetooth/gatt/server.h b/pw_bluetooth/public/pw_bluetooth/gatt/server.h
index 2cff56f..90d441f 100644
--- a/pw_bluetooth/public/pw_bluetooth/gatt/server.h
+++ b/pw_bluetooth/public/pw_bluetooth/gatt/server.h
@@ -29,6 +29,9 @@
// Parameters for registering a local GATT service.
struct LocalServiceInfo {
+ // A unique (within a Server) handle identifying this service.
+ Handle handle;
+
// Indicates whether this is a primary or secondary service.
bool primary;
@@ -140,9 +143,6 @@
virtual ~LocalService() = default;
- // Returns the unique handle assigned to this service.
- virtual Handle GetHandle() = 0;
-
// Sends a notification to peers. Notifications should be used instead of
// indications when the service does *not* require peer confirmation of the
// update.
@@ -191,14 +191,17 @@
enum class PublishServiceError {
kInternalError = 0,
- /// Invalid service UUID provided.
- kInvalidUuid = 1,
+ // The service handle provided was not unique.
+ kInvalidHandle = 1,
+
+ // Invalid service UUID provided.
+ kInvalidUuid = 2,
// Invalid service characteristics provided.
- kInvalidCharacteristics = 2,
+ kInvalidCharacteristics = 3,
// Invalid service includes provided.
- kInvalidIncludes = 3,
+ kInvalidIncludes = 4,
};
virtual ~Server() = default;