From: Wootak Jung Date: Wed, 12 Oct 2022 08:11:19 +0000 (+0900) Subject: Add device sorting logic with the rssi X-Git-Tag: accepted/tizen/unified/20221111.105330~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01f2c544781162e3450d26f0a0a7ba1cfaca94ae;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsetting-bluetooth.git Add device sorting logic with the rssi Change-Id: I170b213797fbc602bfd1954616c17506fe5bfa7d Signed-off-by: Wootak Jung --- diff --git a/SettingBluetooth/SettingBluetooth/Model/BtDevice.cs b/SettingBluetooth/SettingBluetooth/Model/BtDevice.cs index 4ce0a43..d7e5dbf 100644 --- a/SettingBluetooth/SettingBluetooth/Model/BtDevice.cs +++ b/SettingBluetooth/SettingBluetooth/Model/BtDevice.cs @@ -17,6 +17,7 @@ namespace SettingBluetooth.Model private string[] mServiceUuids = null; private BluetoothServiceClassType mServiceMask = 0; private BtDeviceIcon mDeviceIcon; + private int mRssi = 0; private bool mIsA2dpSupported = false; private BluetoothAudio mBluetoothAudio = null; @@ -33,6 +34,7 @@ namespace SettingBluetooth.Model mIsPaired = device.IsPaired; mDeviceState = state; mBluetoothDevice = device; + mRssi = device.Rssi; if (device.ServiceCount > 0) { mServiceUuids = new string[device.ServiceCount]; @@ -213,6 +215,14 @@ namespace SettingBluetooth.Model } } + internal int Rssi + { + get + { + return mRssi; + } + } + private void BluetoothDeviceBondCreated(object obj, BondCreatedEventArgs ev) { Log.Info(Program.LogTag, "BluetoothDeviceBondCreated. Address: " + ev.Device.Address + ", IsPaired: " + ev.Device.IsPaired); diff --git a/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs b/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs index 7e3d1d7..936e8db 100644 --- a/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs +++ b/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs @@ -22,6 +22,7 @@ namespace SettingBluetooth public event PropertyChangedEventHandler PropertyChanged; BtDevice mBtDevice; private string mState; + private int mRssi; private void OnPropertyChanged(string propertyName) { @@ -144,6 +145,14 @@ namespace SettingBluetooth OnPropertyChanged("ImageUrl"); } } + + public int Rssi + { + get + { + return mRssi; + } + } } public class DeviceCollection : ObservableCollection @@ -170,7 +179,29 @@ namespace SettingBluetooth internal void AddDevice(BtDevice btDevice) { - this.Add(new Device(btDevice)); + if (this.Count == 0) + { + this.Add(new Device(btDevice)); + } + else + { + bool added = false; + foreach (var item in this) + { + if (btDevice.Rssi > item.Rssi) + { + int idx = this.IndexOf(item); + this.Insert(idx, new Device(btDevice)); + added = true; + break; + } + } + if (added == false) + { + this.Add(new Device(btDevice)); + } + } + //this.Add(new Device(btDevice)); Log.Info(Program.LogTag, "device(" + btDevice.Address + ") added"); } diff --git a/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk b/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk index 786e18a..4aa70ef 100644 Binary files a/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk and b/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk differ