Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added the tag class

  • Loading branch information...
commit f6f04cabce3db39160f8f66c07f9031b516097a3 1 parent 2a238c5
@tenderlove authored
Showing with 10 additions and 20 deletions.
  1. +1 −0  ext/nfc/nfc.c
  2. +1 −0  ext/nfc/nfc.h
  3. +8 −20 lib/nfc.rb
View
1  ext/nfc/nfc.c
@@ -7,4 +7,5 @@ void Init_nfc()
cNfc = rb_define_class("NFC", rb_cObject);
init_device();
+ init_iso14443a();
}
View
1  ext/nfc/nfc.h
@@ -7,5 +7,6 @@
extern VALUE cNfc;
#include <nfc_device.h>
+#include <nfc_iso14443a.h>
#endif
View
28 lib/nfc.rb
@@ -1,7 +1,7 @@
require 'singleton'
require 'thread'
-#require 'nfc/lib_nfc'
require 'nfc/nfc'
+require 'nfc/device'
class NFC
VERSION = '1.0.0'
@@ -14,19 +14,19 @@ def initialize
end
def deactivate_field
- LibNFC.nfc_configure device.pointer, LibNFC::DCO_ACTIVATE_FIELD, 0
+ device.configure Device::DCO_ACTIVATE_FIELD, 0
end
def activate_field
- LibNFC.nfc_configure device.pointer, LibNFC::DCO_ACTIVATE_FIELD, 1
+ device.configure Device::DCO_ACTIVATE_FIELD, 1
end
def crc= value
- LibNFC.nfc_configure device.pointer, LibNFC::DCO_HANDLE_CRC, value ? 1 : 0
+ device.configure Device::DCO_HANDLE_CRC, value ? 1 : 0
end
def parity= v
- LibNFC.nfc_configure device.pointer, LibNFC::DCO_HANDLE_PARITY, v ? 1 : 0
+ device.configure Device::DCO_HANDLE_PARITY, v ? 1 : 0
end
def device
@@ -34,27 +34,15 @@ def device
end
def infinite_list_passive= v
- LibNFC.nfc_configure(
- device.pointer,
- LibNFC::DCO_INFINITE_LIST_PASSIVE,
- v ? 1 : 0
- )
+ device.configure Device::DCO_INFINITE_LIST_PASSIVE, v ? 1 : 0
end
def poll_mifare
- thing = LibNFC::ISO1443A.new
- LibNFC.nfc_initiator_select_tag(
- device.pointer,
- LibNFC::IM_ISO14443A_106,
- nil,
- 0,
- thing
- )
- thing
+ device.select Device::IM_ISO14443A_106
end
def deselect
- LibNFC.nfc_initiator_deselect_tag(device.pointer)
+ device.deselect
end
def find
Please sign in to comment.
Something went wrong with that request. Please try again.