2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "bluetooth/bluetooth_gatt_server.h"
20 #include "bluetooth/bluetooth_gatt_server_service.h"
21 #include "bluetooth/bluetooth_instance.h"
22 #include "bluetooth/bluetooth_util.h"
23 #include "bluetooth/uuid.h"
25 #include "common/logger.h"
26 #include "common/platform_result.h"
27 #include "common/tools.h"
29 using namespace extension::bluetooth::util;
30 using common::PlatformResult;
31 using common::ErrorCode;
37 const std::string kUuid = "uuid";
38 const std::string kServiceUuid = "serviceUuid";
39 const std::string kIsPrimary = "isPrimary";
40 const std::string kCharacteristics = "characteristics";
42 const std::string kServices = "services";
43 const std::string kDescriptors = "descriptors";
44 const std::string kIsBroadcast = "isBroadcast";
45 const std::string kHasExtendedProperties = "hasExtendedProperties";
46 const std::string kIsNotify = "isNotify";
47 const std::string kIsIndication = "isIndication";
48 const std::string kIsReadable = "isReadable";
49 const std::string kIsSignedWrite = "isSignedWrite";
50 const std::string kIsWritable = "isWritable";
51 const std::string kIsWriteNoResponse = "isWriteNoResponse";
52 const std::string kReadPermission = "readPermission";
53 const std::string kWritePermission = "writePermission";
54 const std::string kEncryptedReadPermission = "encryptedReadPermission";
55 const std::string kEncryptedWritePermission = "encryptedWritePermission";
56 const std::string kEncryptedSignedReadPermission = "encryptedSignedReadPermission";
57 const std::string kEncryptedSignedWritePermission = "encryptedSignedWritePermission";
59 const std::string kId = "_id";
60 const std::string kIdsToRemoveFromNativeLayer = "idsToRemoveFromNativeLayer";
61 const std::string kClientAddress = "clientAddress";
62 const std::string kRequestId = "requestId";
63 const std::string kValue = "value";
64 const std::string kOffset = "offset";
65 const std::string kReplyRequired = "replyRequired";
66 const std::string kRequestType = "requestType";
67 const std::string kReadRequestType = "readRequestType";
68 const std::string kWriteRequestType = "writeRequestType";
69 const std::string kStatusCode = "statusCode";
70 const std::string kData = "data";
71 const std::string kReadCallback = "readCallback";
72 const std::string kWriteCallback = "writeCallback";
74 int GetPermissionsInt(const picojson::value& permissions) {
75 ScopeLogger("permissions: %s", permissions.serialize().c_str());
78 if (permissions.get(kReadPermission).get<bool>()) {
79 ret |= BT_GATT_PERMISSION_READ;
81 if (permissions.get(kWritePermission).get<bool>()) {
82 ret |= BT_GATT_PERMISSION_WRITE;
84 if (permissions.get(kEncryptedReadPermission).get<bool>()) {
85 ret |= BT_GATT_PERMISSION_ENCRYPT_READ;
87 if (permissions.get(kEncryptedWritePermission).get<bool>()) {
88 ret |= BT_GATT_PERMISSION_ENCRYPT_WRITE;
90 if (permissions.get(kEncryptedSignedReadPermission).get<bool>()) {
91 ret |= BT_GATT_PERMISSION_ENCRYPT_AUTHENTICATED_READ;
93 if (permissions.get(kEncryptedSignedWritePermission).get<bool>()) {
94 ret |= BT_GATT_PERMISSION_ENCRYPT_AUTHENTICATED_WRITE;
97 LoggerD("Permissions: %x", static_cast<unsigned int>(ret));
101 int GetPropertiesInt(const picojson::value& properties) {
102 ScopeLogger("properties: %s", properties.serialize().c_str());
105 if (properties.get(kIsBroadcast).get<bool>()) {
106 ret |= BT_GATT_PROPERTY_BROADCAST;
108 if (properties.get(kIsReadable).get<bool>()) {
109 ret |= BT_GATT_PROPERTY_READ;
111 if (properties.get(kIsWriteNoResponse).get<bool>()) {
112 ret |= BT_GATT_PROPERTY_WRITE_WITHOUT_RESPONSE;
114 if (properties.get(kIsWritable).get<bool>()) {
115 ret |= BT_GATT_PROPERTY_WRITE;
117 if (properties.get(kIsNotify).get<bool>()) {
118 ret |= BT_GATT_PROPERTY_NOTIFY;
120 if (properties.get(kIsIndication).get<bool>()) {
121 ret |= BT_GATT_PROPERTY_INDICATE;
123 if (properties.get(kIsSignedWrite).get<bool>()) {
124 ret |= BT_GATT_PROPERTY_AUTHENTICATED_SIGNED_WRITES;
126 if (properties.get(kHasExtendedProperties).get<bool>()) {
127 ret |= BT_GATT_PROPERTY_EXTENDED_PROPERTIES;
130 LoggerD("Properties: %x", static_cast<unsigned int>(ret));
136 bool BluetoothGATTServerService::DestroyService(int total, int index, bt_gatt_h handle,
138 ScopeLogger("total: %d, index: %d, handle: %p", total, index, handle);
141 * Undocumented behavior of native Bluetooth API:
142 * bt_gatt_service_destroy() destroys not only the service, but also all
143 * its components (included services, characteristics, descriptors)
146 auto ret = bt_gatt_service_destroy(handle);
147 if (BT_ERROR_NONE != ret) {
148 LoggerE("bt_gatt_service_destroy(): %d (%s)", ret, get_error_message(ret));
150 LoggerD("bt_gatt_service_destroy(): success");
155 bool BluetoothGATTServerService::DestroyCharacteristic(int total, int index, bt_gatt_h handle,
157 ScopeLogger("total: %d, index: %d, handle: %p", total, index, handle);
159 auto ret = bt_gatt_characteristic_destroy(handle);
160 if (BT_ERROR_NONE != ret) {
161 LoggerE("bt_gatt_characteristic_destroy(): %d (%s)", ret, get_error_message(ret));
163 LoggerD("bt_gatt_characteristic_destroy(): success");
168 bool BluetoothGATTServerService::DestroyDescriptor(int total, int index, bt_gatt_h handle,
170 ScopeLogger("total: %d, index: %d, handle: %p", total, index, handle);
172 auto ret = bt_gatt_descriptor_destroy(handle);
173 if (BT_ERROR_NONE != ret) {
174 LoggerE("bt_gatt_descriptor_destroy(): %d (%s)", ret, get_error_message(ret));
176 LoggerD("bt_gatt_descriptor_destroy(): success");
181 BluetoothGATTServerService::BluetoothGATTServerService(BluetoothInstance& instance)
182 : instance_{instance}, rw_request_callback_data_{instance, callback_names_} {
186 BluetoothGATTServerService::~BluetoothGATTServerService() {
190 common::PlatformResult BluetoothGATTServerService::AddDescriptors(
191 const picojson::array& descriptors_init, bt_gatt_h characteristic_handle,
192 std::vector<std::pair<int, bt_gatt_h>>& new_gatt_objects) {
193 ScopeLogger("descriptors_init length: %zu", descriptors_init.size());
196 * This function expects valid input.
197 * If it gets descriptors missing any: uuid, permission,
198 * or with one of these with a wrong type, the application will crash.
201 for (const auto& descriptor_init_data : descriptors_init) {
202 const auto& uuid_str = descriptor_init_data.get(kUuid).get<std::string>();
204 * Native APIs don't support 32-bit UUIDs. We convert any UUID to its 128-bit
205 * form to assure, it will be accepted by the native API.
207 * We assume, UUID::create() returns a valid object, because the input is valid.
209 auto uuid = UUID::create(uuid_str);
210 int permissions = GetPermissionsInt(descriptor_init_data);
211 bt_gatt_h descriptor_handle = nullptr;
213 int ret = bt_gatt_descriptor_create(uuid->uuid_128_bit.c_str(), permissions, nullptr, 0,
215 if (BT_ERROR_NONE != ret) {
216 LoggerE("bt_gatt_descriptor_create() failed: %d (%s)", ret, get_error_message(ret));
217 return BluetoothErrorToPlatformResult(ret, "Failed to create a descriptor");
219 LoggerD("bt_gatt_descriptor_create(): success");
221 ret = bt_gatt_characteristic_add_descriptor(characteristic_handle, descriptor_handle);
222 if (BT_ERROR_NONE != ret) {
223 LoggerE("bt_gatt_characteristic_add_descriptor() failed: %d (%s)", ret,
224 get_error_message(ret));
225 DestroyDescriptor(0, 0, descriptor_handle, nullptr);
226 return BluetoothErrorToPlatformResult(ret, "Failed to add descriptor to characteristic");
228 LoggerD("bt_gatt_characteristic_add_descriptor(): success");
230 const auto _id = static_cast<int>(descriptor_init_data.get(kId).get<double>());
231 new_gatt_objects.push_back({_id, descriptor_handle});
234 return common::PlatformResult();
237 common::PlatformResult BluetoothGATTServerService::AddCharacteristics(
238 const picojson::array& characteristics_init, bt_gatt_h service_handle,
239 std::vector<std::pair<int, bt_gatt_h>>& new_gatt_objects) {
240 ScopeLogger("characteristics_init length: %zu", characteristics_init.size());
243 * This function expects valid input.
244 * If it gets characteristics missing any: uuid, permission, property,
245 * or with any of these with a wrong type, the application will crash.
248 for (const auto& characteristic_init_data : characteristics_init) {
249 const auto& uuid_str = characteristic_init_data.get(kUuid).get<std::string>();
251 * Native APIs don't support 32-bit UUIDs. We convert any UUID to its 128-bit
252 * form to assure, it will be accepted by the native API.
254 * We assume, UUID::create() returns a valid object, because the input is valid.
256 auto uuid = UUID::create(uuid_str);
258 int permissions = GetPermissionsInt(characteristic_init_data);
259 int properties = GetPropertiesInt(characteristic_init_data);
260 bt_gatt_h characteristic_handle = nullptr;
262 int ret = bt_gatt_characteristic_create(uuid->uuid_128_bit.c_str(), permissions, properties,
263 nullptr, 0, &characteristic_handle);
264 if (BT_ERROR_NONE != ret) {
265 LoggerE("bt_gatt_characteristic_create() failed: %d (%s)", ret, get_error_message(ret));
266 return BluetoothErrorToPlatformResult(ret, "Failed to create a characteristic");
268 LoggerD("bt_gatt_characteristic_create(): success");
270 if (characteristic_init_data.get(kDescriptors).is<picojson::array>()) {
271 const auto& descriptors = characteristic_init_data.get(kDescriptors).get<picojson::array>();
272 auto result = AddDescriptors(descriptors, characteristic_handle, new_gatt_objects);
274 DestroyCharacteristic(0, 0, characteristic_handle, nullptr);
279 ret = bt_gatt_service_add_characteristic(service_handle, characteristic_handle);
280 if (BT_ERROR_NONE != ret) {
281 LoggerE("bt_gatt_service_add_characteristic() failed: %d (%s)", ret, get_error_message(ret));
282 DestroyCharacteristic(0, 0, characteristic_handle, nullptr);
283 return BluetoothErrorToPlatformResult(ret, "Failed to add a characteristic to a service");
285 LoggerD("bt_gatt_service_add_characteristic(): success");
287 const auto _id = static_cast<int>(characteristic_init_data.get(kId).get<double>());
288 new_gatt_objects.push_back({_id, characteristic_handle});
291 return common::PlatformResult();
294 common::PlatformResult BluetoothGATTServerService::AddIncludedServices(
295 const picojson::array& included_services_init, bt_gatt_h parent_service_handle,
296 std::vector<std::pair<int, bt_gatt_h>>& new_gatt_objects) {
297 ScopeLogger("included_services_init length: %zu", included_services_init.size());
300 * This function expects valid input.
301 * If it gets included_services missing a uuid
302 * or with any of these with a wrong type, the application will crash.
305 for (const auto& service_init_data : included_services_init) {
306 bt_gatt_h included_service_handle = nullptr;
307 auto result = CreateService(service_init_data, &included_service_handle, new_gatt_objects);
309 LoggerE("Failed to create included service");
313 int ret = bt_gatt_service_add_included_service(parent_service_handle, included_service_handle);
314 if (BT_ERROR_NONE != ret) {
315 LoggerE("bt_gatt_service_add_included_service() failed: %d (%s)", ret,
316 get_error_message(ret));
317 DestroyService(0, 0, included_service_handle, nullptr);
318 return BluetoothErrorToPlatformResult(ret, "Failed to add included service");
320 LoggerD("bt_gatt_service_add_included_service(): success");
322 const auto _id = static_cast<int>(service_init_data.get(kId).get<double>());
323 new_gatt_objects.push_back({_id, parent_service_handle});
326 return common::PlatformResult();
329 common::PlatformResult BluetoothGATTServerService::CreateService(
330 const picojson::value& service_init, bt_gatt_h* new_service_handle,
331 std::vector<std::pair<int, bt_gatt_h>>& new_gatt_objects) {
332 ScopeLogger("service_init: %s", service_init.serialize().c_str());
334 * This function expects valid input.
335 * If it gets service_init without any of the expected members or with a member of
336 * a wrong type, the application will crash.
339 const auto& uuid_str = service_init.get(kServiceUuid).get<std::string>();
341 * Native APIs don't support 32-bit UUIDs. We convert any UUID to its 128-bit
342 * form to assure, it will be accepted by the native API.
344 * We assume, UUID::create() returns a valid object, because the input is valid.
346 auto uuid = UUID::create(uuid_str);
347 bool primary = service_init.get(kIsPrimary).get<bool>();
348 bt_gatt_service_type_e type =
349 primary ? BT_GATT_SERVICE_TYPE_PRIMARY : BT_GATT_SERVICE_TYPE_SECONDARY;
350 bt_gatt_h service_handle = nullptr;
352 int err = bt_gatt_service_create(uuid->uuid_128_bit.c_str(), type, &service_handle);
353 if (BT_ERROR_NONE != err) {
354 LoggerE("bt_gatt_service_create error: %d (%s)", err, get_error_message(err));
355 return BluetoothErrorToPlatformResult(err, "Failed to create GATT service");
357 LoggerD("bt_gatt_service_create(): success");
359 if (service_init.get(kServices).is<picojson::array>()) {
360 const auto& services = service_init.get(kServices).get<picojson::array>();
361 auto result = AddIncludedServices(services, service_handle, new_gatt_objects);
363 DestroyService(0, 0, service_handle, nullptr);
368 if (service_init.get(kCharacteristics).is<picojson::array>()) {
369 const auto& characteristics = service_init.get(kCharacteristics).get<picojson::array>();
370 auto result = AddCharacteristics(characteristics, service_handle, new_gatt_objects);
372 DestroyService(0, 0, service_handle, nullptr);
377 const auto _id = static_cast<int>(service_init.get(kId).get<double>());
378 new_gatt_objects.push_back({_id, service_handle});
380 *new_service_handle = service_handle;
382 return common::PlatformResult();
385 common::PlatformResult BluetoothGATTServerService::RegisterService(
386 bt_gatt_h service_handle, bt_gatt_server_h server,
387 const std::vector<std::pair<int, bt_gatt_h>>& new_gatt_objects) {
390 int ret = bt_gatt_server_register_service(server, service_handle);
391 if (BT_ERROR_NONE != ret) {
392 LoggerE("bt_gatt_server_register_service() failed: %d (%s)", ret, get_error_message(ret));
393 return BluetoothErrorToPlatformResult(ret, "Failed to register GATT service");
396 gatt_objects_.insert(new_gatt_objects.begin(), new_gatt_objects.end());
398 return common::PlatformResult();
401 common::PlatformResult BluetoothGATTServerService::UnregisterService(const picojson::value& args,
402 bt_gatt_server_h server) {
405 auto _id = static_cast<int>(args.get(kId).get<double>());
406 LoggerD("Unregistering service with _id: %d", _id);
408 auto service_handle = gatt_objects_[_id];
411 * Undocumented behavior of native Bluetooth API:
412 * bt_gatt_server_unregister_service() not only unregisters the service,
413 * but also calls bt_gatt_destroy_service() on its handle, destroying
414 * the corresponding service object and all its components (included services,
415 * characteristics, descriptors).
417 auto ret = bt_gatt_server_unregister_service(server, service_handle);
418 if (BT_ERROR_NONE != ret) {
419 LoggerE("bt_gatt_server_unregister_service() failed: %d (%s)", ret, get_error_message(ret));
420 return BluetoothErrorToPlatformResult(ret, "Failed to unregister GATT service");
422 LoggerD("bt_gatt_server_unregister_service(): SUCCESS");
424 gatt_objects_.erase(_id);
426 auto ids_to_remove = args.get(kIdsToRemoveFromNativeLayer).get<picojson::array>();
427 for (const auto& to_remove : ids_to_remove) {
428 const auto id_to_remove = static_cast<int>(to_remove.get<double>());
430 auto handle_to_remove = gatt_objects_[id_to_remove];
431 LoggerD("Erasing gatt object with _id: %d", id_to_remove);
432 callback_names_.erase(std::make_pair(handle_to_remove, kReadCallback));
433 callback_names_.erase(std::make_pair(handle_to_remove, kWriteCallback));
434 gatt_objects_.erase(id_to_remove);
437 return common::PlatformResult{};
440 PlatformResult BluetoothGATTServerService::SetReadValueRequestCallback(
441 const picojson::value& args) {
444 auto _id = static_cast<int>(args.get(kId).get<double>());
445 LoggerD("Setting read value request callback for a GATT entity with _id: %d", _id);
447 auto gatt_handle = gatt_objects_[_id];
448 callback_names_[std::make_pair(gatt_handle, kReadCallback)] =
449 "ReadValueRequestCallback_" + std::to_string(_id);
451 auto read_value_request_callback = [](const char* remote_address, int request_id,
452 bt_gatt_server_h server, bt_gatt_h gatt_handle, int offset,
453 void* user_data) -> void {
454 ScopeLogger("ReadValueRequestCallback called. remote_address: %s, request_id: %d, offset: %d",
455 remote_address, request_id, offset);
456 auto rw_callback_data = static_cast<ReadWriteRequestCallbackData*>(user_data);
458 // We create a copy of this value, because remote_address pointer will be invalid
459 // when the job will be executed in the worker
460 auto remote_address_copy = std::string{remote_address};
462 rw_callback_data->instance_.GetWorker().add_job(
463 [remote_address_copy, request_id, server, gatt_handle, offset, rw_callback_data] {
464 ScopeLogger("Async call: SetReadValueRequestCallback");
466 auto read_value_request = picojson::value{picojson::object{}};
467 auto& read_value_request_obj = read_value_request.get<picojson::object>();
468 read_value_request_obj[kClientAddress] = picojson::value{remote_address_copy};
469 read_value_request_obj[kRequestId] = picojson::value{static_cast<double>(request_id)};
470 read_value_request_obj[kRequestType] = picojson::value{kReadRequestType};
471 read_value_request_obj[kOffset] = picojson::value{static_cast<double>(offset)};
472 const auto callback_name =
473 rw_callback_data->callback_names_map_[std::make_pair(gatt_handle, kReadCallback)];
474 LoggerD("Firing read value request event: %s: %s", callback_name.c_str(),
475 read_value_request.serialize().c_str());
476 rw_callback_data->instance_.FireEvent(callback_name, read_value_request);
480 auto ret = bt_gatt_server_set_read_value_requested_cb(gatt_handle, read_value_request_callback,
481 &rw_request_callback_data_);
482 if (BT_ERROR_NONE != ret) {
483 LoggerE("bt_gatt_server_set_read_value_requested_cb() failed: %d (%s)", ret,
484 get_error_message(ret));
485 return BluetoothErrorToPlatformResult(ret, "Failed to set read value request callback");
488 LoggerD("bt_gatt_server_set_read_value_requested_cb(): SUCCESS");
489 return common::PlatformResult{};
492 PlatformResult BluetoothGATTServerService::SetWriteValueRequestCallback(
493 const picojson::value& args) {
496 auto _id = static_cast<int>(args.get(kId).get<double>());
497 LoggerD("Setting write value request callback for a GATT entity with _id: %d", _id);
499 auto gatt_handle = gatt_objects_[_id];
500 callback_names_[std::make_pair(gatt_handle, kWriteCallback)] =
501 "WriteValueRequestCallback_" + std::to_string(_id);
503 auto write_value_request_callback = [](
504 const char* remote_address, int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle,
505 bool response_needed, int offset, const char* value, int len, void* user_data) -> void {
507 "WriteValueRequestCallback called. remote_address: %s, request_id: %d, response_needed: "
508 "%d, offset: %d, value: %s, len: %d",
509 remote_address, request_id, response_needed, offset, value, len);
510 auto rw_callback_data = static_cast<ReadWriteRequestCallbackData*>(user_data);
512 // We create a copy of value and remote_address
513 auto remote_address_copy = std::string{remote_address};
514 auto value_copy = std::string{value};
515 rw_callback_data->instance_.GetWorker().add_job([remote_address_copy, request_id, server,
516 gatt_handle, response_needed, offset, value_copy,
518 ScopeLogger("Async call: SetWriteValueRequestCallback");
520 auto write_value_request = picojson::value{picojson::object{}};
521 auto& write_value_request_obj = write_value_request.get<picojson::object>();
522 write_value_request_obj[kClientAddress] = picojson::value{remote_address_copy};
523 write_value_request_obj[kRequestId] = picojson::value{static_cast<double>(request_id)};
524 write_value_request_obj[kRequestType] = picojson::value{kWriteRequestType};
525 write_value_request_obj[kReplyRequired] = picojson::value{response_needed};
526 write_value_request_obj[kOffset] = picojson::value{static_cast<double>(offset)};
528 write_value_request_obj[kValue] = picojson::value{picojson::array{}};
529 auto& value_byte_array = write_value_request_obj[kValue].get<picojson::array>();
530 for (auto c: value_copy) {
531 value_byte_array.push_back(picojson::value{static_cast<double>(c)});
533 const auto callback_name =
534 rw_callback_data->callback_names_map_[std::make_pair(gatt_handle, kWriteCallback)];
535 LoggerD("Firing write value request event: %s: %s", callback_name.c_str(),
536 write_value_request.serialize().c_str());
537 rw_callback_data->instance_.FireEvent(callback_name, write_value_request);
541 auto ret = bt_gatt_server_set_write_value_requested_cb(gatt_handle, write_value_request_callback,
542 &rw_request_callback_data_);
543 if (BT_ERROR_NONE != ret) {
544 LoggerE("bt_gatt_server_set_write_value_requested_cb() failed: %d (%s)", ret,
545 get_error_message(ret));
546 return BluetoothErrorToPlatformResult(ret, "Failed to set write value request callback");
549 LoggerD("bt_gatt_server_set_write_value_requested_cb(): SUCCESS");
550 return common::PlatformResult{};
553 PlatformResult BluetoothGATTServerService::SendResponse(const picojson::value& args) {
554 ScopeLogger("Response: %s", args.serialize().c_str());
556 auto _id = static_cast<int>(args.get(kId).get<double>());
557 auto request_id = static_cast<int>(args.get(kRequestId).get<double>());
558 auto request_type_str = args.get(kRequestType).get<std::string>();
559 auto request_type = (request_type_str == kReadRequestType) ? BT_GATT_REQUEST_TYPE_READ
560 : BT_GATT_REQUEST_TYPE_WRITE;
561 auto offset = static_cast<int>(args.get(kOffset).get<double>());
562 auto status_code = static_cast<int>(args.get(kStatusCode).get<double>());
564 std::unique_ptr<char[]> value{nullptr};
566 if (args.get(kData).is<picojson::array>()) {
567 auto value_octets = args.get(kData).get<picojson::array>();
568 value_size = value_octets.size();
569 value = std::make_unique<char[]>(value_size);
570 for (int i = 0; i < value_size; ++i) {
571 value[i] += static_cast<int>(value_octets[i].get<double>());
578 "Sending response: _id: %d, requestId: %d, requestType: %s, offset: %d, statusCode: %d, "
579 "value: [%p], value size: %d",
580 _id, request_id, request_type_str.c_str(), offset, status_code, value.get(), value_size);
582 auto ret = bt_gatt_server_send_response(request_id, request_type, offset, status_code,
583 value.get(), value_size);
584 if (BT_ERROR_NONE != ret) {
585 LoggerE("bt_gatt_server_send_response() failed: %d (%s)", ret, get_error_message(ret));
586 return BluetoothErrorToPlatformResult(ret, "Failed to send response");
588 LoggerD("bt_gatt_server_send_response(): SUCCESS");
590 return common::PlatformResult{};
593 } // namespace bluetooth
594 } // namespace extension