Added BT service to Nano Pi AIR, enabled by default, random MAC at start

This commit is contained in:
Igor Pecovnik
2016-10-29 08:27:02 +02:00
parent ee15d6ecf5
commit 709acc6b38
4 changed files with 43 additions and 8 deletions

View File

@@ -50,7 +50,8 @@ compile_tools()
install -m 644 $SRC/lib/scripts/brcm40183 $tmpdir/armbian-tools-${RELEASE}_${REVISION}_${ARCH}/etc/default
install -m 755 $SRC/lib/scripts/brcm40183-patch $tmpdir/armbian-tools-${RELEASE}_${REVISION}_${ARCH}/etc/init.d
# ap6212 BT
# ap6212 configs and service
install -m 644 $SRC/lib/scripts/ap6212 $tmpdir/armbian-tools-${RELEASE}_${REVISION}_${ARCH}/etc/default
install -m 755 $SRC/lib/scripts/ap6212-bluetooth $tmpdir/armbian-tools-${RELEASE}_${REVISION}_${ARCH}/etc/init.d
cd $tmpdir/armbian-tools-${RELEASE}_${REVISION}_${ARCH}

11
scripts/ap6212 Normal file
View File

@@ -0,0 +1,11 @@
#
# Default it is called to be uncertain wich MAC address the chipset has.
# Therefore it is recommendable to set the MAC address manually.
# This can be done by setting the variable MAC_ADDR with a chosen value.
# If this variable is empty or not set the default 11:22:33:44:55:66 will be chosen.
MAC_ADDR=43:29:B1:55:01:01
#
PORT=ttyS1

View File

@@ -10,6 +10,14 @@
# Description: Patch firmware for ap6212 adapter
### END INIT INFO
DEFAULTS="/etc/default/ap6212"
# Include ap6212 defaults if available
if [ -r "${DEFAULTS}" ]
then
. "${DEFAULTS}"
fi
# exit if bluetooth utils are not installed
[ -f "/bin/hciconfig" ] || exit 0
@@ -30,12 +38,24 @@ then
echo "ap6212 BT device allready initialized"
hcitool dev
else
# Start patching
# Select MAC address
if [ -z "$MAC_ADDR" ]; then
MAC_OPTIONS="11:22:33:44:55:66"
else
MAC_OPTIONS="$MAC_ADDR"
fi
# Select tty port
if [ -z "$PORT" ]; then
log_warning_msg "No PORT set in /etc/default/ap6212, will use ttyS1"
PORT="ttyS1"
fi
# Start patching
rfkill unblock all
echo "0" > /sys/class/rfkill/rfkill0/state
echo "1" > /sys/class/rfkill/rfkill0/state
echo " " > /dev/ttyS1
hciattach /dev/ttyS1 bcm43xx 115200
echo " " > /dev/$PORT
hciattach /dev/$PORT bcm43xx 115200 flow bdaddr $MAC_OPTIONS
hciconfig hci0 up
fi
}

View File

@@ -86,7 +86,7 @@ collect_information() {
[[ "$BOARD" == "cubietruck" ]] && update-rc.d brcm40183-patch defaults
# enable BT on Banana M2+
[[ "$BOARD" == "bananapim2plus" ]] && update-rc.d ap6212-bluetooth defaults
[[ "$BOARD" == "bananapim2plus" || "$BOARD" == "nanopiair" ]] && update-rc.d ap6212-bluetooth defaults
# enable BT on Solidrun boards
[[ "$BOARD" == "Cubox i2eX/i4" ]] && update-rc.d brcm4330-patch defaults && /etc/init.d/brcm4330-patch start
@@ -114,14 +114,17 @@ collect_information() {
adjust_sunxi_settings() {
# set some mac address for BT
[[ "$(lsmod | grep bcmdhd)" != "" ]] && \
[[ "$(lsmod | grep dhd)" != "" ]] && \
(MACADDR=$(printf '43:29:B1:%02X:%02X:%02X\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256]) ; \
sed -i "s/^MAC_ADDR=.*/MAC_ADDR=${MACADDR}/" /etc/default/brcm40183 \
sed -i "s/^MAC_ADDR=.*/MAC_ADDR=${MACADDR}/" /etc/default/brcm40183 ;\
sed -i "s/^MAC_ADDR=.*/MAC_ADDR=${MACADDR}/" /etc/default/ap6212 \
echo -e "\n### [firstrun] Use MAC address ${MACADDR} for Bluetooth from now" >>${Log})
# relink /etc/network/interfaces on OPi Lite and NanoPi Air
# change serial port for BT on NanoPi Air
# relink /etc/network/interfaces on OPi Lite and NanoPi Air
case ${BOARD_NAME} in
"NanoPi Air"|"Orange Pi Lite")
sed -i "s/^PORT=.*/PORT=ttyS3/" /etc/default/ap6212
cd /etc/network/ && ln -sf interfaces.network-manager interfaces
;;
esac