Bluetooth: simple utility with Yad gui

Miscellaneous tools
Post Reply
Message
Author
stemsee

Bluetooth: simple utility with Yad gui

#1 Post by stemsee »

Here is a working yad gui bluetooth scanning and connection utility.
Connects audio device using hcitool and bt-device/bt-audio/bt-obex/bt-network etc. Connects and Disconnects, shows added devices and current connection.

First scan then press one of the buttons for the desired connection type. Then select by highlighting the mac address of the device to be used, drag the mac to the dnd pane at the lower half of the gui, and wait for the results in the same gui.

This is my first use of hcitool and bluez in bash/cli ... any pointers welcomed.

Work in progress.

this is for bluez4

Code: Select all

#!/bin/sh
# simple bluetooth connection gui tool
# by stemsee copyright @ 2019 Marcos M Contant
#
[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\"" 
export OUTPUT_CHARSET=UTF-8
running=`ps -e | grep bt.sh | wc -l` 
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export camino=$HOME/.wifi-connect
export track=/tmp/Wifi-TrayNet
export pics=/usr/share/pixmaps
[[ ! -d /tmp/Wifi-TrayNet ]] && mkdir /tmp/Wifi-TrayNet
function sayonara {     #MochiMoppel/stemsee geometry recorder
[[ ! -f "$track"/geom ]] && exit
   yad --text="$WINDOWTITLE: WT Geometry-Recorder" --window-icon="$pics/wireless.png" \
   --geometry=200x10+100-100 --no-focus --no-buttons --undecorated \
   --on-top --form --skip-taskbar --field="MoreTime:FBTN" "bash -c sayonara" \
   --timeout-indicator=top --timeout=6
   nought=`xwininfo -stats -name "$WINDOWTITLE" | grep "$WINDOWTITLE"`
   XWININFO=`xwininfo -stats -name "$WINDOWTITLE"`
   if [[ ! -z "$nought" ]]; then
	   ARRAY=(${XWININFO#* X: })
	   AX=${ARRAY[0]}
	   AY=${ARRAY[4]}
	   RX=${ARRAY[8]}
	   RY=${ARRAY[12]}
	   W=${ARRAY[14]}
	   H=${ARRAY[16]}
	   X=$((AX-RX))
	   Y=$((AY-RY))
	   echo "$W"x"$H"+"$X"+"$Y" > $camino/geometry/$WINDOWTITLE
   else
		exit
   fi
}; export -f sayonara
function btscanfn (){
	timeout 14 hcitool scan | grep -v 'Scanning' | tr '\t' ' ' >/tmp/Wifi-TrayNet/btresults &
function flash (){
	echo -e '\f' 
	sleep 0.4
	echo "Please Wait ... !" 
	sleep 0.4
}; export -f flash
for i in `seq 1 1 13`
do
	bash -c	flash
done
	cat /tmp/Wifi-TrayNet/btresults
}; export -f btscanfn

function btcon (){
bash -c btset
echo "DnD mac to connect"
cat /tmp/Wifi-TrayNet/btresults
tail -fn0 /tmp/Wifi-TrayNet/btmac | while read line
do
listed=`bt-device -l | grep $line`
if [[ -z "$listed" ]]; then
	bt-device -c $line
else
	hcitool lecc $line
fi
bt-audio -c $line
bash -c blank
done
}; export -f btcon

function btobex (){
kill $btpid >/dev/null
bash -c btset
kill $obxpid
echo "DnD mac for btobex" 
sleep 1
cat /tmp/Wifi-TrayNet/btresults 
tail -fn0 /tmp/Wifi-TrayNet/btmac | while read line
do
bt-obex -s &
export obxpid=$!
echo -e "#
# RFCOMM configuration file.
#

rfcomm4 {
#	# Automatically bind the device at startup
	bind yes;
#
#	# Bluetooth address of the device
	device $line;
#
#	# RFCOMM channel for the connection
	channel	4;
#
#	# Description of the connection
	comment \"Bluetooth rfcomm4 $line\";
}
" > /etc/bluetooth/rfcomm.conf
yes | bt-obex -s /root/Downloads &
export btpid=$!
listed=`bt-device -l | grep $line`
if [[ -z "$listed" ]]; then
    bt-device -c $line --set Trusted
    rfcomm connect rfcomm4 4
    bt-obex -f $line &
    wait $!
else
	hcitool lecc $line
	rfcomm connect rfcomm4 4
	bt-obex -f $line &
	wait $!
fi
bash -c blank
done &
export btobexpid=$!
}; export -f btobex

function btnet (){
bash -c btset
echo "DnD mac for network" 
sleep 1
cat /tmp/Wifi-TrayNet/btresults 
tail -fn0 /tmp/Wifi-TrayNet/btmac | while read line
do
listed=`bt-device -l | grep $line`
if [[ -z "$listed" ]]; then
	bt-device -c $line
	sleep 2
	bt-network -c $line
	bt-network -f $line
	bt-network -s $line
else
	echo "yes" | hcitool lecc $line
	sleep 2
	bt-network -c $line
	bt-network -s $line
	bt-network -f $line
fi
sleep 3
bash -c blank
done
}; export -f btnet

function btdisconfn (){
bash -c btset
tail -fn0 /tmp/Wifi-TrayNet/btmac | while read line
do
	bt-device -d $line
	hcitool ledc $line
	hcitool dc $line
	sleep 3
	bash -c blank
done
}; export -f btdisconfn

function rmdev (){
bash -c btset
echo "Drag'n'Drop mac of device to remove" 
bt-device -l 
tail -fn0 /tmp/Wifi-TrayNet/btmac | while read line
do	
	bt-device -r $line
	sleep 3
	bash -c blank
done
}; export -f rmdev

function macrx (){
echo "macrx"
tail -fn0 /tmp/Wifi-TrayNet/hciselect | while read line
do
	dupe=`echo "$line" | grep -ixE '([0-9A-Z:]*)'`
	if [[ ! -z "$dupe" ]]; then
		echo "$line" > /tmp/Wifi-TrayNet/btmac
	else
		echo "$line" > /tmp/Wifi-TrayNet/btcmd
	fi
done &
export macrxpid=$!
}; export -f macrx

function combt (){
bash -c btset
tail -fn0 /tmp/Wifi-TrayNet/btfn | while read line
do
echo -e '\f' 
case $line in
	btcon) cat /tmp/Wifi-TrayNet/btresults;;
	input|btnet|btobex|btsend|btdiscon) hcitool con;;
	rmdev) bt-device -l;;
esac
[[ ! -z "$line" ]] && bash -c "$line" &>/tmp/Wifi-TrayNet/btpipe &
export funcpid=$!
done &
export combtpid=$!
}; export -f combt
function btftp (){
bash -c btset
sleep 2
tail -fn0 /tmp/Wifi-TrayNet/btmac | while read line
do
	bt-obex -f "$line" &
	wait $!
done
}; export -f btftp
function btserial (){
bash -c btset
sleep 2
tail -fn0 /tmp/Wifi-TrayNet/btmac | while read line
do
echo -e "#
# RFCOMM configuration file.
#

rfcomm4 {
#	# Automatically bind the device at startup
	bind yes;
#
#	# Bluetooth address of the device
	device $line;
#
#	# RFCOMM channel for the connection
	channel	4;
#
#	# Description of the connection
	comment \"Bluetooth rfcomm4 $line\";
}
" > /etc/bluetooth/rfcomm.conf
rfcomm connect rfcomm4 4 
bt-obex -f $line &
wait $!
bash -c blank
done
}; export -f btftp

