Module: MIFARE::UltralightEV1
- Defined in:
- lib/mifare/ultralight_ev1.rb
Instance Method Summary collapse
- #auth(passwd) ⇒ Object
- #authed? ⇒ Boolean
- #counter_torn?(counter) ⇒ Boolean
- #fast_read(from, to) ⇒ Object
- #increment_counter(counter) ⇒ Object
- #read_counter(counter) ⇒ Object
- #read_signature ⇒ Object
Instance Method Details
#auth(passwd) ⇒ Object
3 4 5 6 7 8 9 10 |
# 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? ⇒ Boolean
12 13 14 |
# File 'lib/mifare/ultralight_ev1.rb', line 12 def authed? @authed || false end |
#counter_torn?(counter) ⇒ Boolean
32 33 34 |
# File 'lib/mifare/ultralight_ev1.rb', line 32 def counter_torn?(counter) transceive([CMD_CHECK_TEARING_EVENT, counter]) != 0xBD end |
#fast_read(from, to) ⇒ Object
16 17 18 19 20 21 22 |
# 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) ⇒ Object
28 29 30 |
# File 'lib/mifare/ultralight_ev1.rb', line 28 def increment_counter(counter) transceive([CMD_INCR_CNT, counter]) end |
#read_counter(counter) ⇒ Object
24 25 26 |
# File 'lib/mifare/ultralight_ev1.rb', line 24 def read_counter(counter) transceive([CMD_READ_CNT, counter]) end |
#read_signature ⇒ Object
36 37 38 |
# File 'lib/mifare/ultralight_ev1.rb', line 36 def read_signature transceive([CMD_READ_SIG, 0x00]) end |