Permalink
Browse files

detecting tags again

  • Loading branch information...
1 parent 67a7e5d commit 97d97ed46c203747c1d84f4e108cfb8f2420ba0c @tenderlove committed May 28, 2011
Showing with 27 additions and 7 deletions.
  1. +23 −3 ext/nfc/nfc_device.c
  2. +1 −1 lib/nfc/device.rb
  3. +3 −3 lib/nfc/iso14443a.rb
View
@@ -67,7 +67,7 @@ static VALUE dev_select(VALUE self, VALUE tag)
nfc_modulation_t * mod;
Data_Get_Struct(self, nfc_device_t, dev);
- Data_Get_Struct(self, nfc_modulation_t, mod);
+ Data_Get_Struct(tag, nfc_modulation_t, mod);
nfc_target_t * ti = calloc(1, sizeof(nfc_target_t));
@@ -132,6 +132,24 @@ static VALUE mod_alloc(VALUE klass)
return Data_Wrap_Struct(klass, NULL, xfree, modulation);
}
+static VALUE mod_nmt(VALUE self)
+{
+ nfc_modulation_t * mod;
+
+ Data_Get_Struct(self, nfc_modulation_t, mod);
+
+ return INT2NUM(mod->nmt);
+}
+
+static VALUE mod_nbr(VALUE self)
+{
+ nfc_modulation_t * mod;
+
+ Data_Get_Struct(self, nfc_modulation_t, mod);
+
+ return INT2NUM(mod->nbr);
+}
+
void init_device()
{
VALUE cNfcDevice = rb_define_class_under(cNfc, "Device", rb_cObject);
@@ -146,8 +164,8 @@ void init_device()
VALUE cNfcModulation = rb_define_class_under(cNfcDevice, "Modulation", rb_cObject);
/* modulation types. */
- rb_define_const(cNfcModulation, "ISO14443A", INT2NUM(NMT_ISO14443A));
- rb_define_const(cNfcModulation, "FELICA", INT2NUM(NMT_FELICA));
+ 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));
@@ -157,4 +175,6 @@ void init_device()
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);
}
View
@@ -5,7 +5,7 @@ class Device
DCO_ACTIVATE_FIELD = 0x10
DCO_INFINITE_LIST_PASSIVE = 0x20
- IM_ISO14443A_106 = Modulation.new Modulation::ISO14443A,
+ IM_ISO14443A_106 = Modulation.new Modulation::NMT_ISO14443A,
Modulation::NBR_106
end
end
View
@@ -21,7 +21,7 @@ def atqa
###
# Get the UID as a hex string
def to_s join_string = ''
- sprintf((['%02x'] * uiUidLen).join(join_string), * uid).upcase
+ sprintf((['%02x'] * szUidLen).join(join_string), * uid).upcase
end
###
@@ -33,8 +33,8 @@ def inspect
" UID (NFCID1): #{to_s ' '}",
" SAK (SEL_RES): #{sprintf("%02x", btSak)}"
]
- if uiAtsLen > 0
- ats = sprintf((['%02x'] * uiAtsLen).join(' '), *self.ats)
+ if szAtsLen > 0
+ ats = sprintf((['%02x'] * szAtsLen).join(' '), *self.ats)
string_ary << " ATS (ATR): #{ats}"
end
string_ary.join "\n"

0 comments on commit 97d97ed

Please sign in to comment.