Coverage for janitoo.rfid : 98%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
https://github.com/adafruit/Adafruit_Python_PN532/blob/master/examples/mcpi_write.py https://www.itead.cc/blog/to-drive-itead-pn532-nfc-module-with-raspberry-pi
We got almost 64 blocks of 16 bytes on the card. It seems that we could authenticate and read one block at a time.
2 choices :
- we use each block separatly :
rfid[0] : the version rfid[1] : 0 rfid[2] : type rfid[3] : subtype rfid[4] : control rfid[5] : 0 rfid[6:..] : specific
but : - how to know how many tags are available on the card
- we use the first block as a block allocation table :
- type, subtype -> block
We can mix many subtypes (ie admin + access) combining bits
The specific part wil be a token which allow : - to check againt a pki that the token is valid for this card, this type and subtype. - to allow specific thinks : ie when presence is sleeping and watchdog, se should activate presence detector on outiside zone. - """
This file is part of Janitoo.
Janitoo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Janitoo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Janitoo. If not, see <http://www.gnu.org/licenses/>.
"""
0b10000000 : { 'uid' : 'security', 'subtypes' : { 0b10000000 : 'access', 0b01000000 : 'admin', } }, 0b01000000 : { 'uid' : 'learning', 'subtypes' : { 0b10000000 : 'voice', } }, 0b11000000 : { 'uid' : 'presence', 'subtypes' : { 0b10000000 : 'watchdog', 0b01000000 : 'occupied', 0b00100000 : 'sleeping', 0b00010000 : 'hibernate', 0b00001000 : 'vacancy', 0b00000100 : 'simulation', } }, }
""" Try to decode a bytearray in a Janitoo RFID block :returns: A block """
""" Try to decode RFID blocks on an RFID tag """
""" A RFID card version 0 We should allow multiple version format. """
""" """
"""Convert message to a byte array If uograde is True, the message is udpdated to current version. """ return None
"""Import data from a byte array """
"""Extract version from a byte array """
""" An RFID card version 1 """
""" """ 'to_bytes':self._to_bytes_1, 'from_bytes':self._from_bytes_1, }
"""Convert data to a byte array to be stored on rfid card """
"""Control that header is conform to version 1 """
return False
"""Import data from a byte array stored on card """
""" A RFID block This is the interface to be use by developpers """
""" A RFID tag Can contain up to 64 blocks.
The reader and writer callbacks :
def writer(blockid, blockdata):
- should return True if everything isk ok
def reader(blockid):
- return bytesarray or None if no (more) data
"""
""" """
"""Send the tag to the writer """ else:
"""Format the tag for Janitoo if full, erase all blocks """
"""Retrieve tag from reader """ else: |