case DeviceError.InvalidParameter:
exp = new ArgumentException(msg);
break;
- case DeviceError.AlreadyInProgress:
- //fall through
case DeviceError.NotSupported:
+ exp = new InvalidOperationException(msg +" : Device does not support the Operation.");
+ break;
+ case DeviceError.AlreadyInProgress:
//fall through
case DeviceError.ResourceBusy:
//fall through
--- /dev/null
+using System;
+
+namespace Tizen.System
+{
+ /// <summary>
+ /// The IR API provides functions to control a IR transmitter.
+ /// The IR API provides the way to get the information whether IR is available and transmit IR command.
+ /// </summary>
+ public static class IR
+ {
+ /// <summary>
+ /// Gets the information whether IR module is available.
+ /// </summary>
+ public bool IsAvailable
+ {
+ get
+ {
+ bool available = false;
+ DeviceError res = (DeviceError) Interop.Device.DeviceIRIsAvailable(out available);
+ if (res != DeviceError.None)
+ {
+ Log.Warn(DeviceExceptionFactory.LogTag, "unable to get ir status.");
+ }
+ return available;
+ }
+ }
+
+ /// <summary>
+ /// Transmits IR command.
+ /// </summary>
+ /// <param name="carrierFreequency">
+ /// Carrier frequency to transmit IR command (Hertz).
+ /// </param>
+ /// <param name="pattern">
+ /// IR command list of type interger.
+ /// </param>
+ public void Transmit(int carrierFreequency, IList<int> pattern)
+ {
+ int[] patternArray = pattern.toArray();
+ DeviceError res = (DeviceError) Interop.Device.DeviceIRTransmit(carrierFreequency, patternArray, pattern.Count());
+ if (res != DeviceError.None)
+ {
+ throw DeviceExceptionFactory.CreateException(res, "unable to trasmit IR command.");
+ }
+ }
+ }
+}
DeviceError res = (DeviceError)Interop.Device.DeviceLedPlayCustom(on, off, color, 1);
if (res != DeviceError.None)
{
- throw DeviceExceptionFactory.CreateException(DeviceError.InvalidParameter, "failed to play Led.");
+ throw DeviceExceptionFactory.CreateException(res, "failed to play Led.");
}
}
DeviceError res = (DeviceError) Interop.Device.DeviceLedStopCustom();
if(res != DeviceError.None)
{
- throw DeviceExceptionFactory.CreateException(DeviceError.InvalidParameter, "failed to stop Led.");
+ throw DeviceExceptionFactory.CreateException(res, "failed to stop Led.");
}
}
FlashBrightness
}
}
-
internal static class Interop
{
internal static partial class Device
[DllImport("libcapi-system-device.so.0", EntryPoint = "device_power_release_lock", CallingConvention = CallingConvention.Cdecl)]
internal static extern int DevicePowerReleaseLock(int type);
+ //IR
+ [DllImport("libcapi-system-device.so.0", EntryPoint = "device_ir_is_available", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int DeviceIRIsAvailable(out bool available);
+ [DllImport("libcapi-system-device.so.0", EntryPoint = "device_ir_transmit", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int DeviceIRTransmit(int carrierFreequency, int[] pattern, int size);
+
// Callback
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate bool deviceCallback(int type, IntPtr value, IntPtr data);
<Compile Include="Device\Haptic.cs" />
<Compile Include="Device\Led.cs" />
<Compile Include="Device\Power.cs" />
+ <Compile Include="Device\IR.cs" />
<Compile Include="Device\DeviceEventArgs.cs" />
<Compile Include="Interop\Interop.Device.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />