2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
20 namespace Tizen.Network.Bluetooth
23 /// An extended EventArgs class contains the changed Bluetooth state.
25 public class StateChangedEventArgs : EventArgs
27 private BluetoothState _type;
28 private BluetoothError _result;
30 internal StateChangedEventArgs(BluetoothError result, BluetoothState type)
37 /// The state of Bluetooth.
39 public BluetoothState BTState
48 /// The BluetoothError result.
50 public BluetoothError Result
60 /// An extended EventArgs class contains the changed Bluetooth name.
62 public class NameChangedEventArgs : EventArgs
66 internal NameChangedEventArgs(string name)
72 /// The name of the device.
74 public string DeviceName
84 /// An extended EventArgs class contains the changed Bluetooth visibility mode.
86 public class VisibilityModeChangedEventArgs : EventArgs
88 private VisibilityMode _mode;
89 private BluetoothError _result;
91 internal VisibilityModeChangedEventArgs(BluetoothError result, VisibilityMode mode)
98 /// The visibility mode.
100 public VisibilityMode Visibility
109 /// The BluetoothError result.
111 public BluetoothError Result
121 /// An extended EventArgs class contains the duration until the visibility mode is changed from TimeLimitedDiscoverable to NonDiscoverable.
123 public class VisibilityDurationChangedEventArgs : EventArgs
125 private int _duration;
127 internal VisibilityDurationChangedEventArgs(int duration)
129 _duration = duration;
145 /// An extended EventArgs class contains the changed Bluetooth device discovery state and the discovered device information.
147 public class DiscoveryStateChangedEventArgs : EventArgs
149 private BluetoothError _result;
150 private BluetoothDeviceDiscoveryState _state;
151 private BluetoothDevice _device;
153 internal DiscoveryStateChangedEventArgs(BluetoothError result, BluetoothDeviceDiscoveryState state)
159 internal DiscoveryStateChangedEventArgs(BluetoothError result, BluetoothDeviceDiscoveryState state, BluetoothDevice device)
167 /// The BluetoothError result.
169 public BluetoothError Result
178 /// The state of the discovery.
180 public BluetoothDeviceDiscoveryState DiscoveryState
189 /// The remote device found.
191 public BluetoothDevice DeviceFound
201 /// An extended EventArgs class contains the bonded device information.
203 public class BondCreatedEventArgs : EventArgs
205 private BluetoothError _result;
206 private BluetoothDevice _device;
208 internal BondCreatedEventArgs(BluetoothError result, BluetoothDevice device)
215 /// The BluetoothError result.
217 public BluetoothError Result
226 /// The remote device.
228 public BluetoothDevice Device
238 /// An extended EventArgs class contains the address of the remote Bluetooth device to destroy bond with.
240 public class BondDestroyedEventArgs : EventArgs
242 private BluetoothError _result;
243 private string _address;
245 internal BondDestroyedEventArgs(BluetoothError result, string address)
252 /// The BluetoothError result.
254 public BluetoothError Result
263 /// The remote device address.
265 /// <value>The device address.</value>
266 public string DeviceAddress
276 /// An extended EventArgs class contains the authorization state and the address of the remote Bluetooth device.
278 public class AuthorizationChangedEventArgs : EventArgs
280 private BluetoothAuthorizationType _authType;
281 private string _address;
283 internal AuthorizationChangedEventArgs(BluetoothAuthorizationType authType, string address)
285 _authType = authType;
290 /// The authorization.
292 public BluetoothAuthorizationType Authorization
301 /// The device address.
303 public string DeviceAddress
314 /// An extended EventArgs class contains the service lists found on the remote Bluetooth device.
316 public class ServiceSearchedEventArgs : EventArgs
318 private BluetoothDeviceSdpData _sdpData;
319 private BluetoothError _result;
321 internal ServiceSearchedEventArgs(BluetoothError result, BluetoothDeviceSdpData sdpData)
328 /// The BluetoothError result.
330 public BluetoothError Result
340 public BluetoothDeviceSdpData SdpData
350 /// An extended EventArgs class contains the connection state and the connection information of the remote device.
352 public class DeviceConnectionStateChangedEventArgs : EventArgs
354 private bool _isConnected;
355 private BluetoothDeviceConnectionData _connectionData;
357 internal DeviceConnectionStateChangedEventArgs(bool isConnected, BluetoothDeviceConnectionData connectionData)
359 _isConnected = isConnected;
360 _connectionData = connectionData;
364 /// A value indicating whether the device is connected.
366 public bool IsConnected
375 /// The device connection data.
377 public BluetoothDeviceConnectionData ConnectionData
381 return _connectionData;
387 /// An extended EventArgs class contains the data received information.
389 public class SocketDataReceivedEventArgs : EventArgs
391 private SocketData _data;
393 internal SocketDataReceivedEventArgs(SocketData data)
401 public SocketData Data
411 /// An extended EventArgs class contains the changed connection state.
413 public class SocketConnectionStateChangedEventArgs : EventArgs
415 private BluetoothError _result;
416 private BluetoothSocketState _state;
417 private SocketConnection _connection;
419 internal SocketConnectionStateChangedEventArgs(BluetoothError result, BluetoothSocketState state, SocketConnection connection)
423 _connection = connection;
427 /// The BluetoothError result.
429 public BluetoothError Result
438 /// The socket state.
440 public BluetoothSocketState State
449 /// The socket connection.
451 public SocketConnection Connection
461 /// The AcceptStateChanged event is raised when the socket connection state is changed.
463 public class AcceptStateChangedEventArgs : EventArgs
465 private BluetoothError _result;
466 private BluetoothSocketState _state;
467 private SocketConnection _connection;
468 private IBluetoothServerSocket _server;
470 internal AcceptStateChangedEventArgs(BluetoothError result, BluetoothSocketState state, SocketConnection connection, BluetoothSocket server)
474 _connection = connection;
475 _server = (IBluetoothServerSocket)server;
479 /// The BluetoothError result.
481 public BluetoothError Result
490 /// The socket state.
492 public BluetoothSocketState State
501 /// The socket connection.
503 public SocketConnection Connection
512 /// The server socket instance.
514 public IBluetoothServerSocket Server
524 /// An extended EventArgs class contains the connection state, remote address, and the type of audio profile.
526 public class AudioConnectionStateChangedEventArgs : EventArgs
529 private bool _isConnected;
530 private string _address;
531 private BluetoothAudioProfileType _type;
533 internal AudioConnectionStateChangedEventArgs(int result, bool isConnected, string address, BluetoothAudioProfileType type)
537 _isConnected = isConnected;
553 /// A value indicating whether this instance is connected.
555 public bool IsConnected
566 public string Address
575 /// The type of the audio profile.
577 public BluetoothAudioProfileType ProfileType
587 /// An extended EventArgs class contains the connection state and the address of the remote Bluetooth device.
589 public class HidConnectionStateChangedEventArgs : EventArgs
592 private bool _isConnected;
593 private string _address;
595 internal HidConnectionStateChangedEventArgs(int result, bool isConnected, string address)
598 _isConnected = isConnected;
614 /// A value indicating whether this instance is connected.
616 public bool IsConnected
627 public string Address
637 /// An extended EventArgs class contains the changed equalizer state.
639 public class EqualizerStateChangedEventArgs : EventArgs
641 private EqualizerState _state;
643 internal EqualizerStateChangedEventArgs(EqualizerState state)
649 /// The state of the equalizer.
651 public EqualizerState State
661 /// An extended EventArgs class contains the changed repeat mode.
663 public class RepeatModeChangedEventArgs : EventArgs
665 private RepeatMode _mode;
667 internal RepeatModeChangedEventArgs(RepeatMode mode)
675 public RepeatMode Mode
685 /// An extended EventArgs class contains the changed shuffle mode.
687 public class ShuffleModeChangedeventArgs : EventArgs
689 private ShuffleMode _mode;
691 internal ShuffleModeChangedeventArgs(ShuffleMode mode)
697 /// The shuffle mode.
699 public ShuffleMode Mode
709 /// An extended EventArgs class contains the changed scan mode.
711 public class ScanModeChangedEventArgs : EventArgs
713 private ScanMode _mode;
715 internal ScanModeChangedEventArgs(ScanMode mode)
733 /// An extended EventArgs class contains the connection state and the remote device address.
735 public class TargetConnectionStateChangedEventArgs : EventArgs
737 private bool _isConnected;
738 private string _address;
740 internal TargetConnectionStateChangedEventArgs(bool isConnected, string address)
742 _isConnected = isConnected;
747 /// A value indicating whether this instance is connected.
749 public bool IsConnected
760 public string Address
770 /// An extended EventArgs class contains the changed Bluetooth LE advertising state changed information.
772 public class AdvertisingStateChangedEventArgs : EventArgs
774 private BluetoothLeAdvertisingState _state;
776 private IntPtr _advertiserHandle;
778 //TODO : Add conversion code from IntPtr to BluetoothLeAdvertiser class later
779 internal AdvertisingStateChangedEventArgs(int result, IntPtr advertiserHandle,
780 BluetoothLeAdvertisingState state)
783 _advertiserHandle = advertiserHandle;
799 /// The advertiser handle.
801 public IntPtr AdvertiserHandle
805 return _advertiserHandle;
810 /// The LE advertising state.
812 public BluetoothLeAdvertisingState State
822 /// An extended EventArgs class contains the changed Bluetooth LE scan result information.
824 public class AdapterLeScanResultChangedEventArgs : EventArgs
826 private BluetoothLeDevice _deviceData;
827 private BluetoothError _result;
829 internal AdapterLeScanResultChangedEventArgs(BluetoothError result, BluetoothLeDevice deviceData)
831 _deviceData = deviceData;
838 public BluetoothError Result
847 /// The LE device data.
849 public BluetoothLeDevice DeviceData
859 /// An extended EventArgs class contains the changed Bluetooth LE GATT connection state.
861 public class GattConnectionStateChangedEventArgs : EventArgs
863 private bool _isConnected;
865 private string _remoteAddress;
867 internal GattConnectionStateChangedEventArgs(int result, bool connected, string remoteAddress)
869 _isConnected = connected;
871 _remoteAddress = remoteAddress;
886 /// A value indicating whether this instance is connected.
888 public bool IsConnected
897 /// The remote address.
899 public string RemoteAddress
903 return _remoteAddress;
909 /// An extended EventArgs class contains the changed attribute value.
911 public class ValueChangedEventArgs : EventArgs
913 internal ValueChangedEventArgs(byte[] value)
919 /// The attribute value.
921 public byte[] Value { get; }
925 /// An extended EventArgs class contains the read value request data.
927 public class ReadRequestedEventArgs : EventArgs
929 internal ReadRequestedEventArgs(BluetoothGattServer server, string clientAddress, int requestId, int offset)
932 ClientAddress = clientAddress;
933 RequestId = requestId;
938 /// The GATT server instance.
940 public BluetoothGattServer Server { get; }
942 /// The client address.
944 public string ClientAddress { get; }
946 /// The request identifier.
948 public int RequestId { get; }
952 public int Offset { get; }
956 /// An extended EventArgs class contains the read value request data.
958 public class WriteRequestedEventArgs : EventArgs
960 internal WriteRequestedEventArgs(BluetoothGattServer server, string clientAddress, int requestId, byte[] value, int offset, bool response_needed)
963 ClientAddress = clientAddress;
964 RequestId = requestId;
967 Response_needed = response_needed;
971 /// The GATT server instance.
973 public BluetoothGattServer Server { get; }
975 /// The client address.
977 public string ClientAddress { get; }
979 /// The request identifier.
981 public int RequestId { get; }
985 public byte[] Value { get; }
989 public int Offset { get; }
991 /// Indicates whether a response is required by the remote device.
993 public bool Response_needed { get; }
997 /// An extended EventArgs class contains the client preference to enable or disable the Notification/Indication.
999 public class NotificationStateChangedEventArg : EventArgs
1001 internal NotificationStateChangedEventArg(BluetoothGattServer server, bool value)
1008 /// The GATT server instance.
1010 public BluetoothGattServer Server { get; }
1012 /// A value indicating whether the notification is enabled.
1014 public bool Value { get; }
1018 /// An extended EventArgs class contains the read value request data.
1020 public class NotificationSentEventArg : EventArgs
1022 internal NotificationSentEventArg(BluetoothGattServer server, string clientAddress, int result, bool completed)
1025 ClientAddress = clientAddress;
1027 Completed = completed;
1031 /// The GATT server instance.
1033 public BluetoothGattServer Server { get; }
1035 /// The client address.
1037 public string ClientAddress { get; }
1041 public int Result { get; }
1043 /// Gets a value indicating whether the notification sent is completed.
1045 public bool Completed { get; }
1049 /// An extended EventArgs class which contains the connection state and address of the remote Bluetooth device.
1051 public class ConnectionRequestedEventArgs : EventArgs
1053 private string _address;
1055 internal ConnectionRequestedEventArgs(string address)
1063 public string Address
1073 /// An extended EventArgs class which contains the file transfer progress state, file transfer progress by percent.
1075 public class TransferProgressEventArgs : EventArgs
1077 private string _file;
1079 private int _percent;
1081 internal TransferProgressEventArgs(string file, long size, int percent)
1111 /// The File transfer percent.
1123 /// An extended EventArgs class which contains the file transfer finished state and file state.
1125 public class TransferFinishedEventArgs : EventArgs
1127 private string _file;
1129 private int _result;
1131 internal TransferFinishedEventArgs(int result, string file, long size)
1161 /// The return value.
1173 /// An extended EventArgs class which contains the Push Request respond state
1176 public class PushRespondedEventArgs : EventArgs
1181 internal PushRespondedEventArgs(int result, string address)
1188 /// The return value.
1201 public string Address
1211 /// An extended EventArgs class which contains the file push progress state, push progress by percent.
1213 public class PushProgressEventArgs : EventArgs
1215 private string _file;
1217 private int _percent;
1219 internal PushProgressEventArgs(string file, long size, int percent)
1249 /// The File transfer percent.
1261 /// An extended EventArgs class which contains the Push Request respond state
1264 public class PushFinishedEventArgs : EventArgs
1269 internal PushFinishedEventArgs(int result, string address)
1276 /// The return value.
1289 public string Address