Source2: bluetooth-hci-device.service
BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(hal-api-common)
+BuildRequires: pkgconfig(hal-api-bluetooth)
%description
firmware and tools for bluetooth
%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-start-TM1.sh
%{_unitdir}/bluetooth-hciattach@.service
%{_unitdir}/bluetooth-hci-device.service
+/hal/lib/*.so*
--- /dev/null
+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 COMPONENT RuntimeLibraries)
--- /dev/null
+#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_tm1_start(void)
+{
+ int ret;
+ ret = system("/usr/etc/bluetooth/bt-stack-up.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_tm1_stop(void)
+{
+ int ret;
+ ret = system("/usr/etc/bluetooth/bt-stack-down.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_tm1_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_tm1_start;
+ bluetooth_funcs->stop = bluetooth_tm1_stop;
+
+ *data = (void *)bluetooth_funcs;
+
+ return 0;
+}
+
+static int bluetooth_tm1_exit(void *data)
+{
+ if (!data)
+ return -EINVAL;
+ free(data);
+
+ return 0;
+}
+
+hal_backend EXPORT hal_backend_bluetooth_data = {
+ .name = "bluetooth-spreadtrum",
+ .vendor = "Spreadtrum",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = bluetooth_tm1_init,
+ .exit = bluetooth_tm1_exit,
+};