Class: NFC::ISO14443A

Inherits:
Object
  • Object
show all
Defined in:
lib/nfc/iso14443a.rb,
ext/nfc/nfc_iso14443a.c

Instance Method Summary collapse

Instance Method Details

#atqaObject

Get the atqa



17
18
19
# File 'lib/nfc/iso14443a.rb', line 17

def atqa
  abtAtqa.unpack 'C*'
end

#atsObject

Get the ATS for this tag



11
12
13
# File 'lib/nfc/iso14443a.rb', line 11

def ats
  abtAts.unpack 'C*'
end

#btSakObject

Get the btSak



81
82
83
84
85
86
87
# File 'ext/nfc/nfc_iso14443a.c', line 81

static VALUE btSak(VALUE self)
{
  nfc_target * tag;
  Data_Get_Struct(self, nfc_target, tag);

  return INT2NUM(tag->nti.nai.btSak);
}

#inspectObject

Inspect this tag



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/nfc/iso14443a.rb', line 29

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

#szAtsLenObject

Get the szAtsLen



25
26
27
28
29
30
31
# File 'ext/nfc/nfc_iso14443a.c', line 25

static VALUE szAtsLen(VALUE self)
{
  nfc_target * tag;
  Data_Get_Struct(self, nfc_target, tag);

  return INT2NUM(tag->nti.nai.szAtsLen);
}

#szUidLenObject

Get the szUidLen



11
12
13
14
15
16
17
# File 'ext/nfc/nfc_iso14443a.c', line 11

static VALUE szUidLen(VALUE self)
{
  nfc_target * tag;
  Data_Get_Struct(self, nfc_target, tag);

  return INT2NUM(tag->nti.nai.szUidLen);
}

#to_s(join_string = '') ⇒ Object

Get the UID as a hex string



23
24
25
# File 'lib/nfc/iso14443a.rb', line 23

def to_s join_string = ''
  sprintf((['%02x'] * szUidLen).join(join_string), * uid).upcase
end

#uidObject

Get the unique ID for this tag



5
6
7
# File 'lib/nfc/iso14443a.rb', line 5

def uid
  abtUid.unpack 'C*'
end