1
0

Started adding Enroll funktions and ble parsing

This commit is contained in:
Lukas Bachschwell 2015-09-24 23:23:00 +02:00
parent 7e482344d2
commit 9ac2327812
2 changed files with 46 additions and 16 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -21,6 +21,7 @@ char toprint[255];
Beerbox *box;
int drinksMax = 1; // TODO add this to the box struct
int maxID = 0;
int lastButtonState = 1;
int currentDrink = 0;
@ -54,6 +55,9 @@ void setup() {
// RFID Reader init
Serial1.begin(9600);
// BLE Com init
Serial3.begin(115200);
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
@ -79,9 +83,9 @@ void setup() {
lcd.setCursor(0, 1);
lcd.print(box->drinks[0].name);
currentDrink = 0;
box->waiting=false;
box->waiting = false;
}
@ -94,6 +98,31 @@ void loop() {
boxTimer();
if (Serial3.available() > 0) {
char incomingByte = Serial3.read();
if (incomingByte == '!') { //2 createnew user
incomingByte = Serial3.read();
String personName;
while (incomingByte != ';')
{
personName = String(personName + incomingByte);
incomingByte = Serial3.read();
}
Serial.println(personName);
lcd.clear();
lcd.print(personName);
//lcd.setCursor(0,1);
//lcd.print("Fin pls");
//while(getFingerprintEnroll(maxID+1)!=0)
maxID++;
}
}
}//end loop
@ -218,7 +247,7 @@ Person read_person(Beerbox *box, char *filename) {
while (read_line_from_file(read, tmp, sizeof(tmp)), strlen(tmp) > 0) {
int tmpCount = 0;
int tmpDrink = 0;
sscanf(tmp, "drink_Count_%d: %d",&tmpDrink, &tmpCount);
sscanf(tmp, "drink_Count_%d: %d", &tmpDrink, &tmpCount);
if (strlen(tmp)) {
Serial.print("drink: ");
Serial.print(tmpDrink);
@ -245,6 +274,7 @@ void print_person(Beerbox *box, Person *aperson) {
sprintf(toprint, "rfid_uuid: %s\n", aperson->rfid_uuid);
Serial.write(toprint);
sprintf(toprint, "finger_uuid: %u\n", aperson->finger_uuid);
if(aperson->finger_uuid > maxID) maxID=aperson->finger_uuid;
Serial.print(toprint);
sprintf(toprint, "credits_left: %u\n", aperson->credits_left);
Serial.print(toprint);
@ -252,12 +282,12 @@ void print_person(Beerbox *box, Person *aperson) {
for (i = 0; i < drinksMax; i++) {
if (aperson->drinks_taken[i] != -1) {
sprintf(toprint, "\nDrink: %s\n", box->drinks[i].name);
Serial.write(toprint);
sprintf(toprint, "Drink %d: %d\n", i,aperson->drinks_taken[i]);
Serial.write(toprint);
sprintf(toprint, "Total: %d.%02d Euro\n", aperson->drinks_taken[i]*box->drinks[i].price / 100, (aperson->drinks_taken[i]*box->drinks[i].price) % 100);
Serial.write(toprint);
sprintf(toprint, "\nDrink: %s\n", box->drinks[i].name);
Serial.write(toprint);
sprintf(toprint, "Drink %d: %d\n", i, aperson->drinks_taken[i]);
Serial.write(toprint);
sprintf(toprint, "Total: %d.%02d Euro\n", aperson->drinks_taken[i]*box->drinks[i].price / 100, (aperson->drinks_taken[i]*box->drinks[i].price) % 100);
Serial.write(toprint);
}
}
@ -275,7 +305,7 @@ int update_pers_file() {
int i = 0;
//Serial.println(thisPerson.file_name);
write = SD.open(thisPerson.file_name, FILE_WRITE);
if (write == NULL) {
Serial.print("error while reading!\n");
Serial.print("ABORT!\n\n");
@ -283,7 +313,7 @@ int update_pers_file() {
}
write.seek(0);
sprintf(tmp, "%s\n", thisPerson.name);
write.write(tmp, strlen(tmp));
sprintf(tmp, "rfid_uuid: %s\n", thisPerson.rfid_uuid);
@ -369,11 +399,11 @@ Person* readAllPersons () {
}
entry.close();
}
//now store them
Person* readPersons = new Person[personCount];
int counter = 0;
dir.rewindDirectory();
while (true) {
//now store them
Person* readPersons = new Person[personCount];
int counter = 0;
dir.rewindDirectory();
while (true) {
File entry = dir.openNextFile();
if (! entry) {// no more files
break;