bluez: ccmp1/ccmp2: set custom MAC addresses on boot
Use an HCI vendor-specific command from Infineon on bluetooth-init to set a custom MAC address every time the interface is started. Valid for both CCMP1 (Murata 2AE) and CCMP2 (Murata 2FY) devices. Signed-off-by: Gonzalo Ruiz <Gonzalo.Ruiz@digi.com>
This commit is contained in:
parent
7692d0ed4a
commit
6a07f42432
|
|
@ -40,6 +40,16 @@ bt_power() {
|
||||||
gpioset "${GPIO_CHIP}" "${GPIO_NUMBER}"="${1}"
|
gpioset "${GPIO_CHIP}" "${GPIO_NUMBER}"="${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_btaddr() {
|
||||||
|
hciconfig hci0 up
|
||||||
|
sleep 0.2
|
||||||
|
bt_addr=$(echo "$(fw_printenv -n btaddr)" | awk -F ":" '{ for(i=NF;i>=1;i--) printf "0x%s ", $i }')
|
||||||
|
hcitool -i hci0 cmd 0x3f 0x0001 ${bt_addr}
|
||||||
|
hciconfig hci0 down
|
||||||
|
sleep 0.2
|
||||||
|
hciconfig hci0 up
|
||||||
|
}
|
||||||
|
|
||||||
is_kernel_module_loaded() {
|
is_kernel_module_loaded() {
|
||||||
lsmod | grep -qs -w "^${MODULE_NAME}"
|
lsmod | grep -qs -w "^${MODULE_NAME}"
|
||||||
}
|
}
|
||||||
|
|
@ -57,7 +67,8 @@ bt_init() {
|
||||||
# Load manually the kernel module
|
# Load manually the kernel module
|
||||||
modprobe "${MODULE_NAME}"
|
modprobe "${MODULE_NAME}"
|
||||||
sleep 1
|
sleep 1
|
||||||
is_kernel_module_loaded && log info "Bluetooth activated" && return 0
|
# Reconfigure the HCI interface with the expected MAC address
|
||||||
|
is_kernel_module_loaded && set_btaddr && log info "Bluetooth activated" && return 0
|
||||||
|
|
||||||
log err "Cannot initialize Bluetooth, retrying..."
|
log err "Cannot initialize Bluetooth, retrying..."
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,16 @@ bt_power() {
|
||||||
gpioset gpiochip11 5="${1}"
|
gpioset gpiochip11 5="${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_btaddr() {
|
||||||
|
hciconfig hci0 up
|
||||||
|
sleep 0.2
|
||||||
|
bt_addr=$(echo "$(fw_printenv -n btaddr)" | awk -F ":" '{ for(i=NF;i>=1;i--) printf "0x%s ", $i }')
|
||||||
|
hcitool -i hci0 cmd 0x3f 0x0001 ${bt_addr}
|
||||||
|
hciconfig hci0 down
|
||||||
|
sleep 0.2
|
||||||
|
hciconfig hci0 up
|
||||||
|
}
|
||||||
|
|
||||||
bt_init() {
|
bt_init() {
|
||||||
for i in $(seq ${RETRIES}); do
|
for i in $(seq ${RETRIES}); do
|
||||||
# Perform a power cycle
|
# Perform a power cycle
|
||||||
|
|
@ -42,8 +52,8 @@ bt_init() {
|
||||||
btattach -B /dev/ttySTM1 -P bcm -S 921600 &
|
btattach -B /dev/ttySTM1 -P bcm -S 921600 &
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# Up the interface to be able to send hci commands
|
# Reconfigure the HCI interface with the expected MAC address
|
||||||
hciconfig hci0 up && log info "OK" && return 0
|
set_btaddr && log info "OK" && return 0
|
||||||
fi
|
fi
|
||||||
log err "FAILED to bring hci0 up, retrying..."
|
log err "FAILED to bring hci0 up, retrying..."
|
||||||
killall btattach 2> /dev/null
|
killall btattach 2> /dev/null
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue