Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding some documentation

  • Loading branch information...
commit fac4e4dfcc2aab5c11c2b339107b845e0234ee34 1 parent 6f5c030
@tenderlove tenderlove authored
Showing with 30 additions and 11 deletions.
  1. +17 −8 README.txt
  2. +7 −1 bin/nfc
  3. +6 −2 lib/nfc/lib_nfc.rb
View
25 README.txt
@@ -1,32 +1,41 @@
-= nfc
+= NFC
-* FIX (url)
+* http://seattlerb.rubyforge.org
== DESCRIPTION:
-FIX (describe your package)
+NFC is a ruby wrapper for the Near Field Communication library. The Near
+Field Communication library works with many USB RFID readers, so this gem
+lets you read RFID tags.
== FEATURES/PROBLEMS:
-* FIX (list of features or problems)
+* Only supports ISO1443A tags (MIFARE) tags right now.
== SYNOPSIS:
- FIX (code sample of usage)
+ require 'nfc'
+
+ # Read your tag and print the info
+ p NFC.instance.find
== REQUIREMENTS:
-* FIX (list of requirements)
+* A USB RFID reader. I'm using the touchatag[http://touchatag.com].
+* ffi
+* libnfc
== INSTALL:
-* FIX (sudo gem install, anything else)
+* First install libnfc[http://libnfc.org/]
+* Make sure libnfc.dylib or libnfc.so is in your library path
+* gem install nfc
== LICENSE:
(The MIT License)
-Copyright (c) 2009 FIX
+Copyright (c) 2009 Aaron Patterson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
8 bin/nfc
@@ -1,3 +1,9 @@
#!/usr/bin/env ruby
-abort "you need to write me"
+require 'rubygems'
+require 'nfc'
+nfc = NFC.instance
+
+puts "Connected to NFC reader: #{nfc.device.name}"
+puts
+p nfc.find
View
8 lib/nfc/lib_nfc.rb
@@ -1,7 +1,7 @@
require 'ffi'
class NFC
- class LibNFC # :nodoc
+ class LibNFC
extend FFI::Library
ffi_lib 'nfc'
@@ -40,8 +40,12 @@ class ISO1443A < FFI::Struct
:abtAts, [:char, 36]
)
+ def uid
+ self[:abtUid].to_a.slice(0, self[:uiUidLen])
+ end
+
def inspect
- uid = sprintf((['%02x'] * self[:uiUidLen]).join(' '), *(self[:abtUid]))
+ uid = sprintf((['%02x'] * self[:uiUidLen]).join(' '), *self.uid)
string_ary =
[ "(NFC) ISO14443A Tag",
Please sign in to comment.
Something went wrong with that request. Please try again.