function btsend (){
bash -c btset
sleep 1
tail -fn0 /tmp/Wifi-TrayNet/btmac | while read line
do	
bt-obex -s &
export obxpid=$!
echo -e "#
# RFCOMM configuration file.
#

rfcomm4 {
#	# Automatically bind the device at startup
	bind yes;
#
#	# Bluetooth address of the device
	device $line;
#
#	# RFCOMM channel for the connection
	channel	4;
#
#	# Description of the connection
	comment \"Bluetooth rfcomm4 $line\";
}
" > /etc/bluetooth/rfcomm.conf
	this=`yad --file`
	[[ -z "$this" ]] && exit
rfcomm connect rfcomm4 4
yes | bt-obex -p "$line" "$this" &
wait $!
	sleep 1
	bash -c blank
done
}; export -f btsend
function btget (){
echo "ftp search"
sdptool search FTP
tail -fn0 /tmp/Wifi-TrayNet/btmac | while read line
do
echo -e "#
# RFCOMM configuration file.
#

rfcomm4 {
#	# Automatically bind the device at startup
	bind yes;
#
#	# Bluetooth address of the device
	device $line;
#
#	# RFCOMM channel for the connection
	channel	4;
#
#	# Description of the connection
	comment \"Bluetooth rfcomm4 $line\";
}
" > /etc/bluetooth/rfcomm.conf
rfcomm connect rfcomm4 4
rfcomm listen 4
obexfs -b$line
cd /
ls /
done
}; export -f btget
function btset (){
	echo -e '\f'
	hcitool con >/tmp/Wifi-TrayNet/btpipe
	kill $funcpid >/dev/null
}; export -f btset

