sensord: add set_attribute_* API for internal
[platform/core/system/sensord.git] / src / shared / command_common.h
1 /*
2  * libsensord-share
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19
20 #ifndef _COMMAND_COMMON_H_
21 #define _COMMAND_COMMON_H_
22
23 #include <sensor_common.h>
24
25 #define COMMAND_CHANNEL_PATH                    "/tmp/sensord_command_socket"
26 #define EVENT_CHANNEL_PATH                              "/tmp/sensord_event_socket"
27
28 #define MAX_HANDLE                      256
29 #define MAX_HANDLE_REACHED      -2
30
31 enum packet_type_t {
32         CMD_NONE = 0,
33         CMD_GET_ID,
34         CMD_GET_SENSOR_LIST,
35         CMD_HELLO,
36         CMD_BYEBYE,
37         CMD_DONE,
38         CMD_START,
39         CMD_STOP,
40         CMD_REG,
41         CMD_UNREG,
42         CMD_SET_OPTION,
43         CMD_SET_WAKEUP,
44         CMD_SET_BATCH,
45         CMD_UNSET_BATCH,
46         CMD_GET_DATA,
47         CMD_SET_ATTRIBUTE_INT,
48         CMD_SET_ATTRIBUTE_STR,
49         CMD_CNT,
50 };
51
52 typedef struct {
53         char name[NAME_MAX];
54 } cmd_get_id_t;
55
56 typedef struct {
57 } cmd_get_sensor_list_t;
58
59 typedef struct {
60         int client_id;
61         sensor_id_t sensor;
62 } cmd_hello_t;
63
64 typedef struct {
65 } cmd_byebye_t;
66
67
68 typedef struct {
69         unsigned int type;
70 } cmd_get_data_t;
71
72 typedef struct {
73         long value;
74 } cmd_done_t;
75
76
77 typedef struct {
78         int client_id;
79 } cmd_get_id_done_t;
80
81 typedef struct {
82         int sensor_cnt;
83         char data[0];
84 } cmd_get_sensor_list_done_t;
85
86 typedef struct {
87         int state;
88         sensor_data_t base_data;
89 } cmd_get_data_done_t;
90
91 typedef struct {
92 } cmd_start_t;
93
94 typedef struct {
95 } cmd_stop_t;
96
97 typedef struct {
98         unsigned int event_type;
99 } cmd_reg_t;
100
101 typedef struct {
102         unsigned int event_type;
103 } cmd_unreg_t;
104
105 typedef struct {
106         unsigned int interval;
107         unsigned int latency;
108 } cmd_set_batch_t;
109
110 typedef struct {
111 } cmd_unset_batch_t;
112
113 typedef struct {
114         int option;
115 } cmd_set_option_t;
116
117 typedef struct {
118         int wakeup;
119 } cmd_set_wakeup_t;
120
121 typedef struct  {
122         int attribute;
123         int value;
124 } cmd_set_attribute_int_t;
125
126 typedef struct  {
127         int attribute;
128         int value_len;
129         char value[0];
130 } cmd_set_attribute_str_t;
131
132 #define EVENT_CHANNEL_MAGIC 0xCAFECAFE
133
134 typedef struct {
135         unsigned int magic;
136         int client_id;
137 } event_channel_ready_t;
138
139 typedef void *(*cmd_func_t)(void *data, void *cb_data);
140
141 #endif /* _COMMAND_COMMON_H_ */