Esempio n. 1
0
def read():
    ledRedOn()
    cardId = nfc.readNfc()
    beep()
    ledRedOff()
    onScreen(cardId)
    return cardId
Esempio n. 2
0
def main():
    logger.setupLogger()
    logger.info("Starting application")

    db = database.Database()
    db.createConnection()

    try:
        initGpio()
        while True:
            tagId = nfc.readNfc()
            employeeId = db.getEmployeeIdFromTagId(tagId)
            if (employeeId != None):
                logger.info("Employee authorized")
                db.addNewTimestampOfEmployeeId(employeeId)
                blinkLed(GREEN_LED)
                time.sleep(SYS_PAUSE_TIME)
            else:
                logger.info("Employee NOT authorized")
                blinkLed(RED_LED)
                time.sleep(SYS_PAUSE_TIME)

    except KeyboardInterrupt:
        logger.info("Closing application")
        GPIO.cleanup()
        db.closeConnection()
Esempio n. 3
0
def readCard():
    global cardNumber
    print "Thread is running..."
    while(1):
        if (cardNumber == -1):
            cardNumber = nfc.readNfc()
            time.sleep(5)
def main():
    # Initialization..
    print("Reading loop...")
    try:
        #Main loop
        while True:
            print("asking for card")
            uid_read = nfc.readNfc()
            save_rfid_txt(uid_read)
    except KeyboardInterrupt:
        print("ctrl plus c pressed, service down..")
Esempio n. 5
0
def read():
    ledRedOn()
    cardId=nfc.readNfc()
    beep()
    ledRedOff()
    return cardId
Esempio n. 6
0
        lcd1.clear()
        print "0 card - 1 key"
        lcd1.message("0 card - 1 key")

        #wait for the user selection: 0 for card reader - 1 for key a password
        while (ch != '0') and (ch != "1"):

            ch = getch()

        lcd1.clear();
        lcd1.blink();

        if (ch == "0"):
            print "Waiting for card"
            lcd1.message("Waiting for card\n")
            data = nfc.readNfc()
            lcd2.message("Authenticating..\n")
            response = sendPOST(data)
            lcd2.message(response)
            #other actions will follow once you know what to do once the autenthication process suceeded

        if (ch == "1"):
            lcd1.clear()
            lcd1.message("Type password:\n")
            while (ord(ch) != 10):
                ch = getch()
                msg = msg + ch
                lcd1.message("*")
                print msg

            lcd1.noBlink()
Esempio n. 7
0
def read():
    ledRedOn()
    cardId = nfc.readNfc()
    beep()
    ledRedOff()
    return cardId
Esempio n. 8
0
import sys
import tty
import termios
import logging

import thread
import time

import RPi.GPIO as GPIO

def readNfc():
    reading = True
    while reading:
        MIFAREReader = MFRC522.MFRC522()

        while continue_reading:
        	(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)

        if status == MIFAREReader.MI_OK:
        	print("Card detected")

        (status,backData) = MIFAREReader.MFRC522_Anticoll()
        if status == MIFAREReader.MI_OK:
            print ("Card Number: "+str(backData[0])+","+str(backData[1])+","+str(backData[2])+","+str(backData[3])+","+str(backData[4]))
            MIFAREReader.AntennaOff()
            reading=False
            return str(backData[0])+str(backData[1])+str(backData[2])+str(backData[3])+str(backData[4])

tester=nfc.readNfc()
Esempio n. 9
0
def main():
    # Initialization..
    logAndScreen("service init..")
    initGPio()
    display.init()
    try:
        #Main loop
        while True:
            #input readings.
            readLoopInputs()
            #TODO: Check if machine available(active low pin signal.)
            #checkMaytagAvailable()
            #print "luego del chequeo",maytag_available_signal
            #If PASS, then machine is available, and wait until a valid card is passing throug.
            logAndScreen("Machine available, asking for card")
            display.print_lcd_message("passCard")
            uid_read = nfc.readNfc()
            logAndScreen("Card Read: " + uid_read)
            #check Maytag Available when user ask for washing.
            #checkMaytagAvailable()
            if (isMaytagAvailable()):
                logAndScreen("Verifying..")
                display.print_lcd_message("verifying")
                ws_response = httpPostQuery(uid_read, urlFundsQuery)
                response = int(float(ws_response))
                ##Depending on web response..
                if (response == 4):
                    display.print_lcd_message("netwokError")
                    sendWrongBeep()
                    time.sleep(5)
                elif (response == 2):
                    display.print_lcd_message("unasociatedCard")
                    sendWrongBeep()
                    time.sleep(5)
                elif (response == 1):
                    display.print_lcd_message("invalidCard")
                    sendWrongBeep()
                    time.sleep(5)
                elif (response == 3):
                    display.print_lcd_message("noFounds")
                    sendWrongBeep()
                    time.sleep(5)
                elif (response >= 0):  #When founds are enogh
                    display.print_verification_message(response)
                    sendBeep()
                    logAndScreen("Waiting for confirmation..")
                    uuid2 = nfc.readNfcTOut()
                    logAndScreen("UUID2 Read: " + uuid2)
                    if (uuid2 == uid_read):
                        display.print_lcd_message("authorizing")
                        ws_response = httpPostQuery(uid_read, urlWashPayment)
                        response = int(float(ws_response))
                        ##Depending on web response, the results to the machine.
                        if (response == 2):
                            display.print_lcd_message("unasociatedCard")
                            sendWrongBeep()
                            time.sleep(5)
                        elif (response == 4):
                            display.print_lcd_message("networkError")
                            sendWrongBeep()
                            time.sleep(5)
                        elif (response == 1):
                            display.print_lcd_message("invalidCard")
                            sendWrongBeep()
                            time.sleep(5)
                        elif (response == 3):
                            display.print_lcd_message("noFounds")
                            sendWrongBeep()
                            time.sleep(5)
                        elif (response >= 0):
                            sendEnablePulse()
                            display.print_auth_message(response)
                            sendBeep()
                            time.sleep(180)
                        else:
                            display.print_lcd_message("internalError")
                            sendWrongBeep()
                            time.sleep(5)
                else:
                    display.print_lcd_message("internalError")
                    sendWrongBeep()
                    time.sleep(5)
            else:
                #Maytag unavailable
                logAndScreen("Maytag Unavailable")
                display.print_lcd_message("maytagUnavailable")
                sendWrongBeep()
                time.sleep(5)

    except KeyboardInterrupt:
        logAndScreen("ctrl plus c pressed, service down..")
        GPIO.cleanup()

    #except :
    #       logAndScreen("Main loop exception")
    #       GPIO.cleanup()

    GPIO.cleanup()
