pax_global_header00006660000000000000000000000064134244277260014525gustar00rootroot0000000000000052 comment=def6ad1de48b21a57a5b0e70ffc56ce83f8d7dfe ruby-nfc-3.1.2/000077500000000000000000000000001342442772600132555ustar00rootroot00000000000000ruby-nfc-3.1.2/.autotest000066400000000000000000000007401342442772600151270ustar00rootroot00000000000000# -*- ruby -*- require 'autotest/restart' # Autotest.add_hook :initialize do |at| # at.extra_files << "../some/external/dependency.rb" # # at.libs << ":../some/external" # # at.add_exception 'vendor' # # at.add_mapping(/dependency.rb/) do |f, _| # at.files_matching(/test_.*rb$/) # end # # %w(TestA TestB).each do |klass| # at.extra_class_map[klass] = "test/test_misc.rb" # end # end # Autotest.add_hook :run_command do |at| # system "rake build" # end ruby-nfc-3.1.2/CHANGELOG.rdoc000066400000000000000000000005351342442772600154200ustar00rootroot00000000000000=== 2.1.0 / 2011-05-27 * 1 Enhancement * Moved to libnfc version 1.5.x === 2.0.1 / 2009-09-19 * 1 Bugfix * Raising an exception when a reader cannot be found. === 2.0.0 / 2009-08-07 * 2 major enhancements * Switched from FFI to a C backend * Now depends on libnfc 1.2.x === 1.0.0 / 2009-06-01 * 1 major enhancement * Birthday! ruby-nfc-3.1.2/Manifest.txt000066400000000000000000000004631342442772600155670ustar00rootroot00000000000000.autotest CHANGELOG.rdoc Manifest.txt README.rdoc Rakefile bin/nfc ext/nfc/context.c ext/nfc/extconf.rb ext/nfc/nfc.c ext/nfc/nfc.h ext/nfc/nfc_device.c ext/nfc/nfc_felica.c ext/nfc/nfc_iso14443a.c lib/nfc.rb lib/nfc/device.rb lib/nfc/felica.rb lib/nfc/iso14443a.rb test/test_context.rb test/test_device.rb ruby-nfc-3.1.2/README.rdoc000066400000000000000000000040161342442772600150640ustar00rootroot00000000000000= NFC * http://seattlerb.rubyforge.org == DESCRIPTION: 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: * Only supports ISO1443A (MIFARE) tags right now. == SYNOPSIS: require 'nfc' # Create a new context ctx = NFC::Context.new # Open the first available USB device dev = ctx.open nil # Block until a tag is available, then print tag info p dev.select # You can even run in an infinite loop if you'd like to continually find # tags: loop do p dev.select end == REQUIREMENTS: * A USB RFID reader. I'm using the touchatag[http://touchatag.com]. * libnfc == INSTALL: First install libnfc[http://libnfc.org/]. I installed libnfc via homebrew: $ brew install libnfc The install the gem: $ sudo gem install nfc NOTE!!!! The nfc gem requires libnfc version 1.7.0 or greater! == LICENSE: (The MIT License) Copyright (c) 2009-2013 Aaron Patterson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ruby-nfc-3.1.2/Rakefile000066400000000000000000000012321342442772600147200ustar00rootroot00000000000000# -*- ruby -*- require 'rubygems' require 'hoe' gem 'rake-compiler', '>= 0.4.1' require "rake/extensiontask" Hoe.plugin :debugging Hoe.plugin :git Hoe.plugin :minitest HOE = Hoe.spec('nfc') do developer('Aaron Patterson', 'aaron@tenderlovemaking.com') self.readme_file = 'README.rdoc' self.history_file = 'CHANGELOG.rdoc' self.extra_rdoc_files = FileList['*.rdoc'] self.spec_extras = { :extensions => ["ext/nfc/extconf.rb"] } end RET = Rake::ExtensionTask.new("nfc", HOE.spec) do |ext| ext.lib_dir = File.join('lib', 'nfc') end task :kill do pid = `sudo launchctl list | grep pcscd`[/^\d+/] `sudo kill #{pid}` if pid end # vim: syntax=Ruby ruby-nfc-3.1.2/bin/000077500000000000000000000000001342442772600140255ustar00rootroot00000000000000ruby-nfc-3.1.2/bin/nfc000077500000000000000000000002401342442772600145150ustar00rootroot00000000000000#!/usr/bin/env ruby require 'rubygems' require 'nfc' nfc = NFC.instance puts "Connected to NFC reader: #{nfc.device.name}" puts nfc.find do |tag| p tag end ruby-nfc-3.1.2/ext/000077500000000000000000000000001342442772600140555ustar00rootroot00000000000000ruby-nfc-3.1.2/ext/nfc/000077500000000000000000000000001342442772600146235ustar00rootroot00000000000000ruby-nfc-3.1.2/ext/nfc/context.c000066400000000000000000000026551342442772600164630ustar00rootroot00000000000000#include static VALUE allocate(VALUE klass) { nfc_context * context; nfc_init(&context); return Data_Wrap_Struct(klass, NULL, nfc_exit, context); } static VALUE open_dev(VALUE self, VALUE name) { nfc_context * ctx; nfc_device * dev; VALUE device; Data_Get_Struct(self, nfc_context, ctx); if (NIL_P(name)) { dev = nfc_open(ctx, NULL); } else { dev = nfc_open(ctx, StringValuePtr(name)); } if (NULL == dev) rb_raise(rb_eRuntimeError, "Unable to open the device"); if(nfc_initiator_init(dev) < 0) rb_raise(rb_eRuntimeError, "Could not initialize device"); device = Data_Wrap_Struct(cNfcDevice, 0, nfc_close, dev); rb_iv_set(device, "@context", self); return device; } static VALUE devices(VALUE self, VALUE len) { nfc_context *ctx; nfc_connstring * strs; size_t found, i; VALUE devs; Data_Get_Struct(self, nfc_context, ctx); strs = malloc(sizeof(nfc_connstring) * len); found = nfc_list_devices(ctx, strs, 10); devs = rb_ary_new2(found); for (i = 0; i < found; i++) { rb_ary_push(devs, rb_str_new2(strs[i])); } free(strs); return devs; } void init_context() { VALUE cContext = rb_define_class_under(mNfc, "Context", rb_cObject); rb_define_alloc_func(cContext, allocate); rb_define_method(cContext, "devices", devices, 1); rb_define_method(cContext, "open", open_dev, 1); } /* vim: set noet sws=4 sw=4: */ ruby-nfc-3.1.2/ext/nfc/extconf.rb000066400000000000000000000005201342442772600166130ustar00rootroot00000000000000# :stopdoc: require 'mkmf' dir_config 'libnfc' pkg_config 'libnfc' unless find_header('nfc/nfc.h') abort "libnfc is missing. please install libnfc: http://libnfc.org/" end unless find_library('nfc', 'nfc_init') abort "libnfc is missing. please install libnfc: http://libnfc.org/" end create_makefile('nfc/nfc') # :startdoc: ruby-nfc-3.1.2/ext/nfc/nfc.c000066400000000000000000000003271342442772600155370ustar00rootroot00000000000000#include VALUE mNfc; void Init_nfc() { mNfc = rb_define_module("NFC"); init_context(); init_device(); init_iso14443a(); /* init_felica(); */ } /* vim: set noet sws=4 sw=4: */ ruby-nfc-3.1.2/ext/nfc/nfc.h000066400000000000000000000004031342442772600155370ustar00rootroot00000000000000#ifndef NFC_H #define NFC_H #include #include extern VALUE mNfc; extern VALUE cNfcISO14443A; extern VALUE cNfcFelica; extern VALUE cNfcDevice; void init_context(); void init_device(); void init_iso14443a(); void init_felica(); #endif ruby-nfc-3.1.2/ext/nfc/nfc_device.c000066400000000000000000000113521342442772600170560ustar00rootroot00000000000000#include #include VALUE cNfcDevice; struct nogvl_ctx { nfc_device *dev; nfc_modulation *mod; nfc_target *ti; }; void * nogvl_select_passive_target(void * ctx) { nfc_device * dev; nfc_modulation * mod; nfc_target * ti; struct nogvl_ctx * myctx = (struct nogvl_ctx *)ctx; dev = myctx->dev; mod = myctx->mod; ti = myctx->ti; return nfc_initiator_select_passive_target(dev, *mod, NULL, 0, ti); } /* * call-seq: * select_passive_target(tag) * * Select the +tag+ type from the device */ static VALUE select_passive_target(VALUE self, VALUE tag) { nfc_device * dev; nfc_modulation * mod; nfc_target * ti; struct nogvl_ctx ctx; Data_Get_Struct(self, nfc_device, dev); Data_Get_Struct(tag, nfc_modulation, mod); ti = (nfc_target *)xmalloc(sizeof(nfc_target)); ctx.dev = dev; ctx.mod = mod; ctx.ti = ti; if (rb_thread_call_without_gvl(nogvl_select_passive_target, &ctx, RUBY_UBF_IO, 0) ) { switch(mod->nmt) { case NMT_ISO14443A: return Data_Wrap_Struct(cNfcISO14443A, 0, xfree, ti); break; case NMT_FELICA: /* return Data_Wrap_Struct(cNfcFelica, 0, free, ti); */ return Qnil; break; default: rb_raise(rb_eRuntimeError, "untested type: %d", mod->nmt); } } else { xfree(ti); } return Qfalse; } /* * call-seq: * poll_target(tag, ms) * * Poll the +tag+ type from the device */ static VALUE poll_target(VALUE self, VALUE tag, VALUE poll_nr, VALUE ms) { nfc_device * dev; nfc_modulation * mod; nfc_target * ti; int code; int ms_c, poll_nr_c; Data_Get_Struct(self, nfc_device, dev); Data_Get_Struct(tag, nfc_modulation, mod); ms_c = FIX2INT(ms); poll_nr_c = FIX2INT(poll_nr); ti = (nfc_target *)xmalloc(sizeof(nfc_target)); code = nfc_initiator_poll_target(dev, mod, 1, poll_nr_c, ms_c, ti); if (code > 0) { switch(mod->nmt) { case NMT_ISO14443A: return Data_Wrap_Struct(cNfcISO14443A, 0, xfree, ti); break; case NMT_FELICA: return Data_Wrap_Struct(cNfcFelica, 0, xfree, ti); break; default: rb_raise(rb_eRuntimeError, "untested type: %d", mod->nmt); } }else { xfree(ti); } return INT2NUM(code); } /* * call-seq: * name * * Get the name of the tag reader */ static VALUE name(VALUE self) { nfc_device * dev; Data_Get_Struct(self, nfc_device, dev); return rb_str_new2(nfc_device_get_name(dev)); } /* * call-seq: * deselect * * Deselect the current tag */ static VALUE dev_deselect(VALUE self) { nfc_device * dev; Data_Get_Struct(self, nfc_device, dev); nfc_initiator_deselect_target(dev); return self; } static VALUE mod_initialize(VALUE self, VALUE type, VALUE baud) { nfc_modulation * mod; Data_Get_Struct(self, nfc_modulation, mod); mod->nmt = NUM2INT(type); mod->nbr = NUM2INT(baud); return self; } static VALUE mod_alloc(VALUE klass) { nfc_modulation * modulation; modulation = xcalloc(1, sizeof(nfc_modulation)); return Data_Wrap_Struct(klass, NULL, xfree, modulation); } static VALUE mod_nmt(VALUE self) { nfc_modulation * mod; Data_Get_Struct(self, nfc_modulation, mod); return INT2NUM(mod->nmt); } static VALUE mod_nbr(VALUE self) { nfc_modulation * mod; Data_Get_Struct(self, nfc_modulation, mod); return INT2NUM(mod->nbr); } static VALUE initiator_init(VALUE self) { nfc_device * dev; int err; Data_Get_Struct(self, nfc_device, dev); err = nfc_initiator_init(dev); if (0 == err) return Qtrue; return INT2NUM(err); } void init_device() { VALUE cNfcModulation; cNfcDevice = rb_define_class_under(mNfc, "Device", rb_cObject); rb_define_method(cNfcDevice, "initiator_init", initiator_init, 0); rb_define_method(cNfcDevice, "select_passive_target", select_passive_target, 1); rb_define_method(cNfcDevice, "poll_target", poll_target, 3); rb_define_method(cNfcDevice, "name", name, 0); rb_define_method(cNfcDevice, "deselect", dev_deselect, 0); cNfcModulation = rb_define_class_under(cNfcDevice, "Modulation", rb_cObject); /* modulation types. */ rb_define_const(cNfcModulation, "NMT_ISO14443A", INT2NUM(NMT_ISO14443A)); rb_define_const(cNfcModulation, "NMT_FELICA", INT2NUM(NMT_FELICA)); /* baud rates */ rb_define_const(cNfcModulation, "NBR_UNDEFINED", INT2NUM(NBR_UNDEFINED)); rb_define_const(cNfcModulation, "NBR_106", INT2NUM(NBR_106)); rb_define_const(cNfcModulation, "NBR_212", INT2NUM(NBR_212)); rb_define_alloc_func(cNfcModulation, mod_alloc); rb_define_method(cNfcModulation, "initialize", mod_initialize, 2); rb_define_method(cNfcModulation, "nmt", mod_nmt, 0); rb_define_method(cNfcModulation, "nbr", mod_nbr, 0); } /* vim: set noet sws=4 sw=4: */ ruby-nfc-3.1.2/ext/nfc/nfc_felica.c000066400000000000000000000023621342442772600170430ustar00rootroot00000000000000#include VALUE cNfcFelica; /* * size_t szLen; * byte_t btResCode; * byte_t abtId[8]; * byte_t abtPad[8]; * byte_t abtSysCode[2]; */ static VALUE szLen(VALUE self) { nfc_felica_info * tag; Data_Get_Struct(self, nfc_felica_info, tag); return INT2NUM(tag->szLen); } static VALUE btResCode(VALUE self) { nfc_felica_info * tag; Data_Get_Struct(self, nfc_felica_info, tag); return INT2NUM(tag->btResCode); } static VALUE abtId(VALUE self) { nfc_felica_info * tag; Data_Get_Struct(self, nfc_felica_info, tag); return rb_str_new(tag->abtId, 8 ); } static VALUE abtPad(VALUE self) { nfc_felica_info * tag; Data_Get_Struct(self, nfc_felica_info, tag); return rb_str_new(tag->abtPad, 8 ); } static VALUE abtSysCode(VALUE self) { nfc_felica_info * tag; Data_Get_Struct(self, nfc_felica_info, tag); return rb_str_new(tag->abtSysCode, 2 ); } void init_felica() { cNfcFelica = rb_define_class_under(mNfc, "Felica", rb_cObject); rb_define_method(cNfcFelica, "szLen", szLen, 0); rb_define_method(cNfcFelica, "btResCode", btResCode, 0); rb_define_method(cNfcFelica, "abtId", abtId, 0); rb_define_private_method(cNfcFelica, "abtPad", abtPad, 0); rb_define_private_method(cNfcFelica, "abtSysCode", abtSysCode, 0); } ruby-nfc-3.1.2/ext/nfc/nfc_iso14443a.c000066400000000000000000000034751342442772600171610ustar00rootroot00000000000000#include VALUE cNfcISO14443A; /* * call-seq: * szUidLen * * Get the szUidLen */ static VALUE szUidLen(VALUE self) { nfc_target * tag; Data_Get_Struct(self, nfc_target, tag); return INT2NUM(tag->nti.nai.szUidLen); } /* * call-seq: * szAtsLen * * Get the szAtsLen */ static VALUE szAtsLen(VALUE self) { nfc_target * tag; Data_Get_Struct(self, nfc_target, tag); return INT2NUM(tag->nti.nai.szAtsLen); } /* * call-seq: * abtUid * * Get the abtUid */ static VALUE abtUid(VALUE self) { nfc_target * tag; Data_Get_Struct(self, nfc_target, tag); return rb_str_new((const char *)tag->nti.nai.abtUid, tag->nti.nai.szUidLen); } /* * call-seq: * abtAts * * Get the abtAts */ static VALUE abtAts(VALUE self) { nfc_target * tag; Data_Get_Struct(self, nfc_target, tag); return rb_str_new((const char *)tag->nti.nai.abtAts, tag->nti.nai.szAtsLen); } /* * call-seq: * abtAtqa * * Get the abtAtqa */ static VALUE abtAtqa(VALUE self) { nfc_target * tag; Data_Get_Struct(self, nfc_target, tag); return rb_str_new((const char *)tag->nti.nai.abtAtqa, 2); } /* * call-seq: * btSak * * Get the btSak */ static VALUE btSak(VALUE self) { nfc_target * tag; Data_Get_Struct(self, nfc_target, tag); return INT2NUM(tag->nti.nai.btSak); } void init_iso14443a() { cNfcISO14443A = rb_define_class_under(mNfc, "ISO14443A", rb_cObject); rb_define_method(cNfcISO14443A, "szUidLen", szUidLen, 0); rb_define_method(cNfcISO14443A, "szAtsLen", szAtsLen, 0); rb_define_method(cNfcISO14443A, "btSak", btSak, 0); rb_define_private_method(cNfcISO14443A, "abtUid", abtUid, 0); rb_define_private_method(cNfcISO14443A, "abtAts", abtAts, 0); rb_define_private_method(cNfcISO14443A, "abtAtqa", abtAtqa, 0); } /* vim: set noet sws=4 sw=4: */ ruby-nfc-3.1.2/lib/000077500000000000000000000000001342442772600140235ustar00rootroot00000000000000ruby-nfc-3.1.2/lib/nfc.rb000066400000000000000000000004121342442772600151130ustar00rootroot00000000000000require 'thread' require 'nfc/nfc' require 'nfc/device' require 'nfc/iso14443a' require 'nfc/felica' ### # NFC is a class for dealing with Near Field Communication systems. This # library will read RFID tags from an RFID reader. module NFC VERSION = '3.1.2' end ruby-nfc-3.1.2/lib/nfc/000077500000000000000000000000001342442772600145715ustar00rootroot00000000000000ruby-nfc-3.1.2/lib/nfc/device.rb000066400000000000000000000010041342442772600163500ustar00rootroot00000000000000module NFC class Device DCO_HANDLE_CRC = 0x00 DCO_HANDLE_PARITY = 0x01 DCO_ACTIVATE_FIELD = 0x10 DCO_INFINITE_LIST_PASSIVE = 0x20 IM_ISO14443A_106 = Modulation.new Modulation::NMT_ISO14443A, Modulation::NBR_106 # Find a tag, blocks until there is a tag available def select select_passive_target NFC::Device::IM_ISO14443A_106 end def poll poll_nr = 1, ms = 1 poll_target NFC::Device::IM_ISO14443A_106, poll_nr,ms end end end ruby-nfc-3.1.2/lib/nfc/felica.rb000066400000000000000000000013371342442772600163450ustar00rootroot00000000000000module NFC class Felica def uid abtId.unpack 'C*' end def pad abtPad.unpack 'C*' end def sys_code abtSysCode.unpack 'C*' end def to_s join_string = '' sprintf((['%02x'] * 8 ).join(join_string), * uid).upcase end def inspect # 78 printf("The following (NFC) Felica tag was found:\n\n"); # 79 printf("%18s","ID (NFCID2): "); print_hex(ti.tif.abtId,8); # 80 printf("%18s","Parameter (PAD): "); print_hex(ti.tif.abtPad,8); pad = sprintf( (['%02x'] * 8 ).join(' '), *self.pad) string_ary = [ "(NFC) Felica Tag", "ID (NFCID2): #{to_s ' '}", "Parameter(PAD): #{pad}" ] string_ary.join "\n" end end end ruby-nfc-3.1.2/lib/nfc/iso14443a.rb000066400000000000000000000015771342442772600164630ustar00rootroot00000000000000module NFC class ISO14443A ### # Get the unique ID for this tag def uid abtUid.unpack 'C*' end ### # Get the ATS for this tag def ats abtAts.unpack 'C*' end ### # Get the atqa def atqa abtAtqa.unpack 'C*' end ### # Get the UID as a hex string def to_s join_string = '' sprintf((['%02x'] * szUidLen).join(join_string), * uid).upcase end ### # Inspect this tag def inspect string_ary = [ "(NFC) ISO14443A Tag", " ATQA (SENS_RES): #{sprintf("%02x %02x", *atqa)}", " UID (NFCID1): #{to_s ' '}", " SAK (SEL_RES): #{sprintf("%02x", btSak)}" ] if szAtsLen > 0 ats = sprintf((['%02x'] * szAtsLen).join(' '), *self.ats) string_ary << " ATS (ATR): #{ats}" end string_ary.join "\n" end end end ruby-nfc-3.1.2/nfc.gemspec000066400000000000000000000046501342442772600153750ustar00rootroot00000000000000######################################################### # This file has been automatically generated by gem2tgz # ######################################################### # -*- encoding: utf-8 -*- # stub: nfc 3.1.2 ruby lib # stub: ext/nfc/extconf.rb Gem::Specification.new do |s| s.name = "nfc".freeze s.version = "3.1.2" s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.require_paths = ["lib".freeze] s.authors = ["Aaron Patterson".freeze] s.date = "2018-10-02" s.description = "NFC is a ruby wrapper for the Near Field Communication library. The Near\nField Communication library works with many USB RFID readers, so this gem\nlets you read RFID tags.".freeze s.email = ["aaron@tenderlovemaking.com".freeze] s.executables = ["nfc".freeze] s.extensions = ["ext/nfc/extconf.rb".freeze] s.extra_rdoc_files = ["CHANGELOG.rdoc".freeze, "Manifest.txt".freeze, "README.rdoc".freeze] s.files = [".autotest".freeze, "CHANGELOG.rdoc".freeze, "Manifest.txt".freeze, "README.rdoc".freeze, "Rakefile".freeze, "bin/nfc".freeze, "ext/nfc/context.c".freeze, "ext/nfc/extconf.rb".freeze, "ext/nfc/nfc.c".freeze, "ext/nfc/nfc.h".freeze, "ext/nfc/nfc_device.c".freeze, "ext/nfc/nfc_felica.c".freeze, "ext/nfc/nfc_iso14443a.c".freeze, "lib/nfc.rb".freeze, "lib/nfc/device.rb".freeze, "lib/nfc/felica.rb".freeze, "lib/nfc/iso14443a.rb".freeze, "test/test_context.rb".freeze, "test/test_device.rb".freeze] s.homepage = "http://seattlerb.rubyforge.org".freeze s.licenses = ["MIT".freeze] s.rdoc_options = ["--main".freeze, "README.rdoc".freeze] s.rubygems_version = "2.5.2.1".freeze s.summary = "NFC is a ruby wrapper for the Near Field Communication library".freeze if s.respond_to? :specification_version then s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_development_dependency(%q.freeze, ["~> 3.17"]) s.add_development_dependency(%q.freeze, ["~> 5.11"]) s.add_development_dependency(%q.freeze, ["< 6", ">= 4.0"]) else s.add_dependency(%q.freeze, ["~> 3.17"]) s.add_dependency(%q.freeze, ["~> 5.11"]) s.add_dependency(%q.freeze, ["< 6", ">= 4.0"]) end else s.add_dependency(%q.freeze, ["~> 3.17"]) s.add_dependency(%q.freeze, ["~> 5.11"]) s.add_dependency(%q.freeze, ["< 6", ">= 4.0"]) end end ruby-nfc-3.1.2/test/000077500000000000000000000000001342442772600142345ustar00rootroot00000000000000ruby-nfc-3.1.2/test/test_context.rb000066400000000000000000000006321342442772600173050ustar00rootroot00000000000000require "minitest/autorun" require "nfc" module NFC class TestContext < Minitest::Test def test_init assert NFC::Context.new end def test_list_devices ctx = NFC::Context.new assert ctx.devices(1) end def test_open ctx = NFC::Context.new devs = ctx.devices(1) skip "no devs attached" unless devs.length > 0 dev = ctx.open nil end end end ruby-nfc-3.1.2/test/test_device.rb000066400000000000000000000005401342442772600170560ustar00rootroot00000000000000require "minitest/autorun" require "nfc" module NFC class TestDevice < Minitest::Test def test_initiator_init ctx = NFC::Context.new devs = ctx.devices(1) skip "no devs attached" unless devs.length > 0 dev = ctx.open nil dev.initiator_init dev.select_passive_target Device::IM_ISO14443A_106 end end end