Apply hal macro and modify script 22/252322/3 accepted/tizen/unified/20210128.132343 submit/tizen/20210127.232224
authorWootak Jung <wootak.jung@samsung.com>
Tue, 26 Jan 2021 23:32:02 +0000 (08:32 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Wed, 27 Jan 2021 07:35:43 +0000 (16:35 +0900)
Change-Id: Ib1a28670d0e116dda1a9511aa879cfe370a300cb
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
CMakeLists.txt
packaging/bluetooth-firmware-sprd.spec
packaging/bluetooth-hci-device.service [deleted file]
packaging/bluetooth-hciattach@.service [deleted file]
scripts/CMakeLists.txt
scripts/bt-dev-end.sh
scripts/bt-dev-start-TM1.sh
src/CMakeLists.txt
src/hal-backend-bluetooth.c

index c43c9dc..857726d 100644 (file)
@@ -1,4 +1,5 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(bluetooth-firmware-sprd C)
 
 FOREACH(flag ${package_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -6,5 +7,7 @@ ENDFOREACH(flag)
 
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION ${HAL_LICENSE_DIR}/${PROJECT_NAME})
+
 ADD_SUBDIRECTORY(scripts)
 ADD_SUBDIRECTORY(src)
index 1caa623..7cc0f9c 100644 (file)
@@ -5,8 +5,6 @@ Release:    1
 Group:      TO_BE_FILLED
 License:    Apache-2.0
 Source0:    bluetooth-firmware-sprd-%{version}.tar.gz
-Source1:    bluetooth-hciattach@.service
-Source2:    bluetooth-hci-device.service
 
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
@@ -32,26 +30,24 @@ export CFLAGS+=" -fpie -fvisibility=hidden"
 export CXXFLAGS+=" -fpie -fvisibility=hidden"
 export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie"
 
-cmake ./ -DCMAKE_INSTALL_PREFIX=%{_prefix} -DPLUGIN_INSTALL_PREFIX=%{_prefix}
+cmake ./ -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+       -DPLUGIN_INSTALL_PREFIX=%{_prefix} \
+       -DHAL_LIB_DIR=%{_hal_libdir} \
+       -DHAL_LICENSE_DIR=%{_hal_licensedir} \
+       -DHAL_SYSCONF_DIR=%{_hal_sysconfdir}
 make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
 %make_install
 
-install -D -m 0644 %SOURCE1 %{buildroot}%{_unitdir}/bluetooth-hciattach@.service
-install -D -m 0644 %SOURCE2 %{buildroot}%{_unitdir}/bluetooth-hci-device.service
-
 %post TM1
-rm -rf %{_prefix}/etc/bluetooth/bt-dev-start.sh
-ln -s %{_prefix}/etc/bluetooth/bt-dev-start-TM1.sh %{_prefix}/etc/bluetooth/bt-dev-start.sh
+rm -rf %{_hal_sysconfdir}/bluetooth/bt-dev-start.sh
+ln -s %{_hal_sysconfdir}/bluetooth/bt-dev-start-TM1.sh %{_hal_sysconfdir}/bluetooth/bt-dev-start.sh
 
 %files TM1
 %manifest %{name}.manifest
-%license LICENSE
-%defattr(-,root,root,-)
-%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-end.sh
-%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-start-TM1.sh
-%{_unitdir}/bluetooth-hciattach@.service
-%{_unitdir}/bluetooth-hci-device.service
-/hal/lib/*.so*
+%{_hal_licensedir}/%{name}/LICENSE
+%{_hal_sysconfdir}/bluetooth/bt-dev-end.sh
+%{_hal_sysconfdir}/bluetooth/bt-dev-start-TM1.sh
+%{_hal_libdir}/*.so*
diff --git a/packaging/bluetooth-hci-device.service b/packaging/bluetooth-hci-device.service
deleted file mode 100644 (file)
index 99b4888..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=hciattach service for SPRD BT/FM requested
-StopWhenUnneeded=yes
-
-[Service]
-Type=oneshot
-SmackProcessLabel=System
-ExecStart=/usr/etc/bluetooth/bt-dev-start.sh
-ExecStop=/usr/etc/bluetooth/bt-dev-end.sh
-RemainAfterExit=yes
-StandardOutput=journal+console
-StandardError=inherit
diff --git a/packaging/bluetooth-hciattach@.service b/packaging/bluetooth-hciattach@.service
deleted file mode 100644 (file)
index 9d49d09..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Unit]
-Description=hciattach service requested by %I
-Requires=bluetooth-hci-device.service
-After=bluetooth-hci-device.service
-
-[Service]
-Type=oneshot
-SmackProcessLabel=System
-ExecStartPre=-/bin/mkdir -p /run/bluetooth/
-ExecStart=/bin/touch /run/bluetooth/%I
-ExecStop=/bin/rm /run/bluetooth/%I
-RemainAfterExit=yes
-StandardOutput=journal+console
-StandardError=inherit
index c04b688..c88c946 100644 (file)
@@ -1,3 +1,3 @@
 # install firmware
-INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-end.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
-INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-start-TM1.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-end.sh DESTINATION ${HAL_SYSCONF_DIR}/bluetooth)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-start-TM1.sh DESTINATION ${HAL_SYSCONF_DIR}/bluetooth)
index cba7f07..fa62c1e 100755 (executable)
@@ -17,3 +17,28 @@ PGREP="/usr/bin/pgrep"
 # Do NOT use killall due to smack
 hciattach_pid=`${PGREP} hciattach`
 kill $hciattach_pid
+
+HCI_CONFIG=/usr/bin/hciconfig
+TIMEOUT=20
+for ((i=1; i<=$TIMEOUT; i++))
+do
+       /bin/sleep 0.1
+       if [ $i -eq $TIMEOUT ]
+       then
+               echo "time expired happen $i"
+               exit 2
+       fi
+       if (${HCI_CONFIG} | grep DOWN); then
+               echo "Bluetooth device is down"
+               break
+       fi
+       if (${HCI_CONFIG} | grep hci); then
+               echo "Bluetooth device still exist"
+       else
+               echo "hci is removed"
+               break
+       fi
+       echo "Continue...$i"
+done
+
+exit 0
index 1a7118c..e5c7b76 100644 (file)
@@ -13,7 +13,7 @@ echo "Check for Bluetooth device status"
 if (${HCI_CONFIG} | grep hci); then
        echo "Bluetooth device is UP"
        ${HCI_CONFIG} hci0 up
-       exit 1
+       exit 0
 fi
 
 /usr/sbin/rfkill unblock bluetooth
@@ -31,5 +31,29 @@ else
        /bin/cp /var/log/messages /var/lib/bluetooth/
 fi
 
-#/usr/sbin/hciconfig hci0 down
+echo "Check for Bluetooth device status"
+if (${HCI_CONFIG} | grep hci); then
+       echo "Bluetooth device is UP"
+       ${HCI_CONFIG} hci0 up
+else
+       echo "Did not attach HCI"
+       exit 1
+fi
 
+TIMEOUT=20
+for ((i=1; i<=$TIMEOUT; i++))
+do
+       /bin/sleep 0.1
+       if [ $i -eq $TIMEOUT ]
+       then
+               echo "time expired happen $i"
+               exit 2
+       fi
+       if (${HCI_CONFIG} | grep UP); then
+               echo "Bluetooth device is made"
+               break
+       fi
+       echo "Continue...$i"
+done
+
+exit 0
index ca1fc73..964fe52 100644 (file)
@@ -22,4 +22,4 @@ 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)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
index 4eb220f..744b353 100644 (file)
@@ -14,7 +14,7 @@
 static int bluetooth_tm1_start(void)
 {
        int ret;
-       ret = system("/usr/etc/bluetooth/bt-stack-up.sh");
+       ret = system("/hal/etc/bluetooth/bt-dev-start.sh");
        if (ret == 0x100) {
                LOGE("script internal failed");
                return HAL_BACKEND_ERROR_INTERNAL;
@@ -29,7 +29,7 @@ static int bluetooth_tm1_start(void)
 static int bluetooth_tm1_stop(void)
 {
        int ret;
-       ret = system("/usr/etc/bluetooth/bt-stack-down.sh");
+       ret = system("/hal/etc/bluetooth/bt-dev-end.sh");
        if (ret == 0x100) {
                LOGE("script internal failed");
                return HAL_BACKEND_ERROR_INTERNAL;