/// <summary> /// Sets the hash and the randmoizer value of the OOB data into the remote device. /// </summary> /// <remarks> /// The Bluetooth must be enabled. /// </remarks> /// <param name="address">The remote device address.</param> /// <param name="oobData">The BluetoothOobData object.</param> /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled /// or the set OobData procedure is failed.</exception> /// <since_tizen> 3 </since_tizen> static public void SetRemoteOobData(string address, BluetoothOobData oobData) { if (IsBluetoothEnabled && Globals.IsInitialize) { BluetoothAdapterImpl.Instance.SetRemoteOobData(address, oobData); } }
internal BluetoothOobData GetLocalOobData() { BluetoothOobData oobData = new BluetoothOobData(); IntPtr hash; IntPtr randomizer; int hashLength; int randomizerLength; int ret = Interop.Bluetooth.GetOobData(out hash, out randomizer, out hashLength, out randomizerLength); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to get the local oob data, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } if (hashLength > 0) { byte[] hashArr = new byte[hashLength]; Marshal.Copy(hash, hashArr, 0, hashLength); oobData.HashValue = hashArr; Interop.Libc.Free(hash); } if (randomizerLength > 0) { byte[] randomizerArr = new byte[randomizerLength]; Marshal.Copy(randomizer, randomizerArr, 0, randomizerLength); oobData.RandomizerValue = randomizerArr; Interop.Libc.Free(randomizer); } return(oobData); }
internal void SetRemoteOobData(string deviceAddress, BluetoothOobData oobData) { byte[] hash = oobData.HashValue; byte[] randomizer = oobData.RandomizerValue; int hashLength = hash.Length; int randomizerLength = randomizer.Length; IntPtr hashPtr = Marshal.AllocHGlobal(hashLength); Marshal.Copy(hash, 0, hashPtr, hashLength); IntPtr randomizerPtr = Marshal.AllocHGlobal(randomizerLength); Marshal.Copy(randomizer, 0, randomizerPtr, randomizerLength); int ret = Interop.Bluetooth.SetOobData(deviceAddress, hashPtr, randomizerPtr, hashLength, randomizerLength); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to set the remote oob data, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } }