Dear all
First of all, I don't know where ask my doubt, sorry for any inconvenience.
I have a project in Arduino IDE which works like a charm, but I need use BTstack for send data over bluetooth to a Bluetooth 2.0 device. For me, ESP-IDF programming is new and I don't have much idea how to translate my code from Arduino IDE to c++.
By now, I can send text over bluetooth and read data from serial port UART1 and print in idf.py monitor.
But the other thing I have to do is as follows.
1 - I receive a lot of data from UART1 like
@U0----------------------------------------
WEIGHING TICKET
e: 1 kg TIME:13:22 DATE:09.12.2020
----------------------------------------
GRP:02 G kg PT kg NET kg
WEIGHT: 1084 0 1084
----------------------------------------
For every line is finished by '\n'
In arduino IDE I read every character (CHAR), then stored in string until character CHAR = '\n'
if CHAR = '\n' then i compare which line is read.
If line = 7 then copy this last line read into a new variable and make a substring
This is the code I use
[Codebox]
char recibido = serial.read();
datosin += recibido;
if (recibido == '\n') {
if (linea == 7) {
templinea = datosin;
parsedlinea = templinea.substring (36,40);
peso = parsedlinea
peso.trim();
}
else {
linea++;
datosin="";
if (linea==9) {
datosin ="";
parsedlinea="";
peso = "";
linea = 0;
}
}
}
[/Codebox]
How could do this process with ESP-IDF language?
Thanks in advanced.
Read serial data from UART1 to parsing data after
Who is online
Users browsing this forum: axellin, Kuralmozhi, Vitalii_Bondarenko and 81 guests