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 the functions to control the IR transmitter.
25 /// The IR API provides the way to get the information if IR is available and then transmit the IR command.
28 /// http://tizen.org/privilege/use_ir
32 /// Console.WriteLine("IR availability for this device is: {0}", IR.IsAvailable);
35 /// <since_tizen> 3 </since_tizen>
36 public static class IR
39 /// Gets the information whether the IR module is available.
41 /// <since_tizen> 3 </since_tizen>
42 public static bool IsAvailable
46 bool available = false;
47 DeviceError res = (DeviceError)Interop.Device.DeviceIRIsAvailable(out available);
48 if (res != DeviceError.None)
50 Log.Warn(DeviceExceptionFactory.LogTag, "unable to get ir status.");
57 /// Transmits the IR command.
59 /// <since_tizen> 3 </since_tizen>
60 /// <param name="carrierFreequency">
61 /// The carrier frequency to transmit the IR command (Hertz).
63 /// <param name="pattern">
64 /// The IR command list of type integer.
66 /// <exception cref="ArgumentException"> When an invalid parameter value is set.</exception>
67 /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
68 /// <exception cref="InvalidOperationException">In case of any system error.</exception>
69 /// <exception cref="NotSupportedException">In case the device does not support this behavior.</exception>
74 /// List<int> pattern = new List<int>();
77 /// IR.Transmit(60657, pattern);
79 /// catch(Exception e)
84 public static void Transmit(int carrierFreequency, IList<int> pattern)
86 int[] patternArray = pattern.ToArray();
87 DeviceError res = (DeviceError)Interop.Device.DeviceIRTransmit(carrierFreequency, patternArray, pattern.Count());
88 if (res != DeviceError.None)
90 throw DeviceExceptionFactory.CreateException(res, "unable to trasmit IR command.");