diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init index 1971a47c4..2f9c940e4 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init @@ -40,6 +40,16 @@ bt_power() { 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() { lsmod | grep -qs -w "^${MODULE_NAME}" } @@ -57,7 +67,8 @@ bt_init() { # Load manually the kernel module modprobe "${MODULE_NAME}" 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..." done diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp2/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp2/bluetooth-init index 2df3373a1..0a9eaeefa 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp2/bluetooth-init +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp2/bluetooth-init @@ -29,6 +29,16 @@ bt_power() { 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() { for i in $(seq ${RETRIES}); do # Perform a power cycle @@ -42,8 +52,8 @@ bt_init() { btattach -B /dev/ttySTM1 -P bcm -S 921600 & sleep 2 - # Up the interface to be able to send hci commands - hciconfig hci0 up && log info "OK" && return 0 + # Reconfigure the HCI interface with the expected MAC address + set_btaddr && log info "OK" && return 0 fi log err "FAILED to bring hci0 up, retrying..." killall btattach 2> /dev/null