Tomas Flores
/
bluetooth
EEQWRQEWF
Revision 0:c58c860f51f3, committed 2022-09-27
- Comitter:
- manzi
- Date:
- Tue Sep 27 11:41:12 2022 +0000
- Commit message:
- RENZO BOBI
Changed in this revision
diff -r 000000000000 -r c58c860f51f3 bluetooth.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetooth.cpp Tue Sep 27 11:41:12 2022 +0000 @@ -0,0 +1,149 @@ +#include "bluetooth.h" + +#define startData '$' +#define endData '%' + +Serial pc(USBTX, USBRX); +Serial bt(PTE22, PTE23); + +enum{ + standby = 0, + data, +}; + +char beb1[25] = " ", beb2[25] = " ", beb3[25] = " ", beb4[25] = " ", beb5[25] = " ", beb6[25] = " "; +int auxBL = 0; +char datos[100]; + +char charRecieve = 0; +int i=0, bebidas = 0,aux1=0,aux2=0,aux3=0,aux4=0,aux5=0,aux6=0; + +void bluetooth_RX(void){ + + charRecieve = bt.getc(); + static int state = standby; + switch(state){ + case standby: + if(charRecieve == startData) + { + //pc.printf("Recibe $$\n"); + state = data; + } + break; + case data: + if(charRecieve == endData){ + //pc.printf("Recibe %%\n"); + pc.printf("%s\n",datos); + + state = standby; + auxBL=0; + aux1=0; + aux2=0; + aux3=0; + aux4=0; + aux5=0; + aux6=0; + + for(i=0; i < strlen(datos); i++){ + switch (bebidas){ + case 0: + if(datos[i] == '#'){ + bebidas++; + break; + } + else{ + beb1[aux1++] = datos[i]; + } + break; + case 1: + if(datos[i] == '#'){ + bebidas++; + break; + } + else{ + beb2[aux2++] = datos[i]; + } + break; + case 2: + if(datos[i] == '#'){ + bebidas++; + break; + } + else{ + beb3[aux3++] = datos[i]; + } + break; + case 3: + if(datos[i] == '#'){ + bebidas++; + break; + } + else{ + beb4[aux4++] = datos[i]; + } + break; + case 4: + if(datos[i] == '#'){ + bebidas++; + break; + } + else{ + beb5[aux5++] = datos[i]; + } + break; + case 5: + if(datos[i] == '#'){ + bebidas=0; + state = standby; + + break; + } + else{ + beb6[aux6++] = datos[i]; + + } + break; + } + + } + memset(datos,0,100); + pc.printf("%s\n",beb1); + pc.printf("%s\n",beb2); + pc.printf("%s\n",beb3); + pc.printf("%s\n",beb4); + pc.printf("%s\n",beb5); + pc.printf("%s\n",beb6); + memset(beb1,0,25); + memset(beb2,0,25); + memset(beb3,0,25); + memset(beb4,0,25); + memset(beb5,0,25); + memset(beb6,0,25); + } + else{ + datos[auxBL++] = charRecieve; + } + break; + } +} + +void load_simple_drink(void){ + /* + strcpy(simple_drink_matrix[0], beb1); + strcpy(simple_drink_matrix[1], beb2); + strcpy(simple_drink_matrix[2], beb3); + strcpy(simple_drink_matrix[3], beb4); + strcpy(simple_drink_matrix[4], beb5); + strcpy(simple_drink_matrix[5], beb6); + */ +} +void load_elaborated_drinks(void){ + /* + strcpy(elaborated_drink_matrix[0], Ebeb1); + strcpy(elaborated_drink_matrix[1], Ebeb2); + strcpy(elaborated_drink_matrix[2], Ebeb3); + strcpy(elaborated_drink_matrix[3], Ebeb4); + strcpy(elaborated_drink_matrix[4], Ebeb5); + strcpy(elaborated_drink_matrix[5], Ebeb6); + */ +} \ No newline at end of file
diff -r 000000000000 -r c58c860f51f3 bluetooth.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetooth.h Tue Sep 27 11:41:12 2022 +0000 @@ -0,0 +1,21 @@ +#ifndef BLUETOOTH_H +#define BLUETOOTH_H + +#include "mbed.h" + +extern Serial pc; +extern Serial bt; + + +extern char beb1[25],beb2[25],beb3[25],beb4[25],beb5[25],beb6[25]; +extern int auxBL; +extern char datos[100]; + +extern char charRecieve; +extern int i, bebidas, aux1, aux2, aux3, aux4, aux5, aux6; + +void bluetooth_RX(void); +void load_simple_drinks(void); +void load_elaborated_drinks(void); + +#endif \ No newline at end of file
diff -r 000000000000 -r c58c860f51f3 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Sep 27 11:41:12 2022 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" + +#include "bluetooth.h" + + + +// ANDA JOYA 22/9 + + +int main(void) +{ + // Inicializaciones + pc.baud(9600); + bt.baud(9600); + + pc.printf("Conectado a la PC \n"); + memset(datos,0,100); + while(1) + { + if(bt.readable()) + { + bluetooth_RX(); + //pc.printf("%s",datos); + } + } +} \ No newline at end of file
diff -r 000000000000 -r c58c860f51f3 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Sep 27 11:41:12 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file
diff -r 000000000000 -r c58c860f51f3 tsi_sensor.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsi_sensor.lib Tue Sep 27 11:41:12 2022 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Kojto/code/tsi_sensor/#976904559b5c