diff --git a/yoRadio/src/core/netserver.cpp b/yoRadio/src/core/netserver.cpp index fd11b98..8354926 100644 --- a/yoRadio/src/core/netserver.cpp +++ b/yoRadio/src/core/netserver.cpp @@ -242,14 +242,14 @@ void NetServer::processQueue(){ case STATION: requestOnChange(STATIONNAME, clientId); requestOnChange(ITEM, clientId); break; case STATIONNAME: sprintf (wsbuf, "{\"nameset\": \"%s\"}", config.station.name); break; case ITEM: sprintf (wsbuf, "{\"current\": %d}", config.store.lastStation); break; - case TITLE: sprintf (wsbuf, "{\"meta\": \"%s\"}", config.station.title); if (player.requestToStart) { telnet.info(); player.requestToStart = false; } else { telnet.printf("##CLI.META#: %s\n> ", config.station.title); } break; + case TITLE: sprintf (wsbuf, "{\"meta\": \"%s\"}", config.station.title); telnet.printf("##CLI.META#: %s\n> ", config.station.title); break; case VOLUME: sprintf (wsbuf, "{\"vol\": %d}", config.store.volume); telnet.printf("##CLI.VOL#: %d\n", config.store.volume); break; case NRSSI: sprintf (wsbuf, "{\"rssi\": %d}", rssi); /*rssi = 255;*/ break; case SDPOS: sprintf (wsbuf, "{\"sdpos\": %d,\"sdend\": %d,\"sdtpos\": %d,\"sdtend\": %d}", player.getFilePos(), player.getFileSize(), player.getAudioCurrentTime(), player.getAudioFileDuration()); break; case SDLEN: sprintf (wsbuf, "{\"sdmin\": %d,\"sdmax\": %d}", player.sd_min, player.sd_max); break; case SDSNUFFLE: sprintf (wsbuf, "{\"snuffle\": %d}", config.sdSnuffle); break; case BITRATE: sprintf (wsbuf, "{\"bitrate\": %d}", config.station.bitrate); break; - case MODE: sprintf (wsbuf, "{\"mode\": \"%s\"}", player.status() == PLAYING ? "playing" : "stopped"); break; + case MODE: sprintf (wsbuf, "{\"mode\": \"%s\"}", player.status() == PLAYING ? "playing" : "stopped"); telnet.info(); break; case EQUALIZER: sprintf (wsbuf, "{\"bass\": %d, \"middle\": %d, \"trebble\": %d}", config.store.bass, config.store.middle, config.store.trebble); break; case BALANCE: sprintf (wsbuf, "{\"balance\": %d}", config.store.balance); break; default: break; diff --git a/yoRadio/src/core/network.cpp b/yoRadio/src/core/network.cpp index bcbc596..3098371 100644 --- a/yoRadio/src/core/network.cpp +++ b/yoRadio/src/core/network.cpp @@ -184,7 +184,7 @@ bool getWeather(char *wstr) { const char* host = "api.openweathermap.org"; if (!client.connect(host, 80)) { - Serial.println("## OPENWEATHERMAP ###: connection failed"); + Serial.println("##WEATHER###: connection failed"); return false; } char httpget[250] = {0}; @@ -193,7 +193,7 @@ bool getWeather(char *wstr) { unsigned long timeout = millis(); while (client.available() == 0) { if (millis() - timeout > 2000UL) { - Serial.println("## OPENWEATHERMAP ###: client available timeout !"); + Serial.println("##WEATHER###: client available timeout !"); client.stop(); return false; } @@ -211,13 +211,13 @@ bool getWeather(char *wstr) { if ((millis() - timeout) > 500) { client.stop(); - Serial.println("## OPENWEATHERMAP ###: client read timeout !"); + Serial.println("##WEATHER###: client read timeout !"); return false; } } } if (strstr(line.c_str(), "\"temp\"") == NULL) { - Serial.println("## OPENWEATHERMAP ###: weather not found !"); + Serial.println("##WEATHER###: weather not found !"); return false; } char *tmpe; @@ -227,55 +227,55 @@ bool getWeather(char *wstr) { char desc[120], temp[20], hum[20], press[20], icon[5]; tmps = strstr(cursor, "\"description\":\""); - if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: description not found !"); return false;} + if (tmps == NULL) { Serial.println("##WEATHER###: description not found !"); return false;} tmps += 15; tmpe = strstr(tmps, "\",\""); - if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: description not found !"); return false;} + if (tmpe == NULL) { Serial.println("##WEATHER###: description not found !"); return false;} strlcpy(desc, tmps, tmpe - tmps + 1); cursor = tmpe + 2; // "ясно","icon":"01d"}], tmps = strstr(cursor, "\"icon\":\""); - if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: icon not found !"); return false;} + if (tmps == NULL) { Serial.println("##WEATHER###: icon not found !"); return false;} tmps += 8; tmpe = strstr(tmps, "\"}"); - if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: icon not found !"); return false;} + if (tmpe == NULL) { Serial.println("##WEATHER###: icon not found !"); return false;} strlcpy(icon, tmps, tmpe - tmps + 1); cursor = tmpe + 2; tmps = strstr(cursor, "\"temp\":"); - if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: temp not found !"); return false;} + if (tmps == NULL) { Serial.println("##WEATHER###: temp not found !"); return false;} tmps += 7; tmpe = strstr(tmps, ",\""); - if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: temp not found !"); return false;} + if (tmpe == NULL) { Serial.println("##WEATHER###: temp not found !"); return false;} strlcpy(temp, tmps, tmpe - tmps + 1); cursor = tmpe + 1; float tempf = atof(temp); tmps = strstr(cursor, "\"feels_like\":"); - if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: feels_like not found !"); return false;} + if (tmps == NULL) { Serial.println("##WEATHER###: feels_like not found !"); return false;} tmps += 13; tmpe = strstr(tmps, ",\""); - if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: feels_like not found !"); return false;} + if (tmpe == NULL) { Serial.println("##WEATHER###: feels_like not found !"); return false;} strlcpy(temp, tmps, tmpe - tmps + 1); cursor = tmpe + 2; float tempfl = atof(temp); (void)tempfl; tmps = strstr(cursor, "\"pressure\":"); - if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;} + if (tmps == NULL) { Serial.println("##WEATHER###: pressure not found !"); return false;} tmps += 11; tmpe = strstr(tmps, ",\""); - if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;} + if (tmpe == NULL) { Serial.println("##WEATHER###: pressure not found !"); return false;} strlcpy(press, tmps, tmpe - tmps + 1); cursor = tmpe + 2; int pressi = (float)atoi(press) / 1.333; tmps = strstr(cursor, "humidity\":"); - if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: humidity not found !"); return false;} + if (tmps == NULL) { Serial.println("##WEATHER###: humidity not found !"); return false;} tmps += 10; tmpe = strstr(tmps, ",\""); tmpc = strstr(tmps, "}"); - if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: humidity not found !"); return false;} + if (tmpe == NULL) { Serial.println("##WEATHER###: humidity not found !"); return false;} strlcpy(hum, tmps, tmpe - tmps + (tmpc>tmpe?1:0)); tmps = strstr(cursor, "\"grnd_level\":"); @@ -283,26 +283,26 @@ bool getWeather(char *wstr) { if(grnd_level_pr){ tmps += 13; tmpe = strstr(tmps, ",\""); - if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: grnd_level not found !"); return false;} + if (tmpe == NULL) { Serial.println("##WEATHER###: grnd_level not found !"); return false;} strlcpy(press, tmps, tmpe - tmps + 1); cursor = tmpe + 2; pressi = (float)atoi(press) / 1.333; } tmps = strstr(cursor, "\"speed\":"); - if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: wind speed not found !"); return false;} + if (tmps == NULL) { Serial.println("##WEATHER###: wind speed not found !"); return false;} tmps += 8; tmpe = strstr(tmps, ",\""); - if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: wind speed not found !"); return false;} + if (tmpe == NULL) { Serial.println("##WEATHER###: wind speed not found !"); return false;} strlcpy(temp, tmps, tmpe - tmps + 1); cursor = tmpe + 1; float wind_speed = atof(temp); (void)wind_speed; tmps = strstr(cursor, "\"deg\":"); - if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: wind deg not found !"); return false;} + if (tmps == NULL) { Serial.println("##WEATHER###: wind deg not found !"); return false;} tmps += 6; tmpe = strstr(tmps, ",\""); - if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: wind deg not found !"); return false;} + if (tmpe == NULL) { Serial.println("##WEATHER###: wind deg not found !"); return false;} strlcpy(temp, tmps, tmpe - tmps + 1); cursor = tmpe + 1; int wind_deg = atof(temp)/22.5; @@ -330,7 +330,7 @@ bool getWeather(char *wstr) { nextion.weatherVisible(1); #endif - Serial.printf("## OPENWEATHERMAP ###: description: %s, temp:%.1f C, pressure:%dmmHg, humidity:%s%%\n", desc, tempf, pressi, hum); + Serial.printf("##WEATHER###: description: %s, temp:%.1f C, pressure:%dmmHg, humidity:%s%%\n", desc, tempf, pressi, hum); #ifdef WEATHER_FMT_SHORT sprintf(wstr, weatherFmt, tempf, pressi, hum); #else diff --git a/yoRadio/src/core/options.h b/yoRadio/src/core/options.h index 50da0b5..506dc47 100644 --- a/yoRadio/src/core/options.h +++ b/yoRadio/src/core/options.h @@ -1,7 +1,7 @@ #ifndef options_h #define options_h -#define YOVERSION "0.9.111" +#define YOVERSION "0.9.115" /******************************************************* DO NOT EDIT THIS FILE. diff --git a/yoRadio/src/core/player.cpp b/yoRadio/src/core/player.cpp index 2a67549..c03100b 100644 --- a/yoRadio/src/core/player.cpp +++ b/yoRadio/src/core/player.cpp @@ -57,7 +57,6 @@ void Player::init() { setVolume(0); _status = STOPPED; setOutputPins(false); - requestToStart = true; _volTimer=false; playmutex = xSemaphoreCreateMutex(); randomSeed(analogRead(0)); @@ -76,9 +75,8 @@ void Player::sendCommand(playerRequestParams_t request){ void Player::stopInfo() { config.setSmartStart(0); - telnet.info(); + //telnet.info(); netserver.requestOnChange(MODE, 0); - requestToStart = true; } void Player::setError(const char *e){ @@ -185,7 +183,6 @@ void Player::_play(uint16_t stationId) { config.setSmartStart(1); netserver.requestOnChange(MODE, 0); setOutputPins(true); - requestToStart = true; display.putRequest(PSTART); if (player_on_start_play) player_on_start_play(); }else{ @@ -210,7 +207,6 @@ void Player::browseUrl(){ config.setTitle(""); netserver.requestOnChange(MODE, 0); setOutputPins(true); - requestToStart = true; display.putRequest(PSTART); if (player_on_start_play) player_on_start_play(); }else{ diff --git a/yoRadio/src/core/player.h b/yoRadio/src/core/player.h index 967dd0c..252221d 100644 --- a/yoRadio/src/core/player.h +++ b/yoRadio/src/core/player.h @@ -36,7 +36,6 @@ class Player: public Audio { void _play(uint16_t stationId); void _loadVol(uint8_t volume); public: - bool requestToStart; SemaphoreHandle_t playmutex=NULL; bool lockOutput = true; bool resumeAfterUrl = false; diff --git a/yoRadio/src/core/telnet.cpp b/yoRadio/src/core/telnet.cpp index b2e81a1..8c07cf3 100644 --- a/yoRadio/src/core/telnet.cpp +++ b/yoRadio/src/core/telnet.cpp @@ -125,7 +125,10 @@ void Telnet::printf(const char *format, ...) { } } if (strcmp(buf, "> ") == 0) return; - if(strstr(buf,"\n> ")==NULL) Serial.print(buf); + //if(strstr(buf,"\n> ")==NULL) Serial.print(buf); + char *nl = strstr(buf, "\n> "); + if (nl != NULL) { buf[nl-buf+1] = '\0'; } + Serial.print(buf); } void Telnet::printf(byte id, const char *format, ...) {