Class: Rho::NFCTagTechnology_MifareClassic
- Inherits:
-
NFCTagTechnology
- Object
- NFCTagTechnology
- Rho::NFCTagTechnology_MifareClassic
- Defined in:
- lib/extensions/nfc/nfc.rb
Constant Summary collapse
- KEY_DEFAULT =
[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
- KEY_MIFARE_APPLICATION_DIRECTORY =
[0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5]
- KEY_NFC_FORUM =
[0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7]
- TYPE_CLASSIC =
0
- TYPE_PLUS =
1
- TYPE_PRO =
2
- TYPE_UNKNOWN =
-1
Constants inherited from NFCTagTechnology
Rho::NFCTagTechnology::ISODEP, Rho::NFCTagTechnology::MIFARE_CLASSIC, Rho::NFCTagTechnology::MIFARE_ULTRALIGHT, Rho::NFCTagTechnology::NDEF, Rho::NFCTagTechnology::NDEF_FORMATABLE, Rho::NFCTagTechnology::NFCA, Rho::NFCTagTechnology::NFCB, Rho::NFCTagTechnology::NFCF, Rho::NFCTagTechnology::NFCV
Class Method Summary collapse
-
.convert_type_to_string(type) ⇒ Object
return named type (for known types).
Instance Method Summary collapse
-
#authenticate_sector_with_key_A(index, key) ⇒ Object
authenticate sector with key key is 6 byte array return true if authenticate was passed.
-
#authenticate_sector_with_key_B(index, key) ⇒ Object
authenticate sector with key key is 6 byte array return true if authenticate was passed.
-
#get_block_count ⇒ Object
return number of blocks.
-
#get_blocks_in_sector_count(index) ⇒ Object
return count of blocks in sector.
-
#get_sector_count ⇒ Object
return count of sectors.
-
#get_size ⇒ Object
return size in bytes.
-
#get_type ⇒ Object
return int type type.
-
#initialize ⇒ NFCTagTechnology_MifareClassic
constructor
A new instance of NFCTagTechnology_MifareClassic.
-
#read_block(index) ⇒ Object
index - integer return 16 byte array.
-
#sector_to_block(index) ⇒ Object
return index of first block in sector.
-
#transceive(data) ⇒ Object
send data (byte array) to Tag and receive result - byte array.
-
#write_block(index, block) ⇒ Object
index - integer block - 16 byte array.
Methods inherited from NFCTagTechnology
#close, #connect, #get_name, #is_connected
Constructor Details
#initialize ⇒ NFCTagTechnology_MifareClassic
Returns a new instance of NFCTagTechnology_MifareClassic.
353 354 355 |
# File 'lib/extensions/nfc/nfc.rb', line 353 def initialize super(NFCTagTechnology::MIFARE_CLASSIC) end |
Class Method Details
.convert_type_to_string(type) ⇒ Object
return named type (for known types)
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/extensions/nfc/nfc.rb', line 363 def self.convert_type_to_string(type) res = 'unknown' if type == TYPE_CLASSIC res = 'TYPE_CLASSIC' end if type == TYPE_PLUS res = 'TYPE_PLUS' end if type == TYPE_PRO res = 'TYPE_PRO' end if type == TYPE_UNKNOWN res = 'TYPE_UNKNOWN' end return res end |
Instance Method Details
#authenticate_sector_with_key_A(index, key) ⇒ Object
authenticate sector with key key is 6 byte array return true if authenticate was passed
420 421 422 423 |
# File 'lib/extensions/nfc/nfc.rb', line 420 def authenticate_sector_with_key_A(index, key) r = Nfc.tech_MifareClassic_authenticate_sector_with_key_A(index, key) return r!=0 end |
#authenticate_sector_with_key_B(index, key) ⇒ Object
authenticate sector with key key is 6 byte array return true if authenticate was passed
428 429 430 431 |
# File 'lib/extensions/nfc/nfc.rb', line 428 def authenticate_sector_with_key_B(index, key) r = Nfc.tech_MifareClassic_authenticate_sector_with_key_B(index, key) return r!=0 end |
#get_block_count ⇒ Object
return number of blocks
398 399 400 |
# File 'lib/extensions/nfc/nfc.rb', line 398 def get_block_count return Nfc.tech_MifareClassic_get_block_count end |
#get_blocks_in_sector_count(index) ⇒ Object
return count of blocks in sector
408 409 410 |
# File 'lib/extensions/nfc/nfc.rb', line 408 def get_blocks_in_sector_count(index) return Nfc.tech_MifareClassic_get_blocks_in_sector_count(index) end |
#get_sector_count ⇒ Object
return count of sectors
403 404 405 |
# File 'lib/extensions/nfc/nfc.rb', line 403 def get_sector_count return Nfc.tech_MifareClassic_get_sector_count end |
#get_size ⇒ Object
return size in bytes
393 394 395 |
# File 'lib/extensions/nfc/nfc.rb', line 393 def get_size return Nfc.tech_MifareClassic_get_size end |
#get_type ⇒ Object
return int type type
358 359 360 |
# File 'lib/extensions/nfc/nfc.rb', line 358 def get_type return Nfc.tech_MifareClassic_get_type end |
#read_block(index) ⇒ Object
index - integer return 16 byte array
388 389 390 |
# File 'lib/extensions/nfc/nfc.rb', line 388 def read_block(index) return Nfc.tech_MifareClassic_read_block(index) end |
#sector_to_block(index) ⇒ Object
return index of first block in sector
413 414 415 |
# File 'lib/extensions/nfc/nfc.rb', line 413 def sector_to_block(index) return Nfc.tech_MifareClassic_sector_to_block(index) end |
#transceive(data) ⇒ Object
send data (byte array) to Tag and receive result - byte array
434 435 436 |
# File 'lib/extensions/nfc/nfc.rb', line 434 def transceive(data) return Nfc.tech_MifareClassic_transceive(data) end |
#write_block(index, block) ⇒ Object
index - integer block - 16 byte array
382 383 384 |
# File 'lib/extensions/nfc/nfc.rb', line 382 def write_block(index, block) Nfc.tech_MifareClassic_write_block(index, block) end |