[Bluetooth] Fix the re-register GATT server issue (#688) (#688)
authordh79pyun <31202060+dh79pyun@users.noreply.github.com>
Wed, 30 Jan 2019 04:22:15 +0000 (13:22 +0900)
committerGitHub <noreply@github.com>
Wed, 30 Jan 2019 04:22:15 +0000 (13:22 +0900)
* [Bluetooth] Fix the re-register GATT server issue

* Update BluetoothGattImpl.cs

* Update BluetoothGattImpl.cs

* Update BluetoothGattImpl.cs

src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGattImpl.cs

index 39530db..bf8b842 100644 (file)
@@ -637,8 +637,22 @@ namespace Tizen.Network.Bluetooth
         {
             if (_hasOwnership == true)
             {
-                Interop.Bluetooth.BtGattServerDeinitialize();
-                Interop.Bluetooth.BtGattServerDestroy(handle);
+                int err;
+
+                err = Interop.Bluetooth.BtGattServerDestroy(handle);
+                if (err.IsFailed())
+                {
+                    Log.Error(Globals.LogTag, "Failed to destroy the server instance");
+                    return false;
+                }
+
+                err = Interop.Bluetooth.BtGattServerDeinitialize();
+                if (err.IsFailed())
+                {
+                    Log.Error(Globals.LogTag, "Failed to deinitialize");
+                    SetHandle(IntPtr.Zero);
+                    return false;
+                }
             }
             SetHandle(IntPtr.Zero);
             return true;