NFC triggered playback
#1
Background: My goal is to be able to trigger the playback of music in XBMC via an RFID reader.

I have a collection of RFID cards which I've associated with playlists, I currently have the system working on a separate linux machine which fires JSON API calls to XBMC which I have running on a Raspberry Pi (using XBian). On my dev setup, touching a card to the reader simply sends the card's 10 digit code and the return character to the console. I set up bash aliases to take these inputs and send the appropriate JSON call using curl.

Image

You can find a full explanation of my project here: http://fuzzysprojects.wordpress.com/rfid...red-music/

When a card is read the 10 digits are sent and the return character are picked up in XBMC, to XBMC it appears like it was typed in from a keyboard. I can see it in the logs.

I'm looking for a way to have XBMC interpret this input in such a way as to trigger the playback of a certain playlist.

The other idea is to somehow stop XBMC binding to the device, so I can have a background linux process monitor for input and fire JSON-RPC calls into XBMC to start playback. Is there a way I can stop XBMC picking up the device?

When I SSH into the RPi and try to interact with the RFID reader using evtest I'm informed that "this device is grabbed by another process". So I'm wondering if there is some way that I might be able to stop XBMC from grabbing it?

I'm revisiting a project of mine from a year ago. I posted this thread in a different section of the forums and didn't get any replies. I'd since set up a work around by simply connecting the card reader to another device (an mk802 mini-pc) and having it send json-rpc commands to the XBMC machine. That has worked ok, but I really want to redeploy the mk802 for another project.
Reply
#2
My own research into this has led to reading a lot of info about EVIOCGRAB.

I suspect that if I can fire up a process prior to XBMC launching which makes a EVIOCGRAB grab on the device it could do the trick. I've found examples in python and ruby. I'll have a look into hacking together a bit of python to claim the device and then trigger JSON-RPC calls when it picks up the 10 digit codes.

I'd still love any advice from people who have done anything similar.
Reply
#3
What about simply not granting the xbmc linux user access rights to the device ?

Something with udev rules might work. Check out /etc/udev/rules.d/
Reply
#4
Thanks, I'll give that a shot. If XBMC doesn't get access to it, will it be redirected to a shell back behind the scenes?

How I've been handling it on the mk802 device is to create a bunch of alias's for the 10 digit codes. So when I swipe a card it "types" in the digits followed by a return and fires the bash alias.

Would the same thing work behind the scenes on my XBMC device?

I'll make some time to try it out myself, but I was just wondering if you knew off the top of your head.
Reply
#5
you could do the mapping probably with a python addon and call the addon with your digit codes as parameter via JSONrpc
Reply
#6
I haven't had the chance to give changing the permissions so xbmc can't grab the device, but thinking about it I suspect that this will just result in a heap of failed logins being logged.

(2014-06-06, 09:58)da-anda Wrote: you could do the mapping probably with a python addon and call the addon with your digit codes as parameter via JSONrpc

Would that require that I launch the addon and then swipe a card? If so that is adding a step to a process which I'm trying to keep as simple as possible.

My dream is that I can select a card which is assigned to a playlist, swipe it and it will trigger immediate playback.

Having to pick up my remote and fire up an xbmc plugin and then swiping the card is something I want to avoid.
Reply
#7
no, you don't have to fire up the addon in XBMC first
Reply
#8
A simpler way might be to use a NFC capable smartphone. The NFC apps I have seen for android can sent an http request when you swipe the RFID. The http request could be a JSON-RPC request.

You seem to be doing it hard compared to that!
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#9
See for example the "Using NFC Tags" section on this page http://www.androidauthority.com/how-to-u...-2-164644/
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#10
The way I've gone about it definitely turned out to be more difficult, but it was a lot cheaper.

The RFID cards I bought were around $15 for 50. The reader was $5. Compare that with the sky high price of the NFC tags which are compatible with phones and you'll see why I went down this road.

I still haven't had time to mess with the "getting it all onto the raspberry pi" problem. But hopefully I'll get to dabble with it again soon.
Reply
#11
I finally got a chance to work on this.

I've made some real progress based on the ideas put forward here, thanks guys.

I created a udev rule which stopped XBMC grabbing the device. I've got a python script which grabs the device, listens to the "keypress" events which swiping a card fires works out which playlist is assigned to the card and then fires off a PlayMedia command to XBMC using the python eventclient lib.

I'm working on a way to manage the cards to playlists assigning. As soon as I have it all polished up I'll post up a fuller explanation and a demo.
Reply
#12
Try to get your code up on github if you can so we can all benefit
Reply

Logout Mark Read Team Forum Stats Members Help
NFC triggered playback0