ccimx93: bluetooth-init: fix how to set btaddr

Use the specific hcitool vendor command to set the BT mac address.
It is a custom vendor command (0x3f), and the field is 0x0022.
The BT address is passed from last octet to first octet.

https://onedigi.atlassian.net/browse/DEL-8346

Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
This commit is contained in:
Isaac Hermida 2023-04-03 16:38:45 +02:00
parent 03c3593050
commit 6e812a569b
1 changed files with 7 additions and 2 deletions

View File

@ -19,16 +19,21 @@ log() {
printf "<3>iw612-bluetooth: %s\n" "${1}" >/dev/kmsg printf "<3>iw612-bluetooth: %s\n" "${1}" >/dev/kmsg
} }
set_btaddr() {
bt_addr=$(echo $(fw_printenv -n btaddr) | awk -F ":" '{ for(i=NF;i>=1;i--) printf "0x%s ", $i }')
hcitool -i ${HCI_IFACE} cmd 0x3f 0x0022 0xfe 0x06 ${bt_addr}
}
bluetooth_start() { bluetooth_start() {
if ! [ -e "/proc/device-tree/bluetooth/mac-address" ]; then if ! [ -e "/proc/device-tree/bluetooth/mac-address" ]; then
log "[ERROR] Bluetooth mac-address not found" log "[ERROR] Bluetooth mac-address not found"
return return
fi fi
BTADDR=$(hexdump -ve '1/1 "%02X" ":"' /proc/device-tree/bluetooth/mac-address 2>/dev/null | sed 's/:$//g') hciattach -t5 /dev/ttyBt any 115200 flow nosleep && \
hciattach -t5 /dev/ttyBt any 115200 flow nosleep "${BTADDR}" && \
hciconfig ${HCI_IFACE} up && \ hciconfig ${HCI_IFACE} up && \
sleep 0.2 && \ sleep 0.2 && \
set_btaddr && \
hcitool -i ${HCI_IFACE} cmd 0x3f 0x0009 0xc0 0xc6 0x2d 0x00 && \ hcitool -i ${HCI_IFACE} cmd 0x3f 0x0009 0xc0 0xc6 0x2d 0x00 && \
sleep 0.2 && \ sleep 0.2 && \
killall hciattach && \ killall hciattach && \