57db2f927d477502d5ecd7e07836d66979fe1d83
[apps/native/gear-racing-car.git] / inc / message.h
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (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
7  *
8  * http://floralicense.org/license/
9  *
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.
15  */
16
17 #ifndef __CAR_APP_MESSAGE_H__
18 #define __CAR_APP_MESSAGE_H__
19
20 typedef enum __message_cmd_e {
21         MESSAGE_CMD_HELLO, /* to use keep alive, if needed */
22         MESSAGE_CMD_CALIBRATION,
23         MESSAGE_CMD_DRIVE,
24         MESSAGE_CMD_BYE, /* to notify explicitly closing connection */
25 } message_cmd_e;
26
27 typedef struct __message_type_s message_s;
28
29 int message_new(message_cmd_e cmd, int servo, int speed, message_s *new_msg);
30 void message_reset_seq_num(void);
31
32 /* To encapsulate message struction,
33  * we need to discuss about it.
34  * which one is better, hiding its members or direct accessing its members?
35  */
36 int message_get_seq_num(message_s *msg, unsigned long long int *seq_num);
37 int message_get_cmd(message_s *msg, message_cmd_e *cmd);
38 int message_get_speed_value(message_s *msg, int *speed);
39 int message_get_servo_value(message_s *msg, int *servo);
40
41 #endif /* __CAR_APP_MESSAGE_H__ */