diff --git a/uid_voting/uid_voting.ino b/uid_voting/uid_voting.ino index e51e980..dd929bc 100644 --- a/uid_voting/uid_voting.ino +++ b/uid_voting/uid_voting.ino @@ -12,9 +12,14 @@ #include +#include "/home/mike/compile/nfc-voting/uid_voting/uniqueSet.h" + PN532_SPI pn532spi(SPI, 10); PN532 nfc(pn532spi); + + +/* //Testing: unsigned int uniqueSetLen = 3; uint8_t uniqueSet[21] PROGMEM= { @@ -25,6 +30,7 @@ uint8_t uniqueSet[21] PROGMEM= { 0x04, 0x81, 0x78, 0xD2, 0x85, 0x32, 0x80, }; +*/ //Need no more than 500 booleans so just use 64 bytes uint8_t hasVoted[64]; @@ -183,7 +189,7 @@ void loop(void) { Serial.println("Found a card!"); //NTAG203 has 7-byte UID, ignore all others if (uidLength == 7) { - Serial.print(uid[0], HEX);Serial.print(uid[1], HEX);Serial.print(uid[1], HEX);Serial.print(uid[2], HEX);Serial.print(uid[3], HEX);Serial.print(uid[4], HEX);Serial.print(uid[5], HEX);Serial.println(uid[6], HEX); + Serial.print(uid[0], HEX);Serial.print(uid[1], HEX);Serial.print(uid[2], HEX);Serial.print(uid[3], HEX);Serial.print(uid[4], HEX);Serial.print(uid[5], HEX);Serial.println(uid[6], HEX); castBallot(uid); diff --git a/unique-string-gen/generate-uid-test-header.py b/unique-string-gen/generate-uid-test-header.py new file mode 100644 index 0000000..4d78584 --- /dev/null +++ b/unique-string-gen/generate-uid-test-header.py @@ -0,0 +1,43 @@ +########### +# Generate UID Test in C Header File +# +########### + +import string +import random +import pickle + +setSize = 500 +uniqueLen = 7 + +uniqueSet = [] + +print "Generating Set" +while (len(uniqueSet) < setSize): + if len(uniqueSet)%50 == 49: + print str(len(uniqueSet)+1) + " values have been generated" + thisUID = [] + for i in range(7): + thisUID.append(random.choice(range(0xFF))) + if thisUID not in uniqueSet: + print thisUID + uniqueSet.append(thisUID) + +print "Generating PROGMEM array as uniqueSet.h" +with open('uniqueSet.h', 'w') as f: + f.write("//THIS IS FOR TESTING ONLY!!!!!!\n\n") + f.write("unsigned int uniqueSetLen = " + str(setSize) + ";\n\n") + f.write("unsigned char uniqueSet[" + str(setSize)*uniqueLen + "] PROGMEM = {\n") + for i in range(len(uniqueSet)): + outStr = " " + for d in range(6): + outStr += "0x{:02x}".format(uniqueSet[i][d]).upper().replace("X","x") + ", " + + outStr += "0x{:02x}".format(uniqueSet[i][6]).upper().replace("X","x") + if (i == (len(uniqueSet)-1)): + outStr += "\n" + else: + outStr += ",\n" + f.write(outStr) + f.write("};\n") +