function funclist (){
export tap=/tmp/Wifi-TrayNet/selecthci
echo "bash -c blank"
echo "bash -c btcon"
echo "bash -c btdisconfn"
echo "bash -c btnet"
echo "bash -c btobex"
echo "bash -c btscanfn"
echo "bash -c btsend"
echo "bash -c btrmdev"
echo "bash -c btget"
echo "bash -c btftp"
echo "bash -c command"
echo "What have you?"
tail -fn0 /tmp/Wifi-TrayNet/selecthci | while read line
do
		if [[ -z "$line" ]]; then
			echo "nope"
			bash -c command
		else
			bash -c blank
			exec $line
		fi
export tap=/tmp/Wifi-TrayNet/hciselect
done
}; export -f funclist

function command (){
export tap=/dev/null
echo -e '\f'
echo "bash -c funclist" 
echo "rfkill block bluetooth" 
echo "rfkill unblock bluetooth" 
echo "hcitool lewladd"
echo "bt-device -l" 
echo "rfcomm connect rfcomm4 4"
echo "bash -c btsend"
echo "geany /usr/sbin/Wifi-TrayNet"
echo "ls /root/.wifi-connect/profiles"
echo "cat /tmp/Wifi-TrayNet/btresults"
echo "google-chrome-stable --no-sandbox www.google.com" 
echo "seamonkey http://www.murga-linux.com/puppy/"
#line=$(yad --geometry=100x100+100+100 --on-top --text="Command D'n'D" --undecorated --skip-taskbar --dnd)
tail -fn0 /tmp/Wifi-TrayNet/selecthci | while read line
do
		if [[ -z "$line" ]]; then
			echo "nope"
			bash -c command
		else
			bash -c blank
			exec $line
		fi
export tap=/tmp/Wifi-TrayNet/hciselect
done
}; export -f command

function blank (){
	echo -e '\f' >/tmp/Wifi-TrayNet/btpipe
}; export -f blank

