Skip to content

Commit ae4e443

Browse files
committed
telnet_info_115
1 parent 864fa4e commit ae4e443

File tree

6 files changed

+30
-32
lines changed

6 files changed

+30
-32
lines changed

yoRadio/src/core/netserver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ void NetServer::processQueue(){
242242
case STATION: requestOnChange(STATIONNAME, clientId); requestOnChange(ITEM, clientId); break;
243243
case STATIONNAME: sprintf (wsbuf, "{\"nameset\": \"%s\"}", config.station.name); break;
244244
case ITEM: sprintf (wsbuf, "{\"current\": %d}", config.store.lastStation); break;
245-
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;
245+
case TITLE: sprintf (wsbuf, "{\"meta\": \"%s\"}", config.station.title); telnet.printf("##CLI.META#: %s\n> ", config.station.title); break;
246246
case VOLUME: sprintf (wsbuf, "{\"vol\": %d}", config.store.volume); telnet.printf("##CLI.VOL#: %d\n", config.store.volume); break;
247247
case NRSSI: sprintf (wsbuf, "{\"rssi\": %d}", rssi); /*rssi = 255;*/ break;
248248
case SDPOS: sprintf (wsbuf, "{\"sdpos\": %d,\"sdend\": %d,\"sdtpos\": %d,\"sdtend\": %d}", player.getFilePos(), player.getFileSize(), player.getAudioCurrentTime(), player.getAudioFileDuration()); break;
249249
case SDLEN: sprintf (wsbuf, "{\"sdmin\": %d,\"sdmax\": %d}", player.sd_min, player.sd_max); break;
250250
case SDSNUFFLE: sprintf (wsbuf, "{\"snuffle\": %d}", config.sdSnuffle); break;
251251
case BITRATE: sprintf (wsbuf, "{\"bitrate\": %d}", config.station.bitrate); break;
252-
case MODE: sprintf (wsbuf, "{\"mode\": \"%s\"}", player.status() == PLAYING ? "playing" : "stopped"); break;
252+
case MODE: sprintf (wsbuf, "{\"mode\": \"%s\"}", player.status() == PLAYING ? "playing" : "stopped"); telnet.info(); break;
253253
case EQUALIZER: sprintf (wsbuf, "{\"bass\": %d, \"middle\": %d, \"trebble\": %d}", config.store.bass, config.store.middle, config.store.trebble); break;
254254
case BALANCE: sprintf (wsbuf, "{\"balance\": %d}", config.store.balance); break;
255255
default: break;

yoRadio/src/core/network.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ bool getWeather(char *wstr) {
184184
const char* host = "api.openweathermap.org";
185185

186186
if (!client.connect(host, 80)) {
187-
Serial.println("## OPENWEATHERMAP ###: connection failed");
187+
Serial.println("##WEATHER###: connection failed");
188188
return false;
189189
}
190190
char httpget[250] = {0};
@@ -193,7 +193,7 @@ bool getWeather(char *wstr) {
193193
unsigned long timeout = millis();
194194
while (client.available() == 0) {
195195
if (millis() - timeout > 2000UL) {
196-
Serial.println("## OPENWEATHERMAP ###: client available timeout !");
196+
Serial.println("##WEATHER###: client available timeout !");
197197
client.stop();
198198
return false;
199199
}
@@ -211,13 +211,13 @@ bool getWeather(char *wstr) {
211211
if ((millis() - timeout) > 500)
212212
{
213213
client.stop();
214-
Serial.println("## OPENWEATHERMAP ###: client read timeout !");
214+
Serial.println("##WEATHER###: client read timeout !");
215215
return false;
216216
}
217217
}
218218
}
219219
if (strstr(line.c_str(), "\"temp\"") == NULL) {
220-
Serial.println("## OPENWEATHERMAP ###: weather not found !");
220+
Serial.println("##WEATHER###: weather not found !");
221221
return false;
222222
}
223223
char *tmpe;
@@ -227,82 +227,82 @@ bool getWeather(char *wstr) {
227227
char desc[120], temp[20], hum[20], press[20], icon[5];
228228

229229
tmps = strstr(cursor, "\"description\":\"");
230-
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: description not found !"); return false;}
230+
if (tmps == NULL) { Serial.println("##WEATHER###: description not found !"); return false;}
231231
tmps += 15;
232232
tmpe = strstr(tmps, "\",\"");
233-
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: description not found !"); return false;}
233+
if (tmpe == NULL) { Serial.println("##WEATHER###: description not found !"); return false;}
234234
strlcpy(desc, tmps, tmpe - tmps + 1);
235235
cursor = tmpe + 2;
236236

237237
// "ясно","icon":"01d"}],
238238
tmps = strstr(cursor, "\"icon\":\"");
239-
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: icon not found !"); return false;}
239+
if (tmps == NULL) { Serial.println("##WEATHER###: icon not found !"); return false;}
240240
tmps += 8;
241241
tmpe = strstr(tmps, "\"}");
242-
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: icon not found !"); return false;}
242+
if (tmpe == NULL) { Serial.println("##WEATHER###: icon not found !"); return false;}
243243
strlcpy(icon, tmps, tmpe - tmps + 1);
244244
cursor = tmpe + 2;
245245

246246
tmps = strstr(cursor, "\"temp\":");
247-
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: temp not found !"); return false;}
247+
if (tmps == NULL) { Serial.println("##WEATHER###: temp not found !"); return false;}
248248
tmps += 7;
249249
tmpe = strstr(tmps, ",\"");
250-
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: temp not found !"); return false;}
250+
if (tmpe == NULL) { Serial.println("##WEATHER###: temp not found !"); return false;}
251251
strlcpy(temp, tmps, tmpe - tmps + 1);
252252
cursor = tmpe + 1;
253253
float tempf = atof(temp);
254254

255255
tmps = strstr(cursor, "\"feels_like\":");
256-
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: feels_like not found !"); return false;}
256+
if (tmps == NULL) { Serial.println("##WEATHER###: feels_like not found !"); return false;}
257257
tmps += 13;
258258
tmpe = strstr(tmps, ",\"");
259-
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: feels_like not found !"); return false;}
259+
if (tmpe == NULL) { Serial.println("##WEATHER###: feels_like not found !"); return false;}
260260
strlcpy(temp, tmps, tmpe - tmps + 1);
261261
cursor = tmpe + 2;
262262
float tempfl = atof(temp); (void)tempfl;
263263

264264
tmps = strstr(cursor, "\"pressure\":");
265-
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;}
265+
if (tmps == NULL) { Serial.println("##WEATHER###: pressure not found !"); return false;}
266266
tmps += 11;
267267
tmpe = strstr(tmps, ",\"");
268-
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;}
268+
if (tmpe == NULL) { Serial.println("##WEATHER###: pressure not found !"); return false;}
269269
strlcpy(press, tmps, tmpe - tmps + 1);
270270
cursor = tmpe + 2;
271271
int pressi = (float)atoi(press) / 1.333;
272272

273273
tmps = strstr(cursor, "humidity\":");
274-
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: humidity not found !"); return false;}
274+
if (tmps == NULL) { Serial.println("##WEATHER###: humidity not found !"); return false;}
275275
tmps += 10;
276276
tmpe = strstr(tmps, ",\"");
277277
tmpc = strstr(tmps, "}");
278-
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: humidity not found !"); return false;}
278+
if (tmpe == NULL) { Serial.println("##WEATHER###: humidity not found !"); return false;}
279279
strlcpy(hum, tmps, tmpe - tmps + (tmpc>tmpe?1:0));
280280

281281
tmps = strstr(cursor, "\"grnd_level\":");
282282
bool grnd_level_pr = (tmps != NULL);
283283
if(grnd_level_pr){
284284
tmps += 13;
285285
tmpe = strstr(tmps, ",\"");
286-
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: grnd_level not found !"); return false;}
286+
if (tmpe == NULL) { Serial.println("##WEATHER###: grnd_level not found !"); return false;}
287287
strlcpy(press, tmps, tmpe - tmps + 1);
288288
cursor = tmpe + 2;
289289
pressi = (float)atoi(press) / 1.333;
290290
}
291291

292292
tmps = strstr(cursor, "\"speed\":");
293-
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: wind speed not found !"); return false;}
293+
if (tmps == NULL) { Serial.println("##WEATHER###: wind speed not found !"); return false;}
294294
tmps += 8;
295295
tmpe = strstr(tmps, ",\"");
296-
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: wind speed not found !"); return false;}
296+
if (tmpe == NULL) { Serial.println("##WEATHER###: wind speed not found !"); return false;}
297297
strlcpy(temp, tmps, tmpe - tmps + 1);
298298
cursor = tmpe + 1;
299299
float wind_speed = atof(temp); (void)wind_speed;
300300

301301
tmps = strstr(cursor, "\"deg\":");
302-
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: wind deg not found !"); return false;}
302+
if (tmps == NULL) { Serial.println("##WEATHER###: wind deg not found !"); return false;}
303303
tmps += 6;
304304
tmpe = strstr(tmps, ",\"");
305-
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: wind deg not found !"); return false;}
305+
if (tmpe == NULL) { Serial.println("##WEATHER###: wind deg not found !"); return false;}
306306
strlcpy(temp, tmps, tmpe - tmps + 1);
307307
cursor = tmpe + 1;
308308
int wind_deg = atof(temp)/22.5;
@@ -330,7 +330,7 @@ bool getWeather(char *wstr) {
330330
nextion.weatherVisible(1);
331331
#endif
332332

333-
Serial.printf("## OPENWEATHERMAP ###: description: %s, temp:%.1f C, pressure:%dmmHg, humidity:%s%%\n", desc, tempf, pressi, hum);
333+
Serial.printf("##WEATHER###: description: %s, temp:%.1f C, pressure:%dmmHg, humidity:%s%%\n", desc, tempf, pressi, hum);
334334
#ifdef WEATHER_FMT_SHORT
335335
sprintf(wstr, weatherFmt, tempf, pressi, hum);
336336
#else

yoRadio/src/core/options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef options_h
22
#define options_h
33

4-
#define YOVERSION "0.9.111"
4+
#define YOVERSION "0.9.115"
55

66
/*******************************************************
77
DO NOT EDIT THIS FILE.

yoRadio/src/core/player.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ void Player::init() {
5757
setVolume(0);
5858
_status = STOPPED;
5959
setOutputPins(false);
60-
requestToStart = true;
6160
_volTimer=false;
6261
playmutex = xSemaphoreCreateMutex();
6362
randomSeed(analogRead(0));
@@ -76,9 +75,8 @@ void Player::sendCommand(playerRequestParams_t request){
7675

7776
void Player::stopInfo() {
7877
config.setSmartStart(0);
79-
telnet.info();
78+
//telnet.info();
8079
netserver.requestOnChange(MODE, 0);
81-
requestToStart = true;
8280
}
8381

8482
void Player::setError(const char *e){
@@ -185,7 +183,6 @@ void Player::_play(uint16_t stationId) {
185183
config.setSmartStart(1);
186184
netserver.requestOnChange(MODE, 0);
187185
setOutputPins(true);
188-
requestToStart = true;
189186
display.putRequest(PSTART);
190187
if (player_on_start_play) player_on_start_play();
191188
}else{
@@ -210,7 +207,6 @@ void Player::browseUrl(){
210207
config.setTitle("");
211208
netserver.requestOnChange(MODE, 0);
212209
setOutputPins(true);
213-
requestToStart = true;
214210
display.putRequest(PSTART);
215211
if (player_on_start_play) player_on_start_play();
216212
}else{

yoRadio/src/core/player.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class Player: public Audio {
3636
void _play(uint16_t stationId);
3737
void _loadVol(uint8_t volume);
3838
public:
39-
bool requestToStart;
4039
SemaphoreHandle_t playmutex=NULL;
4140
bool lockOutput = true;
4241
bool resumeAfterUrl = false;

yoRadio/src/core/telnet.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ void Telnet::printf(const char *format, ...) {
125125
}
126126
}
127127
if (strcmp(buf, "> ") == 0) return;
128-
if(strstr(buf,"\n> ")==NULL) Serial.print(buf);
128+
//if(strstr(buf,"\n> ")==NULL) Serial.print(buf);
129+
char *nl = strstr(buf, "\n> ");
130+
if (nl != NULL) { buf[nl-buf+1] = '\0'; }
131+
Serial.print(buf);
129132
}
130133

131134
void Telnet::printf(byte id, const char *format, ...) {

0 commit comments

Comments
 (0)