Esempio n. 10
0
def readNfc(action):
    if(action==55):#7 - Incomming
        onScreen("Logging In...")
        display.lcdWriteFirstLine("Kommen ...")
        display.lcdWriteSecondLine("Karte bitte")
        cardId=nfc.readNfc()
        if cardId:
            logging.info("Incomming - %s",cardId)
            name = mysqlite.insertReading(cardId,Actions.incomming)
            if name=="Unbekannte Karte":
                beep(1)
            else:
                beep(.1)
            display.lcdWriteSecondLine(name)
            time.sleep(2) # Sleep a little, so the information about last action on display is readable by humans
            display.lcdWriteSecondLine("Willkommen")
        else:
            beep(1)
            display.lcdWriteSecondLine("Abgebrochen")
            time.sleep(2) # Sleep a little, so the information about last action on display is readable by humans
            display.lcdWriteSecondLine("Willkommen")

    if(action==57):#9 - outcomming
        onScreen("...")
        display.lcdWriteFirstLine("Gehen ...")
        display.lcdWriteSecondLine("Karte bitte")
        cardId=nfc.readNfc()
        if cardId:
            logging.info("Leaving - %s",cardId)
            name = mysqlite.insertReading(cardId,Actions.outcomming)
            if name=="Unbekannte Karte":
                beep(1)
            else:
                beep(.1)
            display.lcdWriteSecondLine(name)
            time.sleep(2) # Sleep a little, so the information about last action on display is readable by humans
            display.lcdWriteSecondLine("Willkommen")
        else:
            beep(1)
            display.lcdWriteSecondLine("Abgebrochen")
            time.sleep(2) # Sleep a little, so the information about last action on display is readable by humans
            display.lcdWriteSecondLine("Willkommen")

    # I don't use this
    if(action==49):#1 - break start
        onScreen("Zacatek pauzy...")
        display.lcdWriteFirstLine("Pauza zacatek...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId=read()
        logging.info("Break start - %s",cardId)
        name = mysql.insertReading(cardId,Actions.breakstart)
        display.lcdWriteSecondLine(name)
    if(action==51):#3 - break end
        onScreen("Konec pauzy...")
        display.lcdWriteFirstLine("Pauza konec...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId=read()
        logging.info("Break end - %s",cardId)
        name = mysql.insertReading(cardId,Actions.breakend)
        display.lcdWriteSecondLine(name)
    if(action==53):#5 - Deletion of last inserted action
        onScreen("Delete the last entry...")
        display.lcdWriteFirstLine("Deleting...")
        display.lcdWriteSecondLine("")
        cardId=read()
        logging.info("Deleting last action - %s",cardId)
        (lastTime,lastAction)=mysql.getLastReading(cardId) or (None, None)

        if(lastTime == None or lastAction == None):
            display.lcdWriteSecondLine("Unknown Event")
            logging.info("Action not found")
            time.sleep(1)

        else:
            display.lcdWriteFirstLine("Delete Event?")
            if(lastAction==Actions.incomming):
                display.lcdWriteSecondLine("Check In")
            elif(lastAction==Actions.outcomming):
                display.lcdWriteSecondLine("Check Out")
            elif(lastAction==Actions.breakstart):
                display.lcdWriteSecondLine("Pauza zacatek")
            elif(lastAction==Actions.breakend):
                display.lcdWriteSecondLine("End of Pause?")
            a=getOneKey()
            if(a==49):#1
                onScreen("Mazu")
                logging.info(" - Deleting action %s (cas: %s)",lastAction, lastTime)
                mysql.deleteLastReading(cardId)
                display.lcdWriteSecondLine("Deleted!")
            else:
                onScreen("Not Deleted")
                logging.info(" - Deleting canceled")
                display.lcdWriteSecondLine("Not deleted!")
Esempio n. 11
0
def read():
    cardId=nfc.readNfc()
    if cardId:
        onScreen(cardId)
    return cardId
Esempio n. 12
0
def read():
    cardId=nfc.readNfc()
    return cardId
Esempio n. 13
0
def read():
    #ledRedOn()
    cardId=nfc.readNfc()
    #ledRedOff()
    return cardId    
Esempio n. 14
0
def read():
    cardId = nfc.readNfc()
    return cardId