LudovicRousseau / pyscard

pyscard smartcard library for python
http://pyscard.sourceforge.net/
GNU Lesser General Public License v2.1
379 stars 108 forks source link

pyscard in python flask web base #92

Closed BoyAbdullah closed 4 years ago

BoyAbdullah commented 4 years ago

any possible to use pyscard for web base, when i try to connect to NFC device on client site but application always show message NoneType

LudovicRousseau commented 4 years ago

If you can do PC/SC over the web then it should work.

BoyAbdullah commented 4 years ago

work when i try from local base (development site), but on client server base (client site) its not working. i'm using python flask blueprint with wsgi in xampp

maybe you have configuration for client server side like using ip address and port?

for example code:

    @staticmethod
    def nfcSerial():
        serial = None

        cardtype = AnyCardType()

        try:

            cardrequest = CardRequest(timeout=10, cardType=cardtype)
            cardservice = cardrequest.waitforcard()

            observer = ConsoleCardConnectionObserver()
            cardservice.connection.addObserver(observer)

            cardservice.connection.connect()

            chip_beep_mute = "ff00520000"
            chip_beep_unmute = "ff0052ff00"
            apdu = [int(chip_beep_mute[i:i + 2], 16) for i in range(0, len(chip_beep_mute), 2)]
            response, sw1, sw2 = cardservice.connection.transmit(apdu)

            chip_info_serial = "ffca000000"
            apdu = [int(chip_info_serial[i:i + 2], 16) for i in range(0, len(chip_info_serial), 2)]
            response, sw1, sw2 = cardservice.connection.transmit(apdu)
            if sw1 == 0x90:
                serial = toHexString(response)
            else:
                serial = None

            print(serial)
        except CardRequestTimeoutException:
            serial = None
        except:
            serial = None

        return serial
LudovicRousseau commented 4 years ago

I can do consulting if you want. Contact me by email.

BoyAbdullah commented 4 years ago

I can do consulting if you want. Contact me by email.

may i have ur email address sir?

LudovicRousseau commented 4 years ago

Sorry. I thought it was available on my profile. ludovic.rousseau@free.fr

fananimi commented 4 years ago

work when i try from local base (development site), but on client server base (client site) its not working. i'm using python flask blueprint with wsgi in xampp

maybe you have configuration for client server side like using ip address and port?

for example code:

    @staticmethod
    def nfcSerial():
        serial = None

        cardtype = AnyCardType()

        try:

            cardrequest = CardRequest(timeout=10, cardType=cardtype)
            cardservice = cardrequest.waitforcard()

            observer = ConsoleCardConnectionObserver()
            cardservice.connection.addObserver(observer)

            cardservice.connection.connect()

            chip_beep_mute = "ff00520000"
            chip_beep_unmute = "ff0052ff00"
            apdu = [int(chip_beep_mute[i:i + 2], 16) for i in range(0, len(chip_beep_mute), 2)]
            response, sw1, sw2 = cardservice.connection.transmit(apdu)

            chip_info_serial = "ffca000000"
            apdu = [int(chip_info_serial[i:i + 2], 16) for i in range(0, len(chip_info_serial), 2)]
            response, sw1, sw2 = cardservice.connection.transmit(apdu)
            if sw1 == 0x90:
                serial = toHexString(response)
            else:
                serial = None

            print(serial)
        except CardRequestTimeoutException:
            serial = None
        except:
            serial = None

        return serial

@BoyAbdullah

I have experience in web development through dekstop programming like xampp in here https://github.com/fananimi/IotBox-Hack.

And here sample of my pyscard with Qt https://github.com/fananimi/mifare-tools

Don't hesitate , may I can help you.

Thanks.