#!/bin/sh PATH=/bin:/usr/bin:/sbin:/usr/sbin # # Script for registering Marvell SDIO BT device # PARAM_BDADDR=/sys/module/bt8xxx/parameters/bt_mac # Please fill the location fo bdaddr file BT_MAC_FILE=/opt/etc/.bd_addr GEN_BDADDR(){ echo "BT Mac addr generates randomly." MAC_PRE=$(echo "00:50:43:") MAC_POST=$(openssl rand -hex 3 | sed 's/\(..\)/\1:/g; s/.$//') echo "Random : $MAC_PRE$MAC_POST" bt_mac=$MAC_PRE$MAC_POST } # Take MAC ADDRESS from NAND storage. If not present generate randomly. if [ -e ${BT_MAC_FILE} ] > /dev/null 2>&1; then bt_mac=$(cat ${BT_MAC_FILE}) if [ ${#bt_mac} == 17 ]; then echo "bt_mac addr exists in ${BT_MAC_FILE} : ${bt_mac}" else echo "bt_mac addr is not proper in ${BT_MAC_FILE} : ${bt_mac}" GEN_BDADDR fi else GEN_BDADDR echo $bt_mac > ${BT_MAC_FILE} fi # Set MAC ADDRESS to module parameters echo $bt_mac > ${PARAM_BDADDR}