Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 13 Dec 2019, 04:02
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Bluetooth: simple utility with Yad gui
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [17 Posts]   Goto page: 1, 2 Next
Author Message
stemsee

Joined: 27 Jun 2013
Posts: 2544
Location: In The Way

PostPosted: Fri 11 Jan 2019, 00:00    Post subject:  Bluetooth: simple utility with Yad gui
Subject description: connect bt devices
 

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:
#!/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:
#!/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 &
xscreenshot-20190117T035153.png
 Description   
 Filesize   20.64 KB
 Viewed   1351 Time(s)

xscreenshot-20190117T035153.png


Last edited by stemsee on Wed 06 Nov 2019, 06:35; edited 5 times in total
Back to top
View user's profile Send private message MSN Messenger 
perdido


Joined: 09 Dec 2013
Posts: 1438
Location: ¿Altair IV , Just north of Eeyore Junction.?

PostPosted: Fri 11 Jan 2019, 12:38    Post subject:  

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.!


.
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2544
Location: In The Way

PostPosted: Fri 11 Jan 2019, 13:14    Post subject:  

Hi

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

Bluez / tools etc
hcitool
yad
xscreenshot-20190111T170309.png
Description 
png

 Download 
Filename  xscreenshot-20190111T170309.png 
Filesize  21.21 KB 
Downloaded  261 Time(s) 

Last edited by stemsee on Wed 16 Jan 2019, 23:50; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
perdido


Joined: 09 Dec 2013
Posts: 1438
Location: ¿Altair IV , Just north of Eeyore Junction.?

PostPosted: Fri 11 Jan 2019, 14:44    Post subject:  

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 Smile

.
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2544
Location: In The Way

PostPosted: Fri 11 Jan 2019, 15:10    Post subject:  

Here is a video of usage.
https://drive.google.com/file/d/1rf5g8hpcCO0Gew3NdGrbGzyALStk7TzH
xscreenshot-20190111T190928.png
Description 
png

 Download 
Filename  xscreenshot-20190111T190928.png 
Filesize  17.1 KB 
Downloaded  274 Time(s) 

Last edited by stemsee on Wed 16 Jan 2019, 23:50; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
perdido


Joined: 09 Dec 2013
Posts: 1438
Location: ¿Altair IV , Just north of Eeyore Junction.?

PostPosted: Sat 12 Jan 2019, 01:39    Post subject:  

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!

.
Back to top
View user's profile Send private message 
Pro

Joined: 12 Feb 2010
Posts: 112

PostPosted: Mon 14 Jan 2019, 01:26    Post subject:  

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
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2544
Location: In The Way

PostPosted: Fri 18 Jan 2019, 12:38    Post subject:  

Thanks Pro

I am studying your code.

Whats the functional difference between bluez4 and 5?
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2544
Location: In The Way

PostPosted: Sat 16 Feb 2019, 09:39    Post subject:  

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.
xscreenshot-20190216T132721.png
 Description   
 Filesize   25.08 KB
 Viewed   1147 Time(s)

xscreenshot-20190216T132721.png

xscreenshot-20190216T132739.png
 Description   functions listing
 Filesize   21.35 KB
 Viewed   1147 Time(s)

xscreenshot-20190216T132739.png

Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2544
Location: In The Way

PostPosted: Sun 24 Feb 2019, 06:52    Post subject:  

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

start bluetoothd --compat ...
blueteeth.gz
Description 
gz

 Download 
Filename  blueteeth.gz 
Filesize  9.59 KB 
Downloaded  36 Time(s) 
xscreenshot-20190224T093524.png
 Description   
 Filesize   21.91 KB
 Viewed   1020 Time(s)

xscreenshot-20190224T093524.png


Last edited by stemsee on Tue 05 Nov 2019, 22:35; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2544
Location: In The Way

PostPosted: Sun 27 Oct 2019, 10:25    Post subject:  

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
xscreenshot-20191027T152115.png
 Description   
 Filesize   48.3 KB
 Viewed   269 Time(s)

xscreenshot-20191027T152115.png


Last edited by stemsee on Mon 04 Nov 2019, 17:04; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
dancytron

Joined: 18 Jul 2012
Posts: 1413

PostPosted: Sun 27 Oct 2019, 14:20    Post subject:  

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?
Back to top
View user's profile Send private message 
rcrsn51


Joined: 05 Sep 2006
Posts: 12807
Location: Stratford, Ontario

PostPosted: Sun 27 Oct 2019, 14:26    Post subject:  

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.
Back to top
View user's profile Send private message 
dancytron

Joined: 18 Jul 2012
Posts: 1413

PostPosted: Sun 27 Oct 2019, 15:26    Post subject:  

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.php?p=979553#979553

Last edited by dancytron on Sun 27 Oct 2019, 17:18; edited 1 time in total
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2544
Location: In The Way

PostPosted: Sun 27 Oct 2019, 16:35    Post subject:  

On fatdog there is pulse emulation.

My script connects to audio headset.
xscreenshot-20191027T213353.png
 Description   
 Filesize   16.63 KB
 Viewed   231 Time(s)

xscreenshot-20191027T213353.png

Back to top
View user's profile Send private message MSN Messenger 
Display posts from previous:   Sort by:   
Page 1 of 2 [17 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0872s ][ Queries: 12 (0.0077s) ][ GZIP on ]