/// <summary> /// Connects the remote device with the HID service. /// </summary> /// <remarks> /// The device must be bonded with the remote device by CreateBond(). /// If connection request succeeds, the HidConnectionStateChanged event will be invoked. /// </remarks> /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled /// or when the connection attempt to the remote device fails.</exception> /// <since_tizen> 3 </since_tizen> public void Connect() { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = BluetoothHidImpl.Instance.Connect(RemoteAddress); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to Connect - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
internal void NotifyAgVoiceRecognitionState(bool enable) { if (Globals.IsAudioInitialize) { int ret = Interop.Bluetooth.NotifyAgVoiceRecognitionState(enable); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to notify sco voice recognition state, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotInitialized); } }
/// <summary> /// Adds a service UUID to the advertise or the scan response data. /// The maximum advertised or responded data size is 31 bytes /// including the data type and the system wide data. /// </summary> /// <remarks> /// The Bluetooth must be enabled. /// </remarks> /// <param name="packetType">The packet type.</param> /// <param name="serviceUuid"> The service UUID to add to advertise data.</param> /// <exception cref="NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the Bluetooth LE is not enabled /// or when the add advertising service UUID procedure fails.</exception> /// <since_tizen> 3 </since_tizen> public void AddAdvertisingServiceUuid(BluetoothLePacketType packetType, string serviceUuid) { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = Interop.Bluetooth.AddAdvertisingServiceUuid(GetHandle(), packetType, serviceUuid); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to add service uuid to advertising data- " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
internal void Disable() { if (IsBluetoothEnabled) { int ret = Interop.Bluetooth.DisableAdapter(); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to disable adapter, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
internal void Enable() { if (Globals.IsInitialize) { int ret = Interop.Bluetooth.EnableAdapter(); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to enable adapter, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotInitialized); } }
internal void SetVisibility(VisibilityMode mode, int timeout) { if (IsBluetoothEnabled) { int ret = Interop.Bluetooth.SetVisibility(mode, timeout); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to set visibility, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
/// <summary> /// Stops the Bluetooth LE scan operation. /// </summary> /// <remarks> /// The Bluetooth must be enabled. /// </remarks>The result of the operation stopLescan. /// <exception cref="NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the Bluetooth LE is not enabled /// or the Stop LE scan is failed.</exception> /// <since_tizen> 3 </since_tizen> static public void StopLeScan() { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = BluetoothLeImplAdapter.Instance.StopScan(); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to stop the le scan operation, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
private void targetDeinitialize() { if (Globals.IsAudioInitialize) { int ret = Interop.Bluetooth.DeinitializeAvrcp(); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to deinitialize bluetooth avrcp, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } else { Globals.IsAudioInitialize = false; } } }
/// <summary> /// Reject File Push request. /// </summary> /// <feature>http://tizen.org/feature/network.bluetooth.opp</feature> /// <exception cref="NotSupportedException">Thrown when the required feature is not Supported.</exception> /// <exception cref="NotSupportedException">Thrown when the BT/BTLE is not Supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not Enabled or Other Bluetooth Errors.</exception> /// <since_tizen> 4 </since_tizen> public void RejectPush() { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = _impl.RejectPush(); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to Reject Push - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
/// <summary> /// Pushes the file set through AddFile. /// </summary> /// <param name="Destination"> destination device address.</param> /// <feature>http://tizen.org/feature/network.bluetooth.opp</feature> /// <exception cref="NotSupportedException">Thrown when the required feature is not Supported.</exception> /// <exception cref="NotSupportedException">Thrown when the BT/BTLE is not Supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not Enabled or Other Bluetooth Errors.</exception> /// <since_tizen> 4 </since_tizen> public void PushFile(string Destination) { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = BluetoothOppClientImpl.Instance.PushFile(Destination); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to Cancel Push Operation - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
/// <summary> /// Starts advertising using the advertise data object. /// </summary> /// <remarks> /// The Bluetooth must be enabled. /// </remarks> /// <param name="advertiseData">The advertiser object carrying information of the advertising.</param> /// <exception cref="NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the Bluetooth LE is not enabled.</exception> /// <since_tizen> 3 </since_tizen> public void StartAdvertising(BluetoothLeAdvertiseData advertiseData) { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = BluetoothLeImplAdapter.Instance.StartAdvertising(advertiseData.GetHandle()); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to start advertising- " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
/// <summary> /// Add File path to be pushed. /// </summary> /// <param name="FilePath"> file for sending.</param> /// <feature>http://tizen.org/feature/network.bluetooth.opp</feature> /// <exception cref="NotSupportedException">Thrown when the required feature is not Supported.</exception> /// <exception cref="NotSupportedException">Thrown when the BT/BTLE is not Supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not Enabled or Other Bluetooth Errors.</exception> /// <since_tizen> 4 </since_tizen> public void AddFile(string FilePath) { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = BluetoothOppClientImpl.Instance.AddFile(FilePath); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to Set File Path - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
/// <summary> /// Clears all the File paths. /// </summary> /// <feature>http://tizen.org/feature/network.bluetooth.opp</feature> /// <exception cref="NotSupportedException">Thrown when the required feature is not Supported.</exception> /// <exception cref="NotSupportedException">Thrown when the BT/BTLE is not Supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not Enabled or Other Bluetooth Errors.</exception> /// <since_tizen> 4 </since_tizen> public void ClearFiles() { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = BluetoothOppClientImpl.Instance.ClearFile(); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to Clear the Files - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
/// <summary> /// Cancel the ongoing transfer session. /// </summary> /// <param name="TransferId"> tranfer ID.</param> /// <feature>http://tizen.org/feature/network.bluetooth.opp</feature> /// <exception cref="NotSupportedException">Thrown when the required feature is not Supported.</exception> /// <exception cref="NotSupportedException">Thrown when the BT/BTLE is not Supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not Enabled or Other Bluetooth Errors.</exception> /// <since_tizen> 4 </since_tizen> public void CancelTransfer(int TransferId) { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = _impl.CancelTransferId(TransferId); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to Cancel Transfer - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
/// <summary> /// Cancel the ongoing transfer session. /// </summary> /// <param name="FilePath"> Path to store the files.</param> /// <feature>http://tizen.org/feature/network.bluetooth.opp</feature> /// <exception cref="NotSupportedException">Thrown when the required feature is not Supported.</exception> /// <exception cref="NotSupportedException">Thrown when the BT/BTLE is not Supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not Enabled or Other Bluetooth Errors.</exception> /// <since_tizen> 4 </since_tizen> public void SetDestinationPath(string FilePath) { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = _impl.SetDestinationPath(FilePath); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to Set Destination Path - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
/// <summary> /// Disconnects the remote device with the given audio profile. /// </summary> /// <remarks> /// The device must be connected by Connect(). If the disconnection request succeeds, the AudioConnectionStateChanged event will be invoked. /// If audio profile type is All and this request succeeds, then the AudioConnectionStateChanged event will be called twice when HspHfp <br/> /// and AdvancedAudioDistribution is disconnected. /// </remarks> /// <param name="type">The type of the audio profile.</param> /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled /// or when Disconnection attempt fails.</exception> /// <since_tizen> 3 </since_tizen> public void Disconnect(BluetoothAudioProfileType type) { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = BluetoothAudioImpl.Instance.Disconnect(RemoteAddress, type); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to Disconnect - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
internal void SelectRole(BluetoothAudioRole role) { if (Globals.IsAudioInitialize) { int ret = Interop.Bluetooth.SelectAudioRole(role); if (ret != (int)BluetoothError.None && ret != (int)BluetoothError.AlreadyDone) { Log.Error(Globals.LogTag, "Failed to select audio role, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotInitialized); } }
private static void RegisterConnectionRequestedEvent() { _connectionRequestedCallback = (int socketFd, string remoteAddress, IntPtr userData) => { Log.Info(Globals.LogTag, "SocketConnectionRequestedCallback is called"); _connectionRequested?.Invoke(null, new SocketConnectionRequestedEventArgs(socketFd, remoteAddress)); }; int ret = Interop.Bluetooth.SetSocketConnectionRequestedCallback(_connectionRequestedCallback, IntPtr.Zero); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to set connection requested callback, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } }
internal void OpenAgSco() { if (Globals.IsAudioInitialize) { int ret = Interop.Bluetooth.OpenAgSco(); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to open ag sco to remote device, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotInitialized); } }
private void Deinitialize() { if (Globals.IsOppClientInitialized) { int ret = Interop.Bluetooth.DeinitializeOppClient(); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to deinitialize Opp Client, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } else { Globals.IsOppClientInitialized = false; } } }
public Task <SocketConnection> AcceptAsync() { if (_taskForAccept != null && !_taskForAccept.Task.IsCompleted) { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NowInProgress); } _taskForAccept = new TaskCompletionSource <SocketConnection>(); int ret = Interop.Bluetooth.Accept(socketFd); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to accept connection, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } return(_taskForAccept.Task); }
/// <summary> /// The default constructor initializes an object of the BluetoothLeAdvertiseData. /// </summary> /// <exception cref="NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the Bluetooth LE is not enabled /// or when create advertiser fails.</exception> /// <since_tizen> 3 </since_tizen> public BluetoothLeAdvertiseData() { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { Log.Debug(Globals.LogTag, " Creating LeAdvertiser()"); int ret = Interop.Bluetooth.CreateAdvertiser(out _handle); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to create advertiser object- " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
internal BluetoothDevice GetBondedDevice(string address) { IntPtr deviceInfo; BluetoothDevice btDevice; int ret = Interop.Bluetooth.GetBondedDeviceByAddress(address, out deviceInfo); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to get bonded device by address, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } BluetoothDeviceStruct device = (BluetoothDeviceStruct)Marshal.PtrToStructure(deviceInfo, typeof(BluetoothDeviceStruct)); btDevice = BluetoothUtils.ConvertStructToDeviceClass(device); Interop.Bluetooth.FreeDeviceInfo(deviceInfo); return(btDevice); }
public Task DisconnectAsync() { if (_taskForDisconnection != null && !_taskForDisconnection.Task.IsCompleted) { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NowInProgress); } _taskForDisconnection = new TaskCompletionSource <bool>(); int ret = BluetoothHidDeviceImpl.Instance.DisconnectHidDevice(RemoteAddress); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to disconnect to the remote device, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } return(_taskForDisconnection.Task); }
internal ManufacturerData GetScanResultManufacturerData(BluetoothLeScanData scanData, BluetoothLePacketType packetType) { if (!BluetoothAdapter.IsBluetoothEnabled || !Globals.IsInitialize) { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } int dataId = 0; int dataLength = 0; IntPtr manufData; BluetoothLeScanDataStruct scanDataStruct = BluetoothUtils.ConvertLeScanDataToStruct(scanData); int ret = Interop.Bluetooth.GetScanResultManufacturerData(ref scanDataStruct, packetType, out dataId, out manufData, out dataLength); if (ret == (int)BluetoothError.NoData) { Log.Info(Globals.LogTag, "No ManufacturerData in " + packetType); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); return(null); } else if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to get Manufacturer data - " + (BluetoothError)ret); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); BluetoothErrorFactory.ThrowBluetoothException(ret); } Log.Info(Globals.LogTag, "Count of ManufacturerData: " + dataLength); ManufacturerData data = new ManufacturerData(); data.Id = dataId; data.DataLength = dataLength; if (data.DataLength > 0) { data.Data = new byte[data.DataLength]; Marshal.Copy(manufData, data.Data, 0, data.DataLength); } Interop.Libc.Free(manufData); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); return(data); }
internal IList <BluetoothLeServiceData> GetScanResultServiceDataList(BluetoothLeScanData scanData, BluetoothLePacketType packetType) { if (!BluetoothAdapter.IsBluetoothEnabled || !Globals.IsInitialize) { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } IntPtr serviceListArray; _serviceListCount = 0; BluetoothLeScanDataStruct scanDataStruct = BluetoothUtils.ConvertLeScanDataToStruct(scanData); int ret = Interop.Bluetooth.GetScanResultServiceDataList(ref scanDataStruct, packetType, out serviceListArray, out _serviceListCount); if (ret == (int)BluetoothError.NoData) { Log.Info(Globals.LogTag, "No ServiceDataList in " + packetType); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); return(null); } else if (ret != (int)BluetoothError.None) { Log.Info(Globals.LogTag, "Failed to get Service Data List, Error - " + (BluetoothError)ret); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); BluetoothErrorFactory.ThrowBluetoothException(ret); } Log.Info(Globals.LogTag, "Count of ServiceDataList: " + _serviceListCount); IList <BluetoothLeServiceData> list = new List <BluetoothLeServiceData>(); int sizePointerToABC = Marshal.SizeOf(new BluetoothLeServiceDataStruct()); for (int i = 0; i < _serviceListCount; i++) { var svc = (BluetoothLeServiceDataStruct)Marshal.PtrToStructure(new IntPtr(serviceListArray.ToInt32() + (i * sizePointerToABC)), typeof(BluetoothLeServiceDataStruct)); list.Add(BluetoothUtils.ConvertStructToLeServiceData(svc)); } Interop.Bluetooth.FreeServiceDataList(serviceListArray, _serviceListCount); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); return(list); }
internal IList <string> GetScanResultSvcSolicitationUuids(BluetoothLeScanData scanData, BluetoothLePacketType packetType) { if (!BluetoothAdapter.IsBluetoothEnabled || !Globals.IsInitialize) { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } IntPtr uuidListArray; int count; BluetoothLeScanDataStruct scanDataStruct = BluetoothUtils.ConvertLeScanDataToStruct(scanData); int ret = Interop.Bluetooth.GetScanResultSvcSolicitationUuids(ref scanDataStruct, packetType, out uuidListArray, out count); if (ret == (int)BluetoothError.NoData) { Log.Info(Globals.LogTag, "No ServiceSolicitationUuids in " + packetType); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); return(null); } else if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to get service solicitation uuids " + (BluetoothError)ret); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); BluetoothErrorFactory.ThrowBluetoothException(ret); } Log.Info(Globals.LogTag, "Count of ServiceSolicitationUuids: " + count); IList <string> list = new List <string>(); IntPtr[] uuidList = new IntPtr[count]; Marshal.Copy(uuidListArray, uuidList, 0, count); foreach (IntPtr uuids in uuidList) { list.Add(Marshal.PtrToStringAnsi(uuids)); Interop.Libc.Free(uuids); } Interop.Libc.Free(uuidListArray); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); return(list); }
internal void NotifyTrack(Track trackData) { string title = trackData.Title; string artist = trackData.Artist; string album = trackData.Album; string genre = trackData.Genre; uint trackNum = trackData.TrackNum; uint totalTracks = trackData.TotalTracks; uint duration = trackData.Duration; int ret = Interop.Bluetooth.NotifyTrack(title, artist, album, genre, trackNum, totalTracks, duration); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to notify track data to the remote device, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } }
/// <summary> /// Accept File Push request. /// </summary> /// <returns>The id of transfer.</returns> /// <param name="FileName"> File name to accept.</param> /// <feature>http://tizen.org/feature/network.bluetooth.opp</feature> /// <exception cref="NotSupportedException">Thrown when the required feature is not Supported.</exception> /// <exception cref="NotSupportedException">Thrown when the BT/BTLE is not Supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not Enabled or Other Bluetooth Errors.</exception> /// <since_tizen> 4 </since_tizen> public int AcceptPush(string FileName) { int _transitionId = -1; if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = _impl.AcceptPush(FileName, out _transitionId); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to Accept Push - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } return(_transitionId); }
internal int FreeServiceDataList() { if (_list.Count > 0) { int iServiceDataSize = Marshal.SizeOf(typeof(BluetoothLeServiceData)); IntPtr structServiceData = Marshal.AllocHGlobal(iServiceDataSize); Marshal.StructureToPtr(_list, structServiceData, false); int ret = Interop.Bluetooth.FreeServiceDataList(structServiceData, _serviceListCount); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to free Service Data List, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } Marshal.FreeHGlobal(structServiceData); } return(0); }