Hello,
I'm creating an RFID card reader with MIT App inventor and ESP32 & RC522 sensor.
Currently, in my app, the DelimiterByte for Bluetooth is set to 0.
And in a timer control I'm testing if Bytes Available To Recieve is greater than 0
In this discussion here in the community guys (@ChrisWard @Patryk_F @ABG ) are saying that this approach is not stable and could cause crashes of the app.
Should I change this? And if yes, what is the DelimiterByte value, I'm pasting here my code from the ESP32 that is sending the string to the Bluetooth if you can check if it is 10 or 13 or something other.
Thanks,
Davor
My ESP32 code is:
/*
* RC522 and ESP32
*/
#include <SPI.h>
#include <MFRC522.h>
#include "BluetoothSerial.h"
#define SS_PIN 5
#define RST_PIN 22
MFRC522 mfrc522(SS_PIN, RST_PIN);
MFRC522::MIFARE_Key key;
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
void setup() {
Serial.begin(9600);
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
//bluetooth name of the reader
SerialBT.begin("RFID Card Reader");
}
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
char str[32] = "";
array_to_string(mfrc522.uid.uidByte, 4, str);
Serial.println(str); //Print the output uid string
SerialBT.println(str);
delay(1000);
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
}
void array_to_string(byte array[], unsigned int len, char buffer[])
{
for (unsigned int i = 0; i < len; i++)
{
if (i == 0)
sprintf(buffer, "%02X", array[i]);
else
sprintf(&buffer[i*3-1], ":%02X", array[i]);
}
}