1SUMMARY = "Script to properly configure BT-HCI on Raspberry Pi"
2HOMEPAGE = "https://github.com/RPi-Distro/pi-bluetooth"
3SECTION = "kernel"
4LICENSE = "BSD-3-Clause"
5LIC_FILES_CHKSUM = "\
6    file://debian/copyright;md5=6af8de3c8ee71f8e91e9b22f84ff2022 \
7"
8
9SRC_URI = "\
10    git://github.com/RPi-Distro/pi-bluetooth;branch=master;protocol=https \
11    file://0001-bthelper-correct-path-for-hciconfig-under-Yocto.patch \
12"
13SRCREV = "fd4775bf90e037551532fc214a958074830bb80d"
14
15S = "${WORKDIR}/git"
16
17inherit ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', 'update-rc.d', d)}
18# hciuart.service replaces what was brcm43438.service
19SYSTEMD_SERVICE:${PN} = "\
20    hciuart.service \
21    bthelper@.service \
22"
23INITSCRIPT_NAME = "btuart"
24INITSCRIPT_PARAMS = "start 18 2 3 4 5 ."
25
26do_install() {
27    install -d ${D}${sysconfdir}/udev/rules.d
28    install -m 0644 ${S}/lib/udev/rules.d/* ${D}${sysconfdir}/udev/rules.d
29
30    install -d ${D}${bindir}
31    install -m 0755 ${S}/usr/bin/bthelper ${D}${bindir}
32    install -m 0755 ${S}/usr/bin/btuart ${D}${bindir}
33
34    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
35        install -d ${D}${systemd_system_unitdir}
36        install -m 0644 ${S}/debian/pi-bluetooth.bthelper@.service ${D}${systemd_system_unitdir}/bthelper@.service
37        install -m 0644 ${S}/debian/pi-bluetooth.hciuart.service ${D}${systemd_system_unitdir}/hciuart.service
38    else
39        install -d ${D}${sysconfdir}/init.d/
40        cat > ${WORKDIR}/btuart.init << EOF
41#!/bin/sh
42/usr/bin/btuart
43EOF
44        install -m 0755 ${WORKDIR}/btuart.init ${D}${sysconfdir}/init.d/btuart
45        sed -i -e 's:TAG+="systemd".*$:RUN+="/usr/bin/bthelper %k":' ${D}${sysconfdir}/udev/rules.d/90-pi-bluetooth.rules
46    fi
47}
48
49FILES:${PN} = "\
50    ${bindir} \
51    ${sysconfdir} \
52    ${systemd_unitdir}/system \
53"
54
55RDEPENDS:${PN} += " \
56    udev-rules-rpi \
57"
58