Skip to content

Commit fbc86be

Browse files
committed
DRAFT
1 parent acfa0ec commit fbc86be

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

examples/examples-communication/serial/mp3-xon-xoff/receive-mp3/receive-mp3.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void setup() {
3535
Serial.begin(115200);
3636
AudioLogger::instance().begin(Serial, AudioLogger::Info);
3737

38-
Serial1.begin(115200);
38+
Serial0.begin(115200);
3939

4040
// set up buffer here to allow PSRAM usage
4141
buffer.resize(1024 * 10); // 10kB buffer

examples/examples-communication/serial/mp3-xon-xoff/send-mp3/send-mp3.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @file send-mp3.ino
44
* @brief Example of sending an mp3 stream over Serial the AudioTools library.
55
* We use xon/xoff to control the flow of the data.
6+
* I am using an ESP32 Dev Module for the test with the pins TX=17 and RX=16.
67
*/
78

89
#include "AudioTools.h"
@@ -19,15 +20,15 @@ void setup() {
1920
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Error);
2021

2122
// setup serial data sink
22-
Serial1.begin(115200);
23+
Serial2.begin(115200);
2324

2425
// mp3 radio
2526
url.begin("http://stream.srg-ssr.ch/m/rsj/mp3_128", "audio/mp3");
2627
}
2728

2829
// Determine if we can send data from the flow control sent by the receiver
29-
bool isAcive() {
30-
char c = Serial1.read();
30+
bool isActive() {
31+
char c = Serial2.read();
3132
switch (c) {
3233
case xon:
3334
is_active = true;

examples/examples-communication/serial/mp3/send-mp3/send-mp3.ino

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
/**
33
* @file send-mp3.ino
4-
* @brief Example of sending an mp3 stream over Serial the AudioTools library.
4+
* @brief ESP32 Example of sending an mp3 stream over Serial the AudioTools library.
55
* The processing must be synchronized with RTS/CTS flow control to prevent a
6-
* buffer overflow and lost data.
7-
* We get the mp3 from an URLStream.
6+
* buffer overflow and lost data. We get the mp3 from an URLStream.
7+
* We used a ESP32 Dev Module for the test.
88
*/
99
#include <HardwareSerial.h>
1010

@@ -15,15 +15,18 @@ URLStream url("ssid", "password"); // or replace with ICYStream to get metadata
1515
HardwareSerial MP3Serial(1); // define a Serial for UART1
1616
StreamCopy copier(MP3Serial, url); // copy url to decoder
1717
// pins
18-
const int MySerialTX = 17;
19-
const int MySerialRX = -1;
20-
const int MySerialRTS = 19;
21-
const int MySerialCTS = -1;
18+
const int MySerialTX = 17; // TX2
19+
const int MySerialRX = -1; // not used
20+
const int MySerialRTS = 4; // GPIO 4
21+
const int MySerialCTS = -1; // not useed
2222

2323
void setup() {
2424
Serial.begin(115200);
2525
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
2626

27+
// improve performance
28+
MP3Serial.setTxBufferSize(1024); // must be called before begin
29+
2730
// setup serial data sink with flow control
2831
MP3Serial.begin(115200, SERIAL_8N1);
2932
MP3Serial.setPins(MySerialRX, MySerialTX, MySerialCTS, MySerialRTS);

0 commit comments

Comments
 (0)