Started adding Enroll funktions and ble parsing
This commit is contained in:
parent
7e482344d2
commit
9ac2327812
36
beerbox.ino
36
beerbox.ino
@ -21,6 +21,7 @@ char toprint[255];
|
|||||||
Beerbox *box;
|
Beerbox *box;
|
||||||
|
|
||||||
int drinksMax = 1; // TODO add this to the box struct
|
int drinksMax = 1; // TODO add this to the box struct
|
||||||
|
int maxID = 0;
|
||||||
int lastButtonState = 1;
|
int lastButtonState = 1;
|
||||||
|
|
||||||
int currentDrink = 0;
|
int currentDrink = 0;
|
||||||
@ -54,6 +55,9 @@ void setup() {
|
|||||||
// RFID Reader init
|
// RFID Reader init
|
||||||
Serial1.begin(9600);
|
Serial1.begin(9600);
|
||||||
|
|
||||||
|
// BLE Com init
|
||||||
|
Serial3.begin(115200);
|
||||||
|
|
||||||
|
|
||||||
Serial.print("Initializing SD card...");
|
Serial.print("Initializing SD card...");
|
||||||
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
|
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
|
||||||
@ -79,7 +83,7 @@ void setup() {
|
|||||||
lcd.setCursor(0, 1);
|
lcd.setCursor(0, 1);
|
||||||
lcd.print(box->drinks[0].name);
|
lcd.print(box->drinks[0].name);
|
||||||
currentDrink = 0;
|
currentDrink = 0;
|
||||||
box->waiting=false;
|
box->waiting = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -94,6 +98,31 @@ void loop() {
|
|||||||
|
|
||||||
boxTimer();
|
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
|
}//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) {
|
while (read_line_from_file(read, tmp, sizeof(tmp)), strlen(tmp) > 0) {
|
||||||
int tmpCount = 0;
|
int tmpCount = 0;
|
||||||
int tmpDrink = 0;
|
int tmpDrink = 0;
|
||||||
sscanf(tmp, "drink_Count_%d: %d",&tmpDrink, &tmpCount);
|
sscanf(tmp, "drink_Count_%d: %d", &tmpDrink, &tmpCount);
|
||||||
if (strlen(tmp)) {
|
if (strlen(tmp)) {
|
||||||
Serial.print("drink: ");
|
Serial.print("drink: ");
|
||||||
Serial.print(tmpDrink);
|
Serial.print(tmpDrink);
|
||||||
@ -245,6 +274,7 @@ void print_person(Beerbox *box, Person *aperson) {
|
|||||||
sprintf(toprint, "rfid_uuid: %s\n", aperson->rfid_uuid);
|
sprintf(toprint, "rfid_uuid: %s\n", aperson->rfid_uuid);
|
||||||
Serial.write(toprint);
|
Serial.write(toprint);
|
||||||
sprintf(toprint, "finger_uuid: %u\n", aperson->finger_uuid);
|
sprintf(toprint, "finger_uuid: %u\n", aperson->finger_uuid);
|
||||||
|
if(aperson->finger_uuid > maxID) maxID=aperson->finger_uuid;
|
||||||
Serial.print(toprint);
|
Serial.print(toprint);
|
||||||
sprintf(toprint, "credits_left: %u\n", aperson->credits_left);
|
sprintf(toprint, "credits_left: %u\n", aperson->credits_left);
|
||||||
Serial.print(toprint);
|
Serial.print(toprint);
|
||||||
@ -254,7 +284,7 @@ void print_person(Beerbox *box, Person *aperson) {
|
|||||||
if (aperson->drinks_taken[i] != -1) {
|
if (aperson->drinks_taken[i] != -1) {
|
||||||
sprintf(toprint, "\nDrink: %s\n", box->drinks[i].name);
|
sprintf(toprint, "\nDrink: %s\n", box->drinks[i].name);
|
||||||
Serial.write(toprint);
|
Serial.write(toprint);
|
||||||
sprintf(toprint, "Drink %d: %d\n", i,aperson->drinks_taken[i]);
|
sprintf(toprint, "Drink %d: %d\n", i, aperson->drinks_taken[i]);
|
||||||
Serial.write(toprint);
|
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);
|
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);
|
Serial.write(toprint);
|
||||||
|
Loading…
Reference in New Issue
Block a user