Skip to content

Commit

Permalink
present method added to tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Chechel committed Nov 22, 2015
1 parent 9776f1a commit fc31683
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
15 changes: 15 additions & 0 deletions lib/ruby-nfc/tags/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ def processed?
@target.processed?
end

def present?
modulation = LibNFC::Modulation.new
modulation[:nmt] = :NMT_ISO14443A
modulation[:nbr] = :NBR_106

ptr = FFI::MemoryPointer.new(:char, @target[:nti][:nai][:szUidLen])
ptr.put_bytes(0, uid)

res = LibNFC.nfc_initiator_select_passive_target(@reader.ptr, modulation, ptr,
@target[:nti][:nai][:szUidLen],
FFI::Pointer::NULL)

return res >= 1
end

def disconnect; end

def uid
Expand Down
10 changes: 5 additions & 5 deletions ruby-nfc.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'ruby-nfc'
s.version = '1.1.0'
s.date = '2014-10-01'
s.version = '1.2'
s.date = '2015-11-23'
s.summary = "Provides NFC functionality for Ruby"
s.description = <<-EOF
This gem is built on top of libnfc and libfreefare using ffi and supports:
Expand All @@ -11,7 +11,7 @@ Gem::Specification.new do |s|
EOF

s.authors = ["Maxim Chechel"]
s.email = 'maximchick@gmail.com'
s.email = 'hexdigest@gmail.com'
s.files = [
"./lib/ruby-nfc.rb",
"./lib/ruby-nfc/nfc.rb",
Expand All @@ -28,7 +28,7 @@ Gem::Specification.new do |s|
"./LICENSE"
]

s.homepage = 'https://github.com/maximchick/ruby-nfc'
s.homepage = 'https://github.com/hexdigest/ruby-nfc'
s.license = 'MIT'
s.requirements << 'libnfc, v1.7.x'
s.requirements << 'libfreefare'
Expand All @@ -39,6 +39,6 @@ Gem::Specification.new do |s|
s.post_install_message = <<-EOS
Don't forget to install libnfc and libfreefare
see installation instructions here:
https://github.com/maximchick/ruby-nfc
https://github.com/hexdigest/ruby-nfc
EOS
end

0 comments on commit fc31683

Please sign in to comment.