function bluetooth (){
kill $btpid &>/dev/null
kill $combtpid &>/dev/null
kill $macrxpid &>/dev/null
export tap=/tmp/Wifi-TrayNet/hciselect
export pat=/tmp/Wifi-TrayNet/selecthci
[[ ! -f /tmp/Wifi-TrayNet/btpipe ]] && mkfifo -m 755 /tmp/Wifi-TrayNet/btpipe
exec 2<> /tmp/Wifi-TrayNet/btpipe
[[ ! -f /tmp/Wifi-TrayNet/hciselect ]] && touch /tmp/Wifi-TrayNet/hciselect
[[ ! -f /tmp/Wifi-TrayNet/selecthci ]] && touch /tmp/Wifi-TrayNet/selecthci
[[ ! -f /tmp/Wifi-TrayNet/btfn ]] && touch /tmp/Wifi-TrayNet/btfn
[[ ! -f /tmp/Wifi-TrayNet/btmac ]] && touch /tmp/Wifi-TrayNet/btmac

WINDOWTITLE="Bluetooth"
export WINDOWTITLE
bash -c sayonara &
yad --listen --plug=$$ --tabnum=1 --item-separator=" " --form --cycle-read --columns=2 --field=A --field=0 --field=1 --field=2 --field=3 --field=4 --field=5 --field=6 --field=7 --field=8 --field=9 --field=10 <& 2 &
yad --plug=$$ --tabnum=2 --text="\t\t\t\t\t\t\tDnD panel\n\tClick a button Then Drag the mac address here!\n\tDrop command string here..." --dnd | tee $pat >$tap &
yad --geometry=$(cat $camino/geometry/$WINDOWTITLE) --title="$WINDOWTITLE" --window-icon=$pics/bluetooth-active.png --key=$$ --columns=2 --paned --height=220 --width=300 --tab=Found --tab=DnD --button="Command":"echo command" --button="Scan":"echo btscanfn" --button="Remove":"echo rmdev" --button="Connect":"echo btcon" --button="Disconnect":"echo btdisconfn" >/tmp/Wifi-TrayNet/btfn &
bash -c macrx &
bash -c combt &
sleep 0.1
echo -e '\f' >/tmp/Wifi-TrayNet/btpipe 
}; export -f bluetooth
bash -c bluetooth &
this is for bluez5
edit your bluetooth.service startup file so that the daemon 'bluetoothd' starts in compat mode, 'bluetoothd --compat &'
and starts 'obexd -a &'
plus sdptool add FTP
sdptool add OPUSH
sdptool add KBD
or other services.

Code: Select all

#!/bin/sh
[[ "`whoami`" != "root" ]] && exec sudo -A ${0} ${@} 
running=`ps -e | grep blueteeth | wc -l` 
[[ "$running" -gt 2 ]] && exit
[[ ! -d /tmp/blueteeth ]] && mkdir /tmp/blueteeth
function btscanfn (){
	echo -e '\f'
	echo "Scanning! Click connect button to see results"
	sleep 1	
bluetoothctl
scan on

}; export -f btscanfn

function btcon (){
bash -c btset
bluetoothctl devices | awk '{fflush();print;fflush()}' | awk '{print $2,$3,$4,$5,$6,$7,$8,$9,$10}'
timeout 24 tail -Fn0 /tmp/blueteeth/btmac | awk '{fflush();print;fflush()}' | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"
listed=`bluetoothctl paired-devices | grep $line`
if [[ ! -z "$listed" ]]; then
	bluetoothctl trust $line &
	wait $!
	timeout 8 bluetoothctl connect $line &
	wait $!
else
unset ok
while [[ -z "$ok" ]]; do bluetoothctl pair $line; sleep 22; ok=`bluetoothctl paired-devices | grep $line`; [[ ! -z "$ok" ]] && break; done
	bluetoothctl trust $line
	unset hao
while  [[ -z "$hao" ]]; do bluetoothctl connect $line; sleep 22; hao=`hcitool connected | grep $line`; [[ ! -z "$hao" ]] && break; done
fi
done
}; export -f btcon

function btobex (){
kill "$btpid"
bash -c btset
bluetoothctl paired-devices | awk '{print $2,$3,$4,$5,$6,$7,$8,$9,$10}'
tail -Fn0 /tmp/blueteeth/btmac | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"
export line
bash -c rfcomfn
listed=`bt-device -l | grep $line`
if [[ ! -z "$listed" ]]; then
timeout 8 bluetoothctl connect $line
else
	bluetoothctl pair $line
	bluetoothctl trust $line
	timeout 8 bluetoothctl connect $line
fi
rfcomm connect rfcomm4 4
export btpid=$!
wait $!
done &
}; export -f btobex

