v0.8.950
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "mqtt.h"
|
||||
|
||||
#ifdef MQTT_HOST
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
#include "WiFi.h"
|
||||
|
||||
#include "telnet.h"
|
||||
@@ -122,6 +122,12 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
||||
player.request.doSave = true;
|
||||
return;
|
||||
}
|
||||
if (strstr(buf, "http")==buf){
|
||||
Serial.println(payload);
|
||||
if(len+1>sizeof(player.burl)) return;
|
||||
strlcpy(player.burl, payload, len+1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ifdef MQTT_HOST
|
||||
#endif // #ifdef MQTT_ROOT_TOPIC
|
||||
|
||||
@@ -30,7 +30,7 @@ void handleHTTPArgs(AsyncWebServerRequest * request);
|
||||
void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len);
|
||||
|
||||
bool shouldReboot = false;
|
||||
#ifdef MQTT_HOST
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
Ticker mqttplaylistticker;
|
||||
bool mqttplaylistblock = false;
|
||||
void mqttplaylistSend() {
|
||||
@@ -231,7 +231,7 @@ void NetServer::processQueue(){
|
||||
}
|
||||
if (strlen(wsbuf) > 0) {
|
||||
if (clientId == 0) { websocket.textAll(wsbuf); }else{ websocket.text(clientId, wsbuf); }
|
||||
#ifdef MQTT_HOST
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
if (clientId == 0 && (request.type == STATION || request.type == ITEM || request.type == TITLE || request.type == MODE)) mqttPublishStatus();
|
||||
if (clientId == 0 && request.type == VOLUME) mqttPublishVolume();
|
||||
#endif
|
||||
@@ -548,7 +548,7 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
|
||||
return;
|
||||
}
|
||||
if (strcmp(cmd, "submitplaylistdone") == 0) {
|
||||
#ifdef MQTT_HOST
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
//mqttPublishPlaylist();
|
||||
mqttplaylistticker.attach(5, mqttplaylistSend);
|
||||
#endif
|
||||
@@ -679,7 +679,7 @@ void handleHTTPArgs(AsyncWebServerRequest * request) {
|
||||
if (request->method() == HTTP_GET) {
|
||||
DBGVB("[%s] client ip=%s request of %s", __func__, request->client()->remoteIP().toString().c_str(), request->url().c_str());
|
||||
if (strcmp(request->url().c_str(), PLAYLIST_PATH) == 0 || strcmp(request->url().c_str(), SSIDS_PATH) == 0 || strcmp(request->url().c_str(), INDEX_PATH) == 0 || strcmp(request->url().c_str(), TMP_PATH) == 0 || strcmp(request->url().c_str(), PLAYLIST_SD_PATH) == 0 || strcmp(request->url().c_str(), INDEX_SD_PATH) == 0) {
|
||||
#ifdef MQTT_HOST
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
if (strcmp(request->url().c_str(), PLAYLIST_PATH) == 0) while (mqttplaylistblock) vTaskDelay(5);
|
||||
#endif
|
||||
if(strcmp(request->url().c_str(), PLAYLIST_PATH) == 0 && config.store.play_mode==PM_SDCARD){
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef options_h
|
||||
#define options_h
|
||||
|
||||
#define YOVERSION "0.8.933"
|
||||
#define YOVERSION "0.8.950"
|
||||
|
||||
/*******************************************************
|
||||
DO NOT EDIT THIS FILE.
|
||||
|
||||
@@ -34,6 +34,9 @@ Player player;
|
||||
|
||||
void Player::init() {
|
||||
Serial.print("##[BOOT]#\tplayer.init\t");
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
memset(burl, 0, 400);
|
||||
#endif
|
||||
if(MUTE_PIN!=255) pinMode(MUTE_PIN, OUTPUT);
|
||||
#if I2S_DOUT!=255
|
||||
#if !I2S_INTERNAL
|
||||
@@ -124,6 +127,11 @@ void Player::loop() {
|
||||
volTimer=false;
|
||||
}
|
||||
}
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
if(strlen(burl)>0){
|
||||
browseUrl();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::zeroRequest() {
|
||||
@@ -165,6 +173,30 @@ void Player::play(uint16_t stationId, uint32_t filePos) {
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
void Player::browseUrl(){
|
||||
resumeAfterUrl = mode==PLAYING;
|
||||
display.putRequest(PSTOP);
|
||||
setDefaults();
|
||||
setOutputPins(false);
|
||||
config.setTitle(const_PlConnect);
|
||||
netserver.requestOnChange(TITLE, 0);
|
||||
if (connecttohost(burl)){
|
||||
mode = PLAYING;
|
||||
config.setTitle("");
|
||||
netserver.requestOnChange(TITLE, 0);
|
||||
netserver.requestOnChange(MODE, 0);
|
||||
setOutputPins(true);
|
||||
requestToStart = true;
|
||||
display.putRequest(PSTART);
|
||||
if (player_on_start_play) player_on_start_play();
|
||||
}else{
|
||||
telnet.printf("##ERROR#:\tError connecting to %s\n", burl);
|
||||
}
|
||||
memset(burl, 0, 400);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Player::prev() {
|
||||
if(config.store.play_mode==PM_WEB || !config.sdSnuffle){
|
||||
if (config.store.lastStation == 1) config.store.lastStation = config.store.countStation; else config.store.lastStation--;
|
||||
|
||||
@@ -27,13 +27,20 @@ class Player: public Audio {
|
||||
void zeroRequest();
|
||||
SemaphoreHandle_t playmutex=NULL;
|
||||
bool lockOutput = true;
|
||||
bool resumeAfterUrl = false;
|
||||
uint32_t sd_min, sd_max;
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
char burl[400]; /* buffer for browseUrl */
|
||||
#endif
|
||||
public:
|
||||
Player();
|
||||
void init();
|
||||
void loop();
|
||||
void initHeaders(const char *file);
|
||||
void play(uint16_t stationId, uint32_t filePos=0);
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
void browseUrl();
|
||||
#endif
|
||||
void stop(const char *nttl = NULL);
|
||||
void prev();
|
||||
void next();
|
||||
|
||||
@@ -52,7 +52,7 @@ void setup() {
|
||||
initControls();
|
||||
display.putRequest(DSP_START);
|
||||
while(!display.ready()) delay(10);
|
||||
#ifdef MQTT_HOST
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
mqttInit();
|
||||
#endif
|
||||
if (config.store.play_mode==PM_SDCARD) player.initHeaders(config.station.url);
|
||||
@@ -87,7 +87,7 @@ void checkConnection(){
|
||||
display.putRequest(NEWMODE, PLAYER);
|
||||
if (playing) player.request.station = config.store.lastStation;
|
||||
checkMillis = millis();
|
||||
#ifdef MQTT_HOST
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
connectToMqtt();
|
||||
#endif
|
||||
}
|
||||
@@ -142,6 +142,9 @@ void audio_showstation(const char *info) {
|
||||
bool p = printable(info);
|
||||
config.setTitle(p?info:config.station.name);
|
||||
netserver.requestOnChange(TITLE, 0);
|
||||
config.setStation(p?info:config.station.name);
|
||||
display.putRequest(NEWSTATION);
|
||||
netserver.requestOnChange(STATION, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +201,7 @@ void audio_id3data(const char *info){ //id3 metadata
|
||||
if(player.lockOutput) return;
|
||||
telnet.printf("##AUDIO.ID3#: %s\n", info);
|
||||
}
|
||||
|
||||
void audio_eof_mp3(const char *info){ //end of file
|
||||
config.sdResumePos = 0;
|
||||
if(config.sdSnuffle){
|
||||
@@ -206,6 +210,17 @@ void audio_eof_mp3(const char *info){ //end of file
|
||||
player.next();
|
||||
}
|
||||
}
|
||||
|
||||
void audio_eof_stream(const char *info){
|
||||
player.stop();
|
||||
if(!player.resumeAfterUrl) return;
|
||||
if (config.store.play_mode==PM_WEB){
|
||||
player.play(config.store.lastStation);
|
||||
}else{
|
||||
player.play(config.store.lastStation, config.sdResumePos==0?0:config.sdResumePos-player.sd_min);
|
||||
}
|
||||
}
|
||||
|
||||
void audio_progress(uint32_t startpos, uint32_t endpos){
|
||||
player.sd_min = startpos;
|
||||
player.sd_max = endpos;
|
||||
|
||||
Reference in New Issue
Block a user