-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83767f4
commit f83465d
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
examples/examples-communication/ftp/ftp-client/ftp-client.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* @file ftp-client.ino | ||
* @author Phil Schatzmann | ||
* @brief Receiving audio via FTP and writing to I2S of the AudioKit. | ||
* Replace the userids, passwords and ip adresses with your own! | ||
* @version 0.1 | ||
* @date 2023-11-09 | ||
* | ||
* @copyright Copyright (c) 2023 | ||
*/ | ||
|
||
#include "WiFi.h" | ||
#include "ArduinoFTPClient.h" // install https://github.com/pschatzmann/TinyFTPClient | ||
#include "AudioTools.h" | ||
#include "AudioCodecs/CodecMP3Helix.h" | ||
#include "AudioLibs/AudioKit.h" | ||
|
||
WiFiClient cmd; | ||
WiFiClient data; | ||
FTPClient client(cmd, data); | ||
FTPFile file; | ||
AudioKitStream kit; // or replace with e.g. I2SStream | ||
MP3DecoderHelix mp3; | ||
EncodedAudioStream decoder(&kit, &mp3); | ||
StreamCopy copier(decoder, file); | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
// connect to WIFI | ||
WiFi.begin("network name", "password"); | ||
while (WiFi.status() != WL_CONNECTED) { | ||
delay(500); | ||
Serial.print("."); | ||
} | ||
|
||
// optional logging | ||
FTPLogger::setOutput(Serial); | ||
// FTPLogger::setLogLevel(LOG_DEBUG); | ||
|
||
// open connection | ||
client.begin(IPAddress(192, 168, 1, 10), "user", "password"); | ||
|
||
// copy data from file | ||
file = client.open("/data/music/Neil Young/After the Gold Rush/08 Birds.mp3"); | ||
|
||
// open output device | ||
kit.begin(); | ||
decoder.begin(); | ||
|
||
} | ||
|
||
void loop() { copier.copy(); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters