void init()
{
Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
Serial.setCallback(onDataCallback);
}
void onDataCallback(Stream& stream, char arrivedChar, unsigned short availableCharsCount)
{
unsigned charReceived = 0;
unsigned numCallback = 0;
bool useRxFlag = true;
Serial.print("Class Delegate Demo Time = ");
Serial.print(micros());
Serial.print(" char = 0x");
Serial.print(String(arrivedChar, HEX)); // char hex code
Serial.print(" available = ");
Serial.println(availableCharsCount);
numCallback++;
if (arrivedChar == '\n') // Lets show data!
{
Serial.println("<New line received>");
while (stream.available())
{
char cur = stream.read();
charReceived++;
Serial.print(cur);
}
Serial.println();
}
}
- How does one know that the function parameters of onDataCallback(Stream& stream, char arrivedChar, unsigned short availableCharsCount) is like that?
- Where are one get the documentation for stream? Is it the same as Arduino stream? Documentation for Arduino stream found https://www.arduino.cc/en/Reference/Stream
- After receiving many characters, availableCharsCount stops at 255. Why can't it go above 255? Where can I find the documentation?
Are there any comprehensive documentation for Serial.setCallback()?