diff options
author | Wootak Jung <wootak.jung@samsung.com> | 2021-06-22 10:10:54 +0900 |
---|---|---|
committer | Wootak Jung <wootak.jung@samsung.com> | 2021-06-22 14:36:38 +0900 |
commit | 781e45b20496df9183358522ccb2f7d2f4fba2ed (patch) | |
tree | 26ddb0f134a9db367199c99f1aca0f48dd872e95 /src | |
parent | 150ecb4e67c50dcb87bc8758046fe4f05abf925f (diff) | |
download | bluetooth-vim3-781e45b20496df9183358522ccb2f7d2f4fba2ed.tar.gz bluetooth-vim3-781e45b20496df9183358522ccb2f7d2f4fba2ed.tar.bz2 bluetooth-vim3-781e45b20496df9183358522ccb2f7d2f4fba2ed.zip |
Apply next HAL architecturetizen_8.0_m2_releasetizen_7.0_m2_releasetizen_6.5.m2_releasesubmit/tizen_6.5/20211028.163201submit/tizen/20210628.015851accepted/tizen/unified/20210628.022625accepted/tizen/8.0/unified/20231005.094514accepted/tizen/7.0/unified/hotfix/20221116.110425accepted/tizen/7.0/unified/20221110.062255accepted/tizen/6.5/unified/20211028.115728tizen_8.0tizen_7.0_hotfixtizen_7.0tizen_6.5accepted/tizen_8.0_unifiedaccepted/tizen_7.0_unified_hotfixaccepted/tizen_7.0_unifiedaccepted/tizen_6.5_unified
Change-Id: I9641c9331f5dd6cd42fcd000385edd86135b5ae4
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 25 | ||||
-rw-r--r-- | src/hal-backend-bluetooth.c | 75 |
2 files changed, 100 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..964fe52 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,25 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-backend-bluetooth C) + +INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include) + +INCLUDE(FindPkgConfig) +pkg_check_modules(hal-backend-bluetooth_pkgs REQUIRED + dlog + hal-api-common + hal-api-bluetooth +) + +SET(SRCS + ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.c) + +FOREACH(flag ${hal-backend-bluetooth_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-bluetooth_pkgs_LDFLAGS}) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries) diff --git a/src/hal-backend-bluetooth.c b/src/hal-backend-bluetooth.c new file mode 100644 index 0000000..5f9846d --- /dev/null +++ b/src/hal-backend-bluetooth.c @@ -0,0 +1,75 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <errno.h> +#include <dlog.h> + +#include <hal/hal-bluetooth-interface.h> + +#undef LOG_TAG +#define LOG_TAG "HALAPI_BLUETOOTH" + +#define EXPORT __attribute__ ((visibility("default"))) + +static int bluetooth_vim3_start(void) +{ + int ret; + ret = system("/hal/etc/bluetooth/bt-dev-start.sh"); + if (ret == 0x100) { + LOGE("script internal failed"); + return HAL_BACKEND_ERROR_INTERNAL; + } else if (ret == 0x200) { + LOGE("script timeout failed"); + return HAL_BACKEND_ERROR_TIMEOUT; + } + LOGD("script started successfully"); + return HAL_BACKEND_ERROR_NONE; +} + +static int bluetooth_vim3_stop(void) +{ + int ret; + ret = system("/hal/etc/bluetooth/bt-dev-end.sh"); + if (ret == 0x100) { + LOGE("script internal failed"); + return HAL_BACKEND_ERROR_INTERNAL; + } else if (ret == 0x200) { + LOGE("script timeout failed"); + return HAL_BACKEND_ERROR_TIMEOUT; + } + LOGD("script started successfully"); + return HAL_BACKEND_ERROR_NONE; +} + +static int bluetooth_vim3_init(void **data) +{ + hal_backend_bluetooth_funcs *bluetooth_funcs; + + bluetooth_funcs = calloc(1, sizeof(hal_backend_bluetooth_funcs)); + if (!bluetooth_funcs) + return -ENOMEM; + + bluetooth_funcs->start = bluetooth_vim3_start; + bluetooth_funcs->stop = bluetooth_vim3_stop; + + *data = (void *)bluetooth_funcs; + + return 0; +} + +static int bluetooth_vim3_exit(void *data) +{ + if (!data) + return -EINVAL; + free(data); + + return 0; +} + +hal_backend EXPORT hal_backend_bluetooth_data = { + .name = "bluetooth-vim3", + .vendor = "VIM3", + .abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .init = bluetooth_vim3_init, + .exit = bluetooth_vim3_exit, +}; |