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;
21 namespace Tizen.System
24 /// The IR API provides functions to control a IR transmitter.
25 /// The IR API provides the way to get the information whether IR is available and transmit IR command.
28 /// http://tizen.org/privilege/use_ir
31 /// Console.WriteLine("IR availablity for this device is: {0}", IR.IsAvailable);
33 public static class IR
36 /// Gets the information whether IR module is available.
38 /// <since_tizen> 3 </since_tizen>
39 public static bool IsAvailable
43 bool available = false;
44 DeviceError res = (DeviceError)Interop.Device.DeviceIRIsAvailable(out available);
45 if (res != DeviceError.None)
47 Log.Warn(DeviceExceptionFactory.LogTag, "unable to get ir status.");
54 /// Transmits IR command.
56 /// <since_tizen> 3 </since_tizen>
57 /// <param name="carrierFreequency">
58 /// Carrier frequency to transmit IR command (Hertz).
60 /// <param name="pattern">
61 /// IR command list of type interger.
63 /// <exception cref="ArgumentException"> When the invalid parameter value is set.</exception>
64 /// <exception cref = "UnauthorizedAccessException"> If the privilege is not set.</exception>
65 /// <exception cref = "InvalidOperationException"> In case of any system error.</exception>
66 /// <exception cref = "NotSupportedException"> In case of device does not support this behavior.</exception>
70 /// List<int> pattern = new List<int>();
73 /// IR.Transmit(60657, pattern);
75 /// catch(Exception e)
79 public static void Transmit(int carrierFreequency, IList<int> pattern)
81 int[] patternArray = pattern.ToArray();
82 DeviceError res = (DeviceError)Interop.Device.DeviceIRTransmit(carrierFreequency, patternArray, pattern.Count());
83 if (res != DeviceError.None)
85 throw DeviceExceptionFactory.CreateException(res, "unable to trasmit IR command.");