function btnet (){
bash -c btset
echo "DnD mac for network" 
sleep 1
bluetoothctl devices | awk '{print $2,$3,$4,$5,$6,$7,$8,$9,$10}'
timeout 24 tail -Fn0 /tmp/blueteeth/btmac | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"
listed=`bluetoothctl paired-devices | grep $line`
if [[ ! -z "$listed" ]]; then
	timeout 8 bluetoothctl connect $line
else
	bluetoothctl pair $line
	bluetoothctl trust $line
	timeout 8 bluetoothctl connect $line
fi
 enil=`bluetoothctl list | awk '{print $2}'`
	( sleep 4; echo "nameserver 8.8.8.8" >/etc/resolv.conf; busybox udhcpc -i bnep0 ) &
	bt-network -a $enil -c $line nap &
	echo -e "#!/bin/sh
	line=$line
	enil=$enil
	( sleep 4; echo \"nameserver 8.8.8.8\" >/etc/resolv; busybox udhcpc -i $enil ) &
	bt-network -a \$enil -c \$line nap &
" >$camino/"\"blth\"+$line"
	chmod 755 $camino/"\"blth\"+$line"
	return 0
done
}; export -f btnet

function btdisconfn (){
bash -c btset
timeout 24 tail -Fn0 /tmp/blueteeth/btmac | while read line
do
unset ok
[[ ! -z "$brk" ]] && exec "$brk"
	while [[ "$ok" = "" ]]; do bluetoothctl disconnect $line; sleep 7; ok=`hcitool connected | grep $line`; [[ -z "$ok" ]] && break; done
done
}; export -f btdisconfn

function macrx (){
kill ${macrxpid}
bash -c btset
echo "macrx"
tail -Fn0 /tmp/blueteeth/hciselect | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"
	dupe=`echo "$line" | grep -ixE '([0-9A-Z:]*)'`
	if [[ ! -z "$dupe" ]]; then
		echo "$line" > /tmp/blueteeth/btmac
	else
		echo "$line" > /tmp/blueteeth/btcmd
	fi
done &
export macrxpid=$!
}; export -f macrx
function rfcomfn (){
[[ ! -z "$rfpid" ]] && kill $rfpid
[[ ! -z "$rfpd" ]] && kill $rfpd
[ ! -f 	/etc/bluetooth/rfcomm.conf ] && echo -e "#
# RFCOMM configuration file.
#

rfcomm4 {
#	# Automatically bind the device at startup
	bind yes;
#
#	# Bluetooth address of the device
	device $line;
#
#	# RFCOMM channel for the connection
	channel	4;
#
#	# Description of the connection
	comment \"Bluetooth rfcomm4 $line\";
}
" > /etc/bluetooth/rfcomm.conf
rfcomm connect rfcomm4 4 &
export rfpid=$!
rfcomm listen 4 &
export rfpd=$!
}; export -f rfcomfn
function toggle (){
[[ ! -f /tmp/blueteeth/toggle ]] && touch /tmp/blueteeth/toggle || rm -f /tmp/blueteeth/toggle
[[ -f /tmp/blueteeth/toggle ]] && service bluetooth stop || service bluetooth start
[[ -f /tmp/blueteeth/toggle ]] && systemctl disable bluetooth.service || systemctl enable bluetooth.service
}; export -f toggle
function combt (){
kill ${compid}
kill $funcpid
bash -c btset
tail -Fn0 /tmp/blueteeth/btfn | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"
echo -e '\f' 
case $line in
	btcon) bluetoothctl devices;;
	btrmdev|input|btnet|btobex|btsend|btdiscon) bluetoothctl paired-devices;;
esac
[[ ! -z "$line" ]] && ( bash -c "$line" >/tmp/blueteeth/btpipe ) &
export funcpid=$!
done &
export compid=$!
}; export -f combt
function btftp (){
bash -c btset
kill $btpid
timeout 24 tail -Fn0 /tmp/blueteeth/btmac | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"
	obexftp -b -c/ &
export btpid=$!
	wait $!
done
}; export -f btftp
function btserial (){
bash -c btset
kill $btpid
timeout 24 tail -Fn0 /tmp/blueteeth/btmac | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"
export $line
bash -c rfcomfn
rfcomm connect rfcomm4 4 
bt-obex -y -c/root/Downloads -a $BTDEV -s
export btpid=$!
wait $!
bash -c blank
done
}; export -f btserial
function btrmdev (){
bash -c btset
timeout 24 tail -Fn0 /tmp/blueteeth/btmac | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"
	bluetoothctl disconnect $line
	bluetoothctl untrust $line
	bluetoothctl remove $line
done
}; export -f btrmdev
function btsend (){
bash -c btset
timeout 24 tail -Fn0 /tmp/blueteeth/btmac | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"	
export $line
bash -c rfcomfn
	this=`yad --file`
	[[ -z "$this" ]] && exit
rfcomm connect rfcomm4 4 &
rfpid=$!
bt-obex -y -d -b "$line" "$this" &
wait $!
	sleep 1
	kill $rfpid 2>/dev/null
done
}; export -f btsend
function btget (){
echo "ftp search"
timeout 8 sdptool search FTP
timeout 24 tail -Fn0 /tmp/blueteeth/btmac | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"
export $line
bash -c rfcomfn
obexfs -b$line
cd /
ls /
done
}; export -f btget
function btset (){
	kill ${compid}
	kill $funcpid
	bluetoothctl scan off
	echo -e '\f'
	hcitool con >/tmp/blueteeth/btpipe
}; export -f btset

function funclist (){
bash -c blank
export tap=/tmp/blueteeth/selecthci
echo "bash -c blank"
echo "bash -c btcon"
echo "bash -c btdisconfn"
echo "bash -c btnet"
echo "bash -c btobex"
echo "bash -c btscanfn"
echo "bash -c btsend"
echo "bash -c btrmdev"
echo "bash -c btget"
echo "bash -c btftp"
echo "bash -c command"
echo "bash -c rfcomfn"
echo "bash -c serial"
echo "What have you?"
timeout 24 tail -Fn0 /tmp/blueteeth/selecthci | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"
		if [[ -z "$line" ]]; then
			echo "nope"
		else
			bash -c blank
			exec $line
		fi
export tap=/tmp/blueteeth/hciselect
done
}; export -f funclist

function command (){
bash -c blank
export tap=/dev/null
echo -e '\f'
echo "bash -c funclist" 
echo "rfkill block bluetooth" 
echo "rfkill unblock bluetooth" 
echo "bluetoothctl scan on"
echo "bluetoothctl scan off"
echo "bluetoothctl discoverable on"
echo "bluetoothctl pairable on"
echo "rfcomm connect rfcomm4 4"
echo "bash -c btsend"
echo "cat /tmp/blueteeth/btresults"
echo "google-chrome-stable --no-sandbox www.google.com" 
echo "seamonkey http://www.murga-linux.com/puppy/"
echo "bash -c blank"
echo "bash -c btcon"
echo "bash -c btdisconfn"
echo "bash -c btnet"
echo "bash -c btobex"
echo "bash -c btscanfn"
echo "bash -c btsend"
echo "bash -c btrmdev"
echo "bash -c btget"
echo "bash -c btftp"
echo "bash -c serial"
echo "bash -c rfcomfn"
echo "bash -c command"
echo "bt-obex -y -a `bluetoothctl list | cut -f2 -d' '` -s"
echo "obexfs --help"
echo "obexftp --help"
echo "obexd --help"
echo "bt-obex --help"
echo "obexftpd --help"
echo "obexautofs --help"
echo "obex-client-tool --help"
echo "obex-server-tool --help"
echo "obex-check-device --help"
#line=$(yad --geometry=100x100+100+100 --on-top --text="Command D'n'D" --undecorated --skip-taskbar --dnd)
timeout 24 tail -Fn0 /tmp/blueteeth/selecthci | while read line
do
[[ ! -z "$brk" ]] && exec "$brk"
		if [[ -z "$line" ]]; then
			echo "nope"
		else
			bash -c blank
			exec $line
		fi
export tap=/tmp/blueteeth/hciselect
done
}; export -f command

function blank (){
	echo -e '\f' >/tmp/blueteeth/btpipe
}; export -f blank

function bluetooth (){
kill $btpid 2>/dev/null
kill $compid 2>/dev/null
kill $macrxpid 2>/dev/null
export tap=/tmp/blueteeth/hciselect
export pat=/tmp/blueteeth/selecthci
[[ -f /tmp/blueteeth ]] && rm -f /tmp/blueteeth
[[ ! -f /tmp/blueteeth/btpipe ]] && mkfifo -m 755 /tmp/blueteeth/btpipe
exec 2<> /tmp/blueteeth/btpipe
[[ ! -f /tmp/blueteeth/hciselect ]] && touch /tmp/blueteeth/hciselect
[[ ! -f /tmp/blueteeth/selecthci ]] && touch /tmp/blueteeth/selecthci
[[ ! -f /tmp/blueteeth/btfn ]] && touch /tmp/blueteeth/btfn
[[ ! -f /tmp/blueteeth/btmac ]] && touch /tmp/blueteeth/btmac
export BTDEV=`bluetoothctl list | awk '{print $2}'`

WINDOWTITLE="Blueteeth"
export WINDOWTITLE
bash -c sayonara &
fields=$(for i in {1..43}; do echo "--field=$i "; done)
yad --listen --plug=$$ --tabnum=1 --item-separator=" " --form \
--cycle-read --columns=3 --field=A --field=0 $fields <& 2 &
yad --plug=$$ --tabnum=2 --text="\t\t\t\t\tDnD panel\n\tClick a button \
Then Drag the mac-address or command here!" --dnd | tee $pat >$tap &
yad --geometry=$(cat $camino/geometry/$WINDOWTITLE) --title="$WINDOWTITLE" \
--window-icon=$pics/bluetooth-active.png --key=$$ --paned \
--height=220 --width=300 --tab=Found --tab=DnD --button="toggle service":"echo toggle" --button="Command":"echo command" \
--button="Scan":"echo btscanfn" --button="Remove":"echo btrmdev" \
--button="Connect":"echo btcon" --button="Disconnect":"echo btdisconfn" >/tmp/blueteeth/btfn &
yp=$!
bash -c macrx &
export macrxpid=$!
bash -c combt &
export compid=$!
bt-obex -y -a `bluetoothctl list | awk '{print $2}'` -s &
sleep 0.1
echo -e '\f' >/tmp/blueteeth/btpipe
wait $yp
killall bash
}; export -f bluetooth
bash -c bluetooth &
Attachments
xscreenshot-20190117T035153.png
(20.64 KiB) Downloaded 1809 times
Last edited by stemsee on Wed 06 Nov 2019, 10:35, edited 5 times in total.

User avatar
perdido
Posts: 1528
Joined: Mon 09 Dec 2013, 16:29
Location: ¿Altair IV , Just north of Eeyore Junction.?

#2 Post by perdido »

Hi stemsee,

Just wondering what are the packages needed? I want to try this utility and test it.

I see bluez , yad , wifi-tray-net , hcitool ,

Any others?

Thanks for working on this bluetooth utility! I have never had a consistent bluetooth connection with puppy, just hit and miss,
a working bluetooth utility would be so good for puppy.!


.

stemsee

#3 Post by stemsee »

Hi

Wifi-TrayNEt is not needed. This was developed for TrayNet but this version is standalone.

Bluez / tools etc
hcitool
yad
Attachments
xscreenshot-20190111T170309.png
(21.21 KiB) Downloaded 368 times
Last edited by stemsee on Thu 17 Jan 2019, 03:50, edited 1 time in total.

User avatar
perdido
Posts: 1528
Joined: Mon 09 Dec 2013, 16:29
Location: ¿Altair IV , Just north of Eeyore Junction.?

#4 Post by perdido »

stemsee wrote:Hi

Wifi-TrayNEt is not needed. This was developed for TrayNet but this version is standalone.

Bluez / tools etc
hcitool
yad

I actually upgraded significantly with a commandline execution facility.
Thanks for the quick reply, will try this later tonite and see what I can see :)

.

stemsee

#5 Post by stemsee »

Attachments
xscreenshot-20190111T190928.png
(17.1 KiB) Downloaded 372 times
Last edited by stemsee on Thu 17 Jan 2019, 03:50, edited 1 time in total.

User avatar
perdido
Posts: 1528
Joined: Mon 09 Dec 2013, 16:29
Location: ¿Altair IV , Just north of Eeyore Junction.?

#6 Post by perdido »

Hi stemsee,

I have a bluetooth adapter in my dell e6400 laptop that is very difficult.
It never initializes with bluez version 5 or later, I was hoping to see it
using the latest ubuntu version of bluez 5.48 & bluez tools in upupbb but that did not happen. It is my hardware that is a problem.

I am still going to keep trying this and will report back if I can figure out the hardware issues.

The video did help me understand the procedure for scanning and connecting. Thanks!

.

Pro
Posts: 109
Joined: Fri 12 Feb 2010, 11:12

#7 Post by Pro »

it's for bluez4 or bluez5?

I do something like this, maybe it will be useful for you
http://murga-linux.com/puppy/viewtopic.php?t=111331

stemsee

#8 Post by stemsee »

Thanks Pro

I am studying your code.

Whats the functional difference between bluez4 and 5?

stemsee

#9 Post by stemsee »

I changed a bit of the code (rfcomm connect rfcomm4 4) and I was able to send files to android phone. Audio devices connect. Command function is more comprehensively implemented, but basically is a terminal. Just lacking interactive input ... for the moment.
Attachments
xscreenshot-20190216T132721.png
(25.08 KiB) Downloaded 1583 times
xscreenshot-20190216T132739.png
functions listing
(21.35 KiB) Downloaded 1568 times

stemsee

#10 Post by stemsee »

So this version is for bluez5, using bluetoothctl in places.

start bluetoothd --compat ...
Attachments
blueteeth.gz
(9.59 KiB) Downloaded 214 times
xscreenshot-20190224T093524.png
(21.91 KiB) Downloaded 1442 times
Last edited by stemsee on Wed 06 Nov 2019, 02:35, edited 1 time in total.

stemsee

#11 Post by stemsee »

I now call the standalone script blueteeth ! !

Updated.

or start daemons like this
#bluetoothd --compat &
#obexd -a &
#spdtool add FTP
#sdptool add OPUSH
#sdptool add A2SRV
#bt-obex -y -a `bluetoothctl device | awk '{print $2}'` -s
Attachments
xscreenshot-20191027T152115.png
(48.3 KiB) Downloaded 678 times
Last edited by stemsee on Mon 04 Nov 2019, 21:04, edited 1 time in total.

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#12 Post by dancytron »

This is a little off topic, but has anyone gotten bluetooth headsets to work correctly without pulse audio?

If so, how did you do it?

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#13 Post by rcrsn51 »

dancytron wrote:This is a little off topic, but has anyone gotten bluetooth headsets to work correctly without pulse audio? If so, how did you do it?
The Starter Kit has a bluetooth package that does this.

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#14 Post by dancytron »

rcrsn51 wrote:
dancytron wrote:This is a little off topic, but has anyone gotten bluetooth headsets to work correctly without pulse audio? If so, how did you do it?
The Starter Kit has a bluetooth package that does this.
Thanks, I'll take a look later.

edit: here is the link for other's reference

http://murga-linux.com/puppy/viewtopic. ... 553#979553
Last edited by dancytron on Sun 27 Oct 2019, 21:18, edited 1 time in total.

stemsee

#15 Post by stemsee »

On fatdog there is pulse emulation.

My script connects to audio headset.
Attachments
xscreenshot-20191027T213353.png
(16.63 KiB) Downloaded 654 times

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#16 Post by dancytron »

stemsee wrote:On fatdog there is pulse emulation.

My script connects to audio headset.
Okay, thanks.

I'll have to dig into this again. I really don't remember what I did, just that I failed to get it to work.

stemsee

#17 Post by stemsee »

Another update!

This one actually works!! ha ha ..
Attachments
blueteeth.gz
fake .gz
(10.72 KiB) Downloaded 182 times

Post Reply