#!/system/bin/sh
# DDS: Initialize T100 bluetooth 

LOG_TAG="BCM2035"
BTUART_PORT=/dev/ttyS1

logi ()
{
  /system/bin/log -t $LOG_TAG -p i ": $@"
}

loge ()
{
  /system/bin/log -t $LOG_TAG -p e ": $@"
}

failed ()
{
  loge "$1: exit code $2"
  exit $2
}

# attach HCI 
logwrapper /system/bin/hciattach -p $BTUART_PORT bcm2035 921600 flow
case $? in
  0) logi "hci attached to : $BTUART_PORT";;
  *) failed "port: $BTUART_PORT - hciattach failed" $?;
     exit $?;;
esac

exit 0
