Sunday, 13 May 2012

w810 ticker message via bluetooth using bash

Assuming bluetooth is setup already and the Sony-Ericcson W810i is bound to rfcomm0. XX:XX:XX:XX:XX:XX is set to the baddr of the phone. Takes a few seconds for the rfcomm to go connected. The sleep command sets how long the ticker will display for, the rfcomm closes when the script exits. #===========cut here ===============================
#!/bin/bash
source /etc/profile
export PATH
MSG=$1$2$3$4$5$6
THERE=$(hcitool name XX:XX:XX:XX:XX:XX) 
if [ "$THERE" != "" ]; then
Z=$( C='';until [ "$C" == "connected" ];do C=`rfcomm show 0|cut -d ' ' -f 5`; done;echo "at*seuis=1;*setick=\"$MSG\",1" >/dev/rfcomm0 )&
let Ztimeout=1
ZZ=$((while read line
do
 y=$((Ztimeout++))
 if [ $Ztimeout -gt 300 ] ; then
   exit
 fi
 echo $line
 if [ "$line" == "*SESFI: 1" ]; then
  sleep 15
  break
 fi
 echo  $ZZ
done < /dev/rfcomm0 ) )

else
 echo "Device bluetooth not on or not in range"
fi

No comments: