Feat: import sketch

This commit is contained in:
Bertrand Benjamin 2022-08-09 22:15:15 +02:00
parent 8420d694f7
commit eeacfea3e3
2 changed files with 89 additions and 0 deletions

81
esp32_radio.ino Normal file
View File

@ -0,0 +1,81 @@
#include "wifiinfo.h"
#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
Audio audio;
String ssid = WIFI_SSID;
String password = WIFI_PASSWD;
void setup {
Serial.begin(115200);
WiFi.disconnect();
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());
Serial.print("Connexion au reseau ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(1500);
Serial.print(".");
}
WiFi.config(WiFi.localIP(), WiFi.gatewayIP(), WiFi.subnetMask(), IPAddress(192,168,2,1));
Serial.println(".");
Serial.println("WiFi connecte");
Serial.println("Adresse IP: ");
Serial.println(WiFi.localIP());
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(5);
audio.connecttohost("http://icecast.radiofrance.fr/franceinter-midfi.mp3");
}
void loop()
{
audio.loop();
}
void audio_info(const char *info) {
Serial.print("info "); Serial.println(info);
}
void audio_id3data(const char *info) { //id3 metadata
Serial.print("id3data "); Serial.println(info);
}
void audio_eof_mp3(const char *info) { //end of file
Serial.print("eof_mp3 "); Serial.println(info);
}
void audio_showstation(const char *info) {
Serial.print("station "); Serial.println(info);
}
void audio_showstreaminfo(const char *info) {
Serial.print("streaminfo "); Serial.println(info);
}
void audio_showstreamtitle(const char *info) {
Serial.print("streamtitle "); Serial.println(info);
}
void audio_bitrate(const char *info) {
Serial.print("bitrate "); Serial.println(info);
}
void audio_commercial(const char *info) { //duration in sec
Serial.print("commercial "); Serial.println(info);
}
void audio_icyurl(const char *info) { //homepage
Serial.print("icyurl "); Serial.println(info);
}
void audio_lasthost(const char *info) { //stream URL played
Serial.print("lasthost "); Serial.println(info);
}
void audio_eof_speech(const char *info) {
Serial.print("eof_speech "); Serial.println(info);
}

8
wifiinfo.h.sample Normal file
View File

@ -0,0 +1,8 @@
#ifndef CREDENTIALS_H
#define CREDENTIALS_H
// Replace with your actual SSID and password:
#define WIFI_SSID "Your SSID here"
#define WIFI_PASSWD "WLAN AP password here"
#endif