module MIFARE::UltralightEV1

Public Instance Methods

auth(passwd) click to toggle source
# File lib/mifare/ultralight_ev1.rb, line 3
def auth(passwd)
  passwd_bytes = [passwd].pack('H*').bytes
  if passwd_bytes.size != 4
    raise UsageError, "Expect 4 bytes password in hex, got: #{passwd_bytes.size} byte"
  end

  transceive([CMD_PWD_AUTH, *passwd_bytes])
end
authed?() click to toggle source
# File lib/mifare/ultralight_ev1.rb, line 12
def authed?
  @authed || false
end
counter_torn?(counter) click to toggle source
# File lib/mifare/ultralight_ev1.rb, line 32
def counter_torn?(counter)
  transceive([CMD_CHECK_TEARING_EVENT, counter]) != 0xBD
end
fast_read(from, to) click to toggle source
# File lib/mifare/ultralight_ev1.rb, line 16
def fast_read(from, to)
  if (to - from + 1) > @max_range
    raise UsageError, "Reading from #{from} to #{to} exceeds PCD receive buffer"
  end

  transceive([CMD_FAST_READ, from, to])
end
increment_counter(counter) click to toggle source
# File lib/mifare/ultralight_ev1.rb, line 28
def increment_counter(counter)
  transceive([CMD_INCR_CNT, counter])
end
read_counter(counter) click to toggle source
# File lib/mifare/ultralight_ev1.rb, line 24
def read_counter(counter)
  transceive([CMD_READ_CNT, counter])
end
read_signature() click to toggle source
# File lib/mifare/ultralight_ev1.rb, line 36
def read_signature
  transceive([CMD_READ_SIG, 0x00])
end