Skip to content
Snippets Groups Projects
# generic-sender
This is a dummy xAAL device.
It waits for (cbor map) data on a named unix pipe.
Then it sends those data on the xAAL bus via attributes_change notifications.
It also can reply to get_attributes request with the last known data and the associated date.


## Motion
To be hosnest, this small xAAL device was designed to work with [motion][http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome]

Motion is a program that monitors one or many local or remote webcams and detect motions on pictures.
It then can record frames, movies, log events on databases, etc.
Among those functionnalities, it can execute a command when it detects motions.
I propose to use this.

For instance, let's start "motion" and "generic-sender" in parallel.
Le's  `./generic-sender.pipe`  be the named pipe listened by generic-sender
The config file of motion could contain:
    on_event_start     echo '{"motion":"start"}'    | json2cbor.rb > ./generic-sender.pipe
    on_event_end       echo '{"motion":"end"}'      | json2cbor.rb > ./generic-sender.pipe
    on_motion_detected echo '{"motion":"detected"}' | json2cbor.rb > ./generic-sender.pipe

See "motion.conf" for details.

Finally, one get a powerfull xAAL motion sensor without efforts.

Note: In the above example, the json2cbor.rb tool (gem install cbor) is used to pack cbor data from shell-script.


## BlueProximity
Another usercase is to use this small xAAL device in conjuntion with [blueproximity][http://blueproximity.sourceforge.net/]

BlueProximity is a programm designed to detect your bluetooth device (e.g., your smartphone) and lock/unlock your session on your desktop.
This is a "bluetooth smart lock" service. Do not confuse with Bluetooth LE beacon profile.

The idea here is to reuse it. Instead of sending commands to the screensaver to lock/unlock your session, I propose to sends cbor messages to the small xAAL device presented here.
Note: to configure blueproximity, you first need to pair your device and your desktop (without any active connexion).
Then, setup something like this:
    lock_command =      echo '{"proximityDevice":"Nexus6_Christophe", "proximityStatus":"coming"}'  | json2cbor.rb > ./generic-sender.pipe
    unlock_command =    echo '{"proximityDevice":"Nexus6_Christophe", "proximityStatus":"leaving"}' | json2cbor.rb > ./generic-sender.pipe
    proximity_command = echo '{"proximityDevice":"Nexus6_Christophe", "proximityStatus":"present"}' | json2cbor.rb > ./generic-sender.pipe
You also have to tune timers in proximity thresholds (not realy a distance, but in radio signal level)
Then, put your configuration file in $HOME/.blueproximity/xxxx.conf
See `blueproximity_xAAL.conf` for details.