Skip to content

Instantly share code, notes, and snippets.

@erikusaj
Created April 8, 2020 07:44
Show Gist options
  • Save erikusaj/35dd05158e6c82d94430b43c3f8d75c6 to your computer and use it in GitHub Desktop.
Save erikusaj/35dd05158e6c82d94430b43c3f8d75c6 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$1" != "" ]; then
ipaddress=$1;
echo -e "Bluetooth HCI logging on STB $ipaddress ... \n"
# cleanup
rm bluetooth_manager_*
rm bluetooth_hci_*
adb connect $ipaddress
echo -e "Rebooting STB ... \n"
adb -s $ipaddress:5555 reboot
t0=$(date +%s)
adb -s $ipaddress:5555 shell dumpsys bluetooth_manager | tee ./bluetooth_manager_reboot_$t0.dump
read -p "Press Y when STB rebooted ... " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
else
adb connect $ipaddress
adb -s $ipaddress:5555 root
adb connect $ipaddress
# delete any existing HCI log
adb -s $ipaddress:5555 shell rm /sdcard/btsnoop_hci.log
adb -s $ipaddress:5555 shell settings put global development_settings_enabled 1
adb -s $ipaddress:5555 shell settings put secure bluetooth_hci_log 1
# disable BT
adb -s $ipaddress:5555 shell service call bluetooth_manager 8
# enable BT
adb -s $ipaddress:5555 shell service call bluetooth_manager 6
# NOTE: turning BT off and odd since bluetooth HCI logging does not take effect with rebobots
echo -e "Bluetooth is re-enabled on STB. \n"
echo -e "HCI log file is now being generated and is saved to /sdcard/btsnoop_hci.log. \n\n"
t1=$(date +%s)
adb -s $ipaddress:5555 shell dumpsys bluetooth_manager | tee ./bluetooth_manager_hci_$t1.dump
date
# reboot
# according to article rebbot should be done after turning on bluetooth_hci_log 1
# NOTE: not rebooting as it appears reboot clears settings and no btsnoop_hci.log is created in case of reboot
# adb -s $ipaddress:5555 reboot
read -p "\n\nPress Y when RCU is connected with Green LED flashing ... " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
echo -e "RCU in bluetooth mode. \n\n"
date
t2=$(date +%s)
adb -s $ipaddress:5555 shell dumpsys bluetooth_manager | tee ./bluetooth_manager_end_$t2.dump
adb pull /sdcard/btsnoop_hci.log bluetooth_hci_$t2.log
fi
else
echo -e "Missing IP address of Android STB.";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment