/*
Этот код:
Подключается к указанной Wi-Fi сети
Отправляет HTTP-запрос к интернет-радиостанции
Получает и выводит данные потока в серийный порт
*/
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Wokwi-GUEST"; // Замените на название вашей Wi-Fi сети
const char* password = ""; // Замените на пароль от вашей Wi-Fi сети
//const char* radioStationURL = "http://mscp4.live-streams.nl:8140/flac.ogg"; // Замените на URL интернет-радиостанции
//const char* radioStationURL = "https://master.net-radio.fr/frequence3.flac"; // chunked
//const char* radioStationURL = "http://volosatoff.ru:8008/euro.opus"; // Opus chunked
//Сектор радио Progressive
const char* radioStationURL = "http://89.223.45.5:8000/progressive-160"; // Замените на URL интернет-радиостанции
//const char* radioStationURL = "http://stream.lazaradio.com:8100/live.ogg";
//const char* radioStationURL = "https://ice.coldstar.online/low.ogg"; // OOG Verbos chunked
//EL-Stacja
//const char* radioStationURL = "http://radio.el-stacja.pl:8000/elstacjaap.ogg"; // OOG Verbos
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected!");
if (!connectToRadioStation()) {
Serial.println("Failed to connect to radio station");
}
}
void loop() {
// Дальнейшая логика может быть добавлена здесь
}
bool connectToRadioStation() {
HTTPClient http;
Serial.println("Connecting to radio station...");
http.begin(radioStationURL);
int httpCode = http.GET();
if (httpCode > 0) {
Serial.printf("HTTP GET code: %d\n", httpCode);
if (httpCode == HTTP_CODE_OK) {
WiFiClient* stream = http.getStreamPtr();
while (stream->connected() && http.connected()) {
while (stream->available()) {
char c = stream->read();
Serial.print(c);
//Serial.print(c, HEX);
//Serial.print(" ");
}
}
} else {
Serial.printf("Failed to get stream, HTTP code: %d\n", httpCode);
return false;
}
} else {
Serial.printf("HTTP GET request failed, error: %s\n", http.errorToString(httpCode).c_str());
return false;
}
http.end();
return true;
}