Bluvert

History

	
Version 1.2.1
	* database schema will be created on startup if not already created
	* if CSV file with active bluetooth devices can not be found, only a debug message will be shown

Version 1.2 - CCC / 26c3 edition
	* global configuration variable $cwd available - will be replaced by current working directory
	* Bluvert is executed in threading mode - no more need for Cron execution
	* execution of Bluetooth neighbourhood discovery is done by execute-server.py - no more need for Cron execution, too
	* sending workers running in threded mode, too - improved performance of sending outstanding messages
	* time span between discovery and sending can be defined in config.ini
	* script for discovering the Bluetooth neighbourhood can be defined in config.ini
	* setting data.current_bluetooth_devices renamed to data.current_bluetooth_devices_csv
	* add-message.py:
		* if argument -r is not given, "*" is used as default recipient
		* if add-message.py is called with one argument the argument is taken as file name
Version 1.1
	* Bluvert now uses ussp-push as standard sending tool - requires no PIN authentication
	* send-obexftp.sh and send-ussp.sh added
	* set-active-bluetooth-devices expects now as parameter a path to CSV file
	* documentation updated
	* directory structure updated

Version 1.0
	* Bluvert published on sourceforge.net

Overview

Description

Bluvert is a small collection of Python scripts which allows you to build up quickly a Bluetooth advertisement or welcome server.
Imagine one of the following situations:

Any of this situations can be realized with Bluvert.

Theory of working

Bluvert uses a more than simple message queuing concept. You can broadcast messages to anyone or an unique device which is identified through Bluetooth MAC address.
Concept:

Internal working concept

Bluvert is based on two parts: the message queue utility and the daemon.
message queue utility:
add-message.py takes a defined input file and put this file into the queue.

daemon:
execute-server.py is the core of Bluvert. It takes a defined CSV file which includes the current Bluetooth devices in your neighbourhood. After execution the daemon searches for outstanding messages of any of the Bluetooth devices which are defined in the CSV file.
If an outstanding message is found, the daemon triggers an external script. This script can be send-ussp.sh (uses ussp-push which is the default), send-obexftp.sh (uses obexftp which requires a paired device) or any other tool you want ot use.
The daemon itself is working in threaded mode.

Used technologies

License

Bluvert is licensed under GPLv2.

Author

Bluvert is developed by Christopher Klein <goldenhawk[at]gmx[dot]net>. The project is hosted on sourceforge (http://sourceforge.net/projects/bluvert).

Installation

See INSTALL
Requirements:
	* Python 2.4 or Python 2.5
	* SQLite3 bindings for Python (python-pysqlite1.1):
		$ sudo apt-get install python-pysqlite1.1
	* A working bluetooth environment on your machine (hcitool and sdptool must be installed)
		$ sudo apt-get install bluez-utils
	* obexftp and/or ussp-push
		$ sudo apt-get install obexftp ussp-push

Installation:
	* copy all files to a directory of your choice (e.g. /usr/bin/bluvert), this is your $INSTALL_DIR
		$ cp * $INSTALL_DIR
		$ cd $INSTALL_DIR
		$ chmod o+x execute-server.py add-message.py script/set-active-bluetooth-devices.sh script/send-ussp.sh script/send-obexftp.sh
	* create a directory for storing your message files, this is your $STORAGE_DIR
		$ mkdir /var/local/bluvert-storage
	  Make sure, that $STORAGE_DIR can be written by add-message.py and read by execute-server.py! 
	* edit your $INSTALL_DIR/config.ini:
		* change "storage_dir" to your $STORAGE_DIR

Testing (active Bluetooth devices):
	* power on Bluetooth on your mobile phone and check Bluetooth is working correctly on your machine.  Be sure your mobile phone is listed in bt-devices.csv
		$ $INSTALL_DIR/script/set-active-bluetooth-devices.sh $INSTALL_DIR/data/bt-devices.csv
		$ cat $INSTALL_DIR/data/bt-devices.csv

Testing (adding a new message to your queue):
	* do
		$ echo "Hello world" >> /tmp/bt.txt
		$ $INSTALL_DIR/add-message.py -r $YOUR_MOBILE_BT_MAC -f /tmp/bt.txt -m

	* Verify that /tmp/bt.txt does not longer exist. 
	* Verify that in $STORAGE_DIR a new file called 1.bt.txt has been created

Testing (executing the daemon):
	* execute $INSTALL_DIR/execute-server.py
	* check the output for failures
	* you should now receive the file 1.bt.txt on your mobile phone

More configuration options:
$INSTALL_DIR/config.ini includes the following options:
	* $cwd will be replaced in all configuration settings with the current working directory
	* [sql.file]: Path to your SQLite3 database. There is no reason why it should be changed
	* [data.current_bluetooth_devices_csv]: Path to comma seperated file with active BT devices. This is equal to the parameter of set-active-bluetooth-devices.sh
	* [data.storage_dir]: Your storage directory
	* [exec.send_command]: This command is executed if an active BT device has outstanding messages. 
	  "$mac" will be internally replaced by target MAC address.
	  "$path_to_file" is the absolute path to the file which has to be sent
	* [exec.bt_search_command]: This command is executed for discovering the active Bluetooth devices in your neighbourhood.
	  "$current_bluetooth_devices_csv" will be internally replaced by [data.current_bluetooth_devices_csv]
	* [threading.sendworker_sleep]: Timespan in seconds between next execution of send worker thread
	* [threading.bt_search_sleep]: Timespan in seconds between next execution of Bluetooth discovery thread

Usage:
execute-server.py:
	* There are no options. All options are taken from $INSTALL_DIR/config.ini

add-message.py:
	* -r|--recipient (optional): MAC address of BT device. If you use "*" the message is sent to every device. If this argument is not given '*' is used as recipient
	* -f|--file  (required): File which has to be sent
	* -e|--expires (optional): This parameter sets a timelimit in seconds for sending files. After this timeout, the message is discarded. 
	  Default is "0" which means "no timeout".
	* -m|--move (optional): The file will be moved instead of being copied. Default is copying mode.

Examples:
	* ./add-message.py -r * -f /tmp/welcome.wav
	  Will send the audio file welcome.wav (-f) to any BT device in your neighbourhood. 
	  There is no timeout so this file is send to any BT device exactly one time. 
	* ./add-message.py /tmp/welcome.wav
	  Same as before
	* ./add-message.py -r 00:11:22:33:44:55 -f /tmp/backup-finished.txt
	  Will send the text file backup-finished.txt exactly one time to Bluetooth adapter 00:11:22:33:44:55
	* ./add-message.py -r 00:11:22:33:44:55 -f /tmp/backup-finished.txt -m
	  Same as before but /tmp/backup-finished.txt will no longer exist.
	* ./add-message.py -r 00:11:22:33:44:55 -f /tmp/pic-of-the-day.jpg -e 86400
	  Will send the JPEG pic-of-the-day.jpg to Bluetooth adapter 00:11:22:33:44:55. After 86400 seconds (24 hours) the message is discarded.