Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ ifeq ($(PLATFORM), tg5040)
cp ./workspace/all/minarch/build/$(PLATFORM)/liblzma.* ./build/SYSTEM/$(PLATFORM)/lib/
cp ./workspace/all/minarch/build/$(PLATFORM)/libzstd.* ./build/SYSTEM/$(PLATFORM)/lib/
endif
cp ./workspace/all/bluetooth/build/$(PLATFORM)/bluetooth.elf ./build/EXTRAS/Tools/$(PLATFORM)/Bluetooth.pak/


cores: # TODO: can't assume every platform will have the same stock cores (platform should be responsible for copy too)
Expand Down
21 changes: 21 additions & 0 deletions skeleton/EXTRAS/Tools/tg5040/Bluetooth.pak/launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

SDCARD_PATH="/mnt/SDCARD"
USERDATA_PATH="$SDCARD_PATH/.userdata"


#!/bin/bash

# Check if bluetoothd is running
if pgrep -x "bluetoothd" > /dev/null; then
echo "Bluetooth daemon is already running."
else
echo "Starting Bluetooth daemon..."
/etc/bluetooth/bluetoothd &
fi


cd $(dirname "$0")


./bluetooth.elf > $USERDATA_PATH/tg5040/logs/bluetooth.log 2>&1
Binary file not shown.
77 changes: 41 additions & 36 deletions skeleton/SYSTEM/tg5040/bin/suspend
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,63 @@ hciattach_running=0
bluetoothd_running=0

# shellcheck disable=SC2317

# honestly im kinda doubting if we even need to do all this because if i just disable everything bluetooth/wifi works perfect from suspend to wake up and all
# doesnt the internal firmware already take care of this?? When i enable all this stuff im just getting all kinds of reconnection errors and what not specially on bluetooth
resume() {
>&2 echo "Resuming from suspend..."

>&2 echo "Unblocking wireless..."
echo 1 >/sys/class/rfkill/rfkill0/state || true
# >&2 echo "Unblocking wireless..."
# echo 1 >/sys/class/rfkill/rfkill0/state || true

if [ "$wpa_running" -eq 1 ]; then
>&2 echo "Starting wpa_supplicant..."
wpa_supplicant -B -iwlan0 -Dnl80211 -c/etc/wifi/wpa_supplicant.conf -I/etc/wifi/wpa_supplicant_overlay.conf -O/etc/wifi/sockets || true
udhcpc -i wlan0 &
fi
# if [ "$wpa_running" -eq 1 ]; then
# >&2 echo "Starting wpa_supplicant..."
# wpa_supplicant -B -iwlan0 -Dnl80211 -c/etc/wifi/wpa_supplicant.conf -I/etc/wifi/wpa_supplicant_overlay.conf -O/etc/wifi/sockets || true
# udhcpc -i wlan0 &
# fi

if [ "$hciattach_running" -eq 1 ]; then
>&2 echo "Starting hciattach..."
/etc/init.d/hciattach start || true
fi
if [ "$bluetoothd_running" -eq 1 ]; then
>&2 echo "Starting bluetoothd..."
/etc/bluetooth/bluetoothd start || true
/usr/bin/bluetoothctl power on || true
fi
# if [ "$hciattach_running" -eq 1 ]; then
# >&2 echo "Starting hciattach..."
# /etc/init.d/hciattach start || true
# fi
# if [ "$bluetoothd_running" -eq 1 ]; then
# >&2 echo "Starting bluetoothd..."
# /etc/bluetooth/bluetoothd start || true
# /usr/bin/bluetoothctl power on || true
# fi
}

main() {
trap "resume" EXIT INT TERM HUP QUIT

>&2 echo "Preparing for suspend..."

if pgrep wpa_supplicant; then
wpa_running=1
>&2 echo "Stopping wpa_supplicant..."
killall -9 wpa_supplicant
fi
ifconfig wlan0 down
# if pgrep wpa_supplicant; then
# wpa_running=1
# >&2 echo "Stopping wpa_supplicant..."
# killall -9 wpa_supplicant
# fi
# ifconfig wlan0 down

# if pgrep hciattach; then
# hciattach_running=1
# >&2 echo "Stopping hciattach..."
# /etc/init.d/hciattach stop
# fi
# if pgrep bluetoothd; then
# bluetoothd_running=1
# >&2 echo "Stopping bluetoothd..."
# /etc/bluetooth/bluetoothd stop
# killall -15 bluealsa
# fi

if pgrep hciattach; then
hciattach_running=1
>&2 echo "Stopping hciattach..."
/etc/init.d/hciattach stop
fi
if pgrep bluetoothd; then
bluetoothd_running=1
>&2 echo "Stopping bluetoothd..."
/etc/bluetooth/bluetoothd stop
killall -15 bluealsa
fi
# >&2 echo "Blocking wireless..."
# echo 0 >/sys/class/rfkill/rfkill0/state

>&2 echo "Blocking wireless..."
echo 0 >/sys/class/rfkill/rfkill0/state

>&2 echo "Suspending..."
echo mem >/sys/power/state
# this is really the only line we really need to activate suspend
echo mem >/sys/power/state

exit 0
}
Expand Down
28 changes: 18 additions & 10 deletions skeleton/SYSTEM/tg5040/paks/MinUI.pak/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,26 @@ CPU_PATH=/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
CPU_SPEED_PERF=2000000
echo $CPU_SPEED_PERF > $CPU_PATH

# bt handling (todo, off for now)
rfkill block bluetooth
killall MtpDaemon # I dont think we need to micro manage this one

# BT handling
# on by default, disable based on systemval setting
#bton=`/usr/trimui/bin/systemval bluetooth`
#if [ "$bton" != "1" ] ; then
# /etc/bluetooth/bluetoothd start
# /usr/bin/bluealsa -p a2dp-source&
# touch /tmp/bluetooth_ready
#fi
bton=`/usr/trimui/bin/systemval bluetooth`



blon=$(nextval.elf wifi | sed -n 's/.*"wifi": \([0-9]*\).*/\1/p')
if [ "$blon" -eq 1 ]; then
# Start Bluetooth daemon
/etc/bluetooth/bluetoothd start
sleep 3

bluealsa --profile=a2dp-source --a2dp-volume > /mnt/SDCARD/.userdata/tg5040/logs/bluealsa.txt 2>&1 &
# Turn Bluetooth power on
bluetoothctl power on
touch /tmp/bluetooth_ready

# Enable scanning for bluetooth devices
bluetoothctl scan on > /dev/null 2>&1 &
fi

# wifi handling
# on by default, disable based on systemval setting
Expand Down
Loading