#!/bin/sh
#                obexsend.sh
#                -----------
#
# Wrapper to ussp-push (http://www.unrooted.net/hacking/bluez-rfcomm-obex.html)
#
#  Nick Burch <phones@gagravarr.org>

# Put your phone's address in here --\/--   /-- 10 is the bluetooth channel
rfcomm bind /dev/rfcomm1 00:10:20:30:40:50 10

if [ -n "$1" ]
then
   echo "Got one argument, \"$1\""
else
   echo "Usage:"
   echo "   obexsend.sh <filename>"
   exit
fi

tosave=$2
if [ -n "$2" ]
then
   echo "Saving to phone with \"$2\""
else
   # Work magic to build a name
   # Take part after last slash
   num=`echo $1 | awk -F '/' '{print NF}'`
   tosave=`echo $1 | awk -F '/' '{print $NF}'`
fi

echo "To write is \"$tosave\""

ussp-push /dev/rfcomm1 $1 $tosave
