Linux and Bluetooth: SMS alerts
I use a Netbook Samsung N230 to access and monitor my home network. That Netbook have several alert system, for example the UPS is monitored by Apcupsd, so I'm able to detect a power outage at home.
With a Bluetooth-enabled phone and a low-cost operator (Pepephone) is possible to have a low-cost SMS alert system at home.
To be able to pair the computer and the phone we need that both systems are BT-enabled, your computer don't have BT system? you can buy a USB dongle for less than 5 bucks.
Once we fulfill the requirements (phone and computer BT-enabled) we can pair both devices using the GUI, but it's better to know the steps to pair a device through the terminal, is better, faster, easier to trace and error...and super cool!
GO GO GO!
Step 1
Search for any BT device visible from the computer
root@ariel5:~# hcitool scan Scanning ... 00:1E:45:30:11:11 K530
Good, the computer detects the phone BT.
Step 2
Ensure that communication between both devices is OK
root@ariel5:/etc/bluetooth# l2ping 00:1E:45:30:11:11 Ping: 00:1E:45:30:0A:76 from 00:1B:B1:14:11:11 (data size 44) ... 44 bytes from 00:1E:45:30:0A:76 id 0 time 66.68ms
Step 3
Pair the computer with the phone
root@ariel5:~# bluez-simple-agent hci0 00:1E:45:30:11:11 RequestPinCode (/org/bluez/535/hci0/dev_00_1E_45_30_11_11) Enter PIN Code:1234 (type the pin code you will use on the phone) Release New device (/org/bluez/535/hci0/dev_00_1E_45_30_11_11)
Step 4
Create data link to send SMS from the computer using the phone
rfcomm bind 0 00:1E:45:30:11:11 1
to ensure that connection is OK we use the following command:
root@ariel5:~# rfcomm show 00:1E:45:30:11:11 rfcomm0: 00:1E:45:30:0A:76 channel 1 closed
Step 5
Try to send an SMS with gsmsendsms (part of the gsm-utils package)
gsmsendsms -d /dev/rfcomm0 644444444 "¡Hola!"
If everything is OK we will receive and SMS on the phone, almost ready!!.
Step 6
All our work will disappear when we power cycle the machine, so lets do all the changes persistent. Edit /etc/bluetooth/rfcomm.conf and configure it using this example as template:
https://gist.github.com/4455872
Ready to go! Now we can use gsmsendsms to send alerts on our scripts, for example here is the script I have to alert me (via SMS, Twiiter and mail!) when we have a power outage:
https://gist.github.com/4455911
I hope that you find this post useful.
-----
Versión en Español: Linux y Bluetooth. Alertas vía SMS














