Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixing function names

  • Loading branch information...
commit 2126a652a897c98ea4cdc279a65c0a02318ed76e 1 parent 4b0ac61
@tenderlove authored
Showing with 14 additions and 9 deletions.
  1. +7 −2 lib/nfc.rb
  2. +7 −7 lib/nfc/lib_nfc.rb
View
9 lib/nfc.rb
@@ -42,7 +42,7 @@ def infinite_list_passive= v
def poll_mifare
thing = LibNFC::ISO1443A.new
- LibNFC.nfc_reader_list_passive(
+ LibNFC.nfc_initiator_select_tag(
device.pointer,
LibNFC::IM_ISO14443A_106,
nil,
@@ -52,6 +52,10 @@ def poll_mifare
thing
end
+ def deselect
+ LibNFC.nfc_initiator_deselect_tag(device.pointer)
+ end
+
def find
@mutex.lock
deactivate_field
@@ -60,6 +64,7 @@ def find
self.parity = true
activate_field
tag = poll_mifare
+ deselect
disconnect
@mutex.unlock
yield tag if block_given?
@@ -69,7 +74,7 @@ def find
private
def connect
device = NFC::LibNFC::Device.new(NFC::LibNFC.nfc_connect)
- LibNFC.nfc_reader_init(device.pointer)
+ LibNFC.nfc_initiator_init(device.pointer)
device
end
View
14 lib/nfc/lib_nfc.rb
@@ -7,9 +7,10 @@ class LibNFC
attach_function :nfc_connect, [], :pointer
attach_function :nfc_disconnect, [:pointer], :void
- attach_function :nfc_reader_init, [:pointer], :int
+ attach_function :nfc_initiator_init, [:pointer], :int
+ attach_function :nfc_initiator_deselect_tag, [:pointer], :int
attach_function :nfc_configure, [:pointer, :int, :int], :int
- attach_function :nfc_reader_list_passive, [:pointer, :int, :pointer, :int, :pointer], :int
+ attach_function :nfc_initiator_select_tag, [:pointer, :int, :pointer, :int, :pointer], :int
DCO_HANDLE_CRC = 0x00
DCO_HANDLE_PARITY = 0x01
@@ -19,11 +20,10 @@ class LibNFC
IM_ISO14443A_106 = 0x00
class Device < FFI::Struct
- layout(:name, [:char, 256])
-
- def name
- pointer.read_string
- end
+ layout(
+ :pdc, :pointer,
+ :name, :pointer
+ )
end
class ISO1443A < FFI::Struct
Please sign in to comment.
Something went wrong with that request. Please try again.