[BluetoothLE] Return NotFound error if UUID is invalid.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 19 Aug 2015 06:34:55 +0000 (08:34 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 20 Aug 2015 09:22:01 +0000 (11:22 +0200)
[Verification] BluetoothLEDevice_getService_NotFoundError should pass.

Change-Id: Ifd7b89448e02ebd1c964ee9bb5e8d369f967ed9b
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/bluetooth/bluetooth_gatt_service.cc

index 2474bb2489acf36a9b4b653a7371a6d7f7a01c74..03d8524d2fb9256802b92c6dba3001840666e8cb 100755 (executable)
@@ -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");
     }
   }