diff --git a/recipes-bsp/mac-address-set/files/mac-address-set.sh b/recipes-bsp/mac-address-set/files/mac-address-set.sh index 9aae50d..71b5a00 100755 --- a/recipes-bsp/mac-address-set/files/mac-address-set.sh +++ b/recipes-bsp/mac-address-set/files/mac-address-set.sh @@ -37,6 +37,7 @@ log_level="$level_info" eth_mac=0 set_wlan=0 set_bt=0 +invert_bt_mac=0 log () { msg_level="$1" @@ -191,8 +192,7 @@ prepare_and_set_wlan_mac_address() { set_and_check_bt_mac_address() { address="$1" addr_to_set="$address" # Because of some bug the address to set may be inverted - invert="$2" - if [[ "$invert" -eq "1" ]]; then + if [[ "$invert_bt_mac" -eq "1" ]]; then addr_to_set=$(echo "$address" | sed -r "s/^(.{2}):(.{2}):(.{2}):(.{2}):(.{2}):(.{2})/\\6:\\5:\\4:\\3:\\2:\\1/") fi @@ -228,13 +228,8 @@ prepare_and_set_bt_mac_address() { hciconfig hci0 up log_info "Setting bluetooth mac address to $address" - set_and_check_bt_mac_address "$address" 0 + set_and_check_bt_mac_address "$address" ret=$? - if [ $ret -ne 0 ]; then - log_info "Trying with reversed address" # This is a bug in some systems - set_and_check_bt_mac_address "$address" 1 - ret=$? - fi return $ret } @@ -292,17 +287,19 @@ main() { echo " $0 -l # loglevel being between 0 (errors) and 2 (info)" echo " $0 -w # set wifi address" echo " $0 -b # set bluetooth address" + echo " $0 -i # invert bluetooth address" echo " $0 -e # mac address input, e.g. 00:11:22:33:44:10" exit 0 fi - while getopts l:w:b:e: option + while getopts l:wbie: option do case "${option}" in l)log_level=${OPTARG};; w)set_wlan=1;; b)set_bt=1;; + i)invert_bt_mac=1;; e)eth_mac=${OPTARG};; esac done diff --git a/recipes-bsp/mac-address-set/mac-address-set.bb b/recipes-bsp/mac-address-set/mac-address-set.bb index c853ded..59cd699 100644 --- a/recipes-bsp/mac-address-set/mac-address-set.bb +++ b/recipes-bsp/mac-address-set/mac-address-set.bb @@ -26,11 +26,18 @@ FILES_${PN}_append = " \ /usr \ " +PACKAGE_ARCH = "${MACHINE_ARCH}" + do_install () { install -d ${D}${systemd_unitdir}/system/ install -m 0644 wlan-address-set.service ${D}${systemd_unitdir}/system/ install -m 0644 bt-address-set.service ${D}${systemd_unitdir}/system/ + # Invert BT mac for TI chips + if ${@bb.utils.contains('MACHINE_FEATURES', 'tibluetooth', 'true', 'false',d)}; then + sed -i 's/^ExecStart=.*/& -i/g' ${D}${systemd_unitdir}/system/bt-address-set.service + fi + install -d ${D}/usr/bin install -m 0755 mac-address-set.sh ${D}/usr/bin/mac-address-set }