Fix BluetoothDevice.Name converting issue (#2499)
authorWootak Jung <wootak.jung@samsung.com>
Fri, 8 Jan 2021 00:47:46 +0000 (09:47 +0900)
committerGitHub <noreply@github.com>
Fri, 8 Jan 2021 00:47:46 +0000 (09:47 +0900)
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs

index 7ced7ef..af0744e 100644 (file)
@@ -63,8 +63,7 @@ namespace Tizen.Network.Bluetooth
         /// <summary>
         /// The name of the device.
         /// </summary>
-        [MarshalAsAttribute(UnmanagedType.LPTStr)]
-        internal string Name;
+        internal IntPtr Name;
 
         /// <summary>
         /// The class of the device.
@@ -241,6 +240,7 @@ namespace Tizen.Network.Bluetooth
     {
         internal static BluetoothDevice ConvertStructToDeviceClass(BluetoothDeviceStruct device)
         {
+            const int DeviceNameLengthMax = 248;
             BluetoothDevice resultDevice = new BluetoothDevice();
             Collection<string> uuidList = null;
 
@@ -256,7 +256,7 @@ namespace Tizen.Network.Bluetooth
             }
 
             resultDevice.RemoteDeviceAddress = device.Address;
-            resultDevice.RemoteDeviceName = device.Name;
+            resultDevice.RemoteDeviceName = Marshal.PtrToStringAnsi(device.Name, DeviceNameLengthMax);
             resultDevice.RemoteDeviceClass = new BluetoothClass();
             resultDevice.Class.MajorType = device.Class.MajorDeviceClassType;
             resultDevice.Class.MinorType = device.Class.MinorDeviceClassType;