add pilot version of receiver module
authorJeonghoon Park <jh1979.park@samsung.com>
Thu, 4 Jan 2018 08:21:43 +0000 (17:21 +0900)
committerJeonghoon Park <jh1979.park@samsung.com>
Thu, 4 Jan 2018 08:21:43 +0000 (17:21 +0900)
CMakeLists.txt
inc/receiver.h [new file with mode: 0644]
inc/receiver_internal.h [new file with mode: 0644]
src/receiver.c [new file with mode: 0644]

index c974fd7..f2024a5 100644 (file)
@@ -14,6 +14,7 @@ pkg_check_modules(APP_PKGS REQUIRED
        capi-appfw-service-application
        capi-system-peripheral-io
        glib-2.0
+       gio-2.0
 )
 
 FOREACH (flag ${APP_PKGS_CFLAGS})
@@ -30,6 +31,7 @@ ADD_EXECUTABLE(${PROJECT_NAME}
        ${PROJECT_ROOT_DIR}/src/app.c
        ${PROJECT_ROOT_DIR}/src/log.c
        ${PROJECT_ROOT_DIR}/src/resource.c
+       ${PROJECT_ROOT_DIR}/src/receiver.c
        ${PROJECT_ROOT_DIR}/src/resource/resource_infrared_obstacle_avoidance_sensor.c
        ${PROJECT_ROOT_DIR}/src/resource/resource_motor_driver_L298N.c
        ${PROJECT_ROOT_DIR}/src/resource/resource_PCA9685.c
diff --git a/inc/receiver.h b/inc/receiver.h
new file mode 100644 (file)
index 0000000..347bd77
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CAR_APP_RECEIVER_H__
+#define __CAR_APP_RECEIVER_H__
+
+typedef enum __receiver_type_e {
+       RECEIVER_TYPE_UDP,
+       RECEIVER_TYPE_BLUETOOTH,
+} receiver_type_e;
+
+int receiver_init(receiver_type_e type);
+void receiver_fini(void);
+
+#endif /* __CAR_APP_RECEIVER_H__ */
diff --git a/inc/receiver_internal.h b/inc/receiver_internal.h
new file mode 100644 (file)
index 0000000..05d6602
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CAR_APP_RECEIVER_INTERNAL_H__
+#define __CAR_APP_RECEIVER_INTERNAL_H__
+
+#include "receiver.h"
+
+/* TODO */
+
+#endif /* __CAR_APP_RECEIVER_INTERNAL_H__ */
diff --git a/src/receiver.c b/src/receiver.c
new file mode 100644 (file)
index 0000000..a77edd9
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include "log.h"
+#include "receiver_internal.h"
+
+typedef struct __receiver_h {
+       receiver_type_e receiver_type;
+       /* TODO */
+} receiver_h;
+
+static receiver_h *ghandle = NULL;
+
+int receiver_init(receiver_type_e type)
+{
+       int ret = 0;
+
+       if (ghandle) {
+               _E("receiver is already initialized");
+               return -1;
+       }
+
+       ghandle = (receiver_h *)malloc(sizeof(receiver_h));
+       if (!ghandle) {
+               _E("failed to malloc handle");
+               return -1;
+       }
+
+       switch (type) {
+       case RECEIVER_TYPE_UDP:
+               ghandle->receiver_type = type;
+               ret = receiver_udp_start();
+               if (ret)
+                       goto ERROR;
+               break;
+       case RECEIVER_TYPE_BLUETOOTH:
+               /* TODO */
+               break;
+       }
+       return 0;
+
+ERROR:
+       free(ghandle);
+       ghandle = NULL;
+       return -1;
+}
+
+void receiver_fini(void)
+{
+       if (ghandle) {
+               switch (ghandle->receiver_type) {
+               case RECEIVER_TYPE_UDP:
+                       receiver_udp_stop();
+                       break;
+               case RECEIVER_TYPE_BLUETOOTH:
+                       /* TODO */
+                       break;
+               }
+
+               free(ghandle);
+               ghandle = NULL;
+       }
+       return;
+}