From f3d0c2f7afefbeaf15e0d4988bd6f2820dd1144b Mon Sep 17 00:00:00 2001 From: Pawel Andruszkiewicz Date: Wed, 19 Aug 2015 08:34:55 +0200 Subject: [PATCH] [BluetoothLE] Return NotFound error if UUID is invalid. [Verification] BluetoothLEDevice_getService_NotFoundError should pass. Change-Id: Ifd7b89448e02ebd1c964ee9bb5e8d369f967ed9b Signed-off-by: Pawel Andruszkiewicz --- src/bluetooth/bluetooth_gatt_service.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bluetooth/bluetooth_gatt_service.cc b/src/bluetooth/bluetooth_gatt_service.cc index 2474bb24..03d8524d 100755 --- a/src/bluetooth/bluetooth_gatt_service.cc +++ b/src/bluetooth/bluetooth_gatt_service.cc @@ -131,10 +131,15 @@ PlatformResult BluetoothGATTService::GetSpecifiedGATTService(const std::string & int ret = bt_gatt_client_get_service(client, uuid.c_str(), &service); if (BT_ERROR_NONE != ret) { LoggerE("bt_gatt_client_get_service() error: %d", ret); - if (BT_ERROR_NO_DATA == ret) { - return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Service not found"); - } else { - return util::GetBluetoothError(ret, "Failed to get a service's GATT handle"); + switch (ret) { + case BT_ERROR_NO_DATA: + return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Service not found"); + + case BT_ERROR_INVALID_PARAMETER: + return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Service UUID is invalid"); + + default: + return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get a service's GATT handle"); } } -- 2.34.1