bluez-init: check on the device tree if the variant has bluetooth
The script was basing on the variant coded in the HWID to determine if the variant had bluetooth, by comparing to an array of hard-coded variants. This required the script to be updated with every new variant that supported Bluetooth. The patch checks instead if the node 'bluetooth' exists at all in the device tree to determine if the variant supports Bluetooth. https://jira.digi.com/browse/DEL-1933 Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
This commit is contained in:
parent
52b4cfe35c
commit
599627f214
|
|
@ -22,25 +22,12 @@ if [ "${1}" != "start" ]; then
|
|||
fi
|
||||
|
||||
SCRIPTNAME="$(basename "${0}")"
|
||||
MACHINENAME="$(cat /proc/device-tree/digi,machine,name 2>/dev/null)"
|
||||
|
||||
bt_init() {
|
||||
# Exit if this hardware does not support Bluetooth
|
||||
if [ "${MACHINENAME}" = "ccardimx28" ]; then
|
||||
BLUETOOTH_VARIANTS="0x02 0x03 0x10 0x11 0x12"
|
||||
MOD_VARIANT="$(cat /proc/device-tree/digi,hwid,variant 2>/dev/null || \
|
||||
cat "/sys/kernel/${MACHINENAME}/mod_variant")"
|
||||
if ! echo "${BLUETOOTH_VARIANTS}" | grep -qs "${MOD_VARIANT}"; then
|
||||
echo "${SCRIPTNAME}: variant ${MOD_VARIANT} does not support bluetooth"
|
||||
exit
|
||||
fi
|
||||
BT_PWR_GPIO_NR="21"
|
||||
elif [ "${MACHINENAME}" = "ccimx6sbc" ]; then
|
||||
BLUETOOTH_VARIANTS="0x01 0x02 0x03 0x04 0x06 0x0b 0x11 0x12"
|
||||
MOD_VARIANT="$(cat /proc/device-tree/digi,hwid,variant)"
|
||||
if ! echo "${BLUETOOTH_VARIANTS}" | grep -qs "${MOD_VARIANT}"; then
|
||||
echo "${SCRIPTNAME}: variant ${MOD_VARIANT} does not support bluetooth"
|
||||
exit
|
||||
fi
|
||||
BT_PWR_GPIO_NR="244"
|
||||
fi
|
||||
|
||||
|
|
@ -63,8 +50,7 @@ bt_init() {
|
|||
[ -f "${FW_MAC}" ] && [ "$(cat ${FW_MAC})" = "${BTADDR}" ] || echo ${BTADDR} > ${FW_MAC}
|
||||
|
||||
JPN_REGCODE="0x2"
|
||||
REGCODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null || \
|
||||
cat "/sys/kernel/${MACHINENAME}/mod_cert")"
|
||||
REGCODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null)"
|
||||
BT_CLASS_LINK="PS_ASIC.pst"
|
||||
BT_CLASS_FILE="PS_ASIC_class_1.pst"
|
||||
if [ -n "${REGCODE}" ] && [ "${JPN_REGCODE}" = "${REGCODE}" ]; then
|
||||
|
|
@ -104,17 +90,16 @@ bt_init() {
|
|||
echo "${SCRIPTNAME}: FAILED (abtfilt)"
|
||||
exit
|
||||
fi
|
||||
if hciconfig hci0 up; then
|
||||
: # No-op
|
||||
else
|
||||
echo "${SCRIPTNAME}: FAILED"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Starting bluetooth services."
|
||||
start-stop-daemon -S --background --exec /usr/lib/bluez5/bluetooth/bluetoothd
|
||||
|
||||
# Initialize driver for 'ccardimx28js'
|
||||
MACHINENAME="$(cat /proc/device-tree/digi,machine,name 2>/dev/null || cat /sys/kernel/machine/name)"
|
||||
[ "${MACHINENAME}" = "ccardimx28" -o "${MACHINENAME}" = "ccimx6sbc" ] && bt_init
|
||||
|
||||
# Run bluetooth daemon
|
||||
if hciconfig hci0 up && start-stop-daemon -S --background --exec /usr/lib/bluez5/bluetooth/bluetoothd; then
|
||||
: # No-op
|
||||
else
|
||||
echo "${SCRIPTNAME}: FAILED"
|
||||
fi
|
||||
# Check if this hardware does support Bluetooth
|
||||
[ -d "/proc/device-tree/bluetooth" ] && bt_init
|
||||
|
|
|
|||
Loading…
Reference in New Issue