4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
28 #define METHOD_GET_BRIGHTNESS "GetBrightness"
29 #define METHOD_GET_MAX_BRIGHTNESS "GetMaxBrightness"
30 #define METHOD_SET_BRIGHTNESS "SetBrightness"
31 #define METHOD_SET_IR_COMMAND "SetIrCommand"
32 #define METHOD_SET_MODE "SetMode"
34 API int led_get_brightness(void)
40 msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
41 DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
42 METHOD_GET_BRIGHTNESS, NULL, NULL);
46 dbus_error_init(&err);
48 ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
50 _E("no message : [%s:%s]", err.name, err.message);
51 dbus_error_free(&err);
55 dbus_message_unref(msg);
59 API int led_get_max_brightness(void)
65 msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
66 DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
67 METHOD_GET_MAX_BRIGHTNESS, NULL, NULL);
71 dbus_error_init(&err);
73 ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
75 _E("no message : [%s:%s]", err.name, err.message);
76 dbus_error_free(&err);
80 dbus_message_unref(msg);
84 API int led_set_brightness_with_noti(int val, bool enable)
93 snprintf(buf_val, sizeof(buf_val), "%d", val);
95 snprintf(buf_noti, sizeof(buf_noti), "%d", enable);
98 msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
99 DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
100 METHOD_SET_BRIGHTNESS, "ii", arr);
104 dbus_error_init(&err);
106 ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
108 _E("no message : [%s:%s]", err.name, err.message);
109 dbus_error_free(&err);
113 dbus_message_unref(msg);
117 API int led_set_ir_command(char *value)
126 msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
127 DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
128 METHOD_SET_IR_COMMAND, "s", arr);
132 dbus_error_init(&err);
134 ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
136 _E("no message : [%s:%s]", err.name, err.message);
137 dbus_error_free(&err);
141 dbus_message_unref(msg);
145 API int led_set_mode_with_property(int mode, bool val, int on, int off, unsigned int color)
150 char buf_mode[32], buf_val[32];
151 char buf_on[32], buf_off[32];
155 snprintf(buf_mode, sizeof(buf_mode), "%d", mode);
157 snprintf(buf_val, sizeof(buf_val), "%d", val);
159 snprintf(buf_on, sizeof(buf_on), "%d", on);
161 snprintf(buf_off, sizeof(buf_off), "%d", off);
163 snprintf(buf_color, sizeof(buf_color), "%lu", color);
166 return dbus_method_sync(DEVICED_BUS_NAME,
167 DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
168 METHOD_SET_MODE, "iiiiu", arr);
171 API int led_set_mode_with_color(int mode, bool on, unsigned int color)
173 return led_set_mode_with_property(mode, on, -1, -1, color);