telnet_info_115
This commit is contained in:
@@ -242,14 +242,14 @@ void NetServer::processQueue(){
|
|||||||
case STATION: requestOnChange(STATIONNAME, clientId); requestOnChange(ITEM, clientId); break;
|
case STATION: requestOnChange(STATIONNAME, clientId); requestOnChange(ITEM, clientId); break;
|
||||||
case STATIONNAME: sprintf (wsbuf, "{\"nameset\": \"%s\"}", config.station.name); break;
|
case STATIONNAME: sprintf (wsbuf, "{\"nameset\": \"%s\"}", config.station.name); break;
|
||||||
case ITEM: sprintf (wsbuf, "{\"current\": %d}", config.store.lastStation); 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 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 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 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 SDLEN: sprintf (wsbuf, "{\"sdmin\": %d,\"sdmax\": %d}", player.sd_min, player.sd_max); break;
|
||||||
case SDSNUFFLE: sprintf (wsbuf, "{\"snuffle\": %d}", config.sdSnuffle); break;
|
case SDSNUFFLE: sprintf (wsbuf, "{\"snuffle\": %d}", config.sdSnuffle); break;
|
||||||
case BITRATE: sprintf (wsbuf, "{\"bitrate\": %d}", config.station.bitrate); 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 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;
|
case BALANCE: sprintf (wsbuf, "{\"balance\": %d}", config.store.balance); break;
|
||||||
default: break;
|
default: break;
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ bool getWeather(char *wstr) {
|
|||||||
const char* host = "api.openweathermap.org";
|
const char* host = "api.openweathermap.org";
|
||||||
|
|
||||||
if (!client.connect(host, 80)) {
|
if (!client.connect(host, 80)) {
|
||||||
Serial.println("## OPENWEATHERMAP ###: connection failed");
|
Serial.println("##WEATHER###: connection failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char httpget[250] = {0};
|
char httpget[250] = {0};
|
||||||
@@ -193,7 +193,7 @@ bool getWeather(char *wstr) {
|
|||||||
unsigned long timeout = millis();
|
unsigned long timeout = millis();
|
||||||
while (client.available() == 0) {
|
while (client.available() == 0) {
|
||||||
if (millis() - timeout > 2000UL) {
|
if (millis() - timeout > 2000UL) {
|
||||||
Serial.println("## OPENWEATHERMAP ###: client available timeout !");
|
Serial.println("##WEATHER###: client available timeout !");
|
||||||
client.stop();
|
client.stop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -211,13 +211,13 @@ bool getWeather(char *wstr) {
|
|||||||
if ((millis() - timeout) > 500)
|
if ((millis() - timeout) > 500)
|
||||||
{
|
{
|
||||||
client.stop();
|
client.stop();
|
||||||
Serial.println("## OPENWEATHERMAP ###: client read timeout !");
|
Serial.println("##WEATHER###: client read timeout !");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strstr(line.c_str(), "\"temp\"") == NULL) {
|
if (strstr(line.c_str(), "\"temp\"") == NULL) {
|
||||||
Serial.println("## OPENWEATHERMAP ###: weather not found !");
|
Serial.println("##WEATHER###: weather not found !");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char *tmpe;
|
char *tmpe;
|
||||||
@@ -227,55 +227,55 @@ bool getWeather(char *wstr) {
|
|||||||
char desc[120], temp[20], hum[20], press[20], icon[5];
|
char desc[120], temp[20], hum[20], press[20], icon[5];
|
||||||
|
|
||||||
tmps = strstr(cursor, "\"description\":\"");
|
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;
|
tmps += 15;
|
||||||
tmpe = strstr(tmps, "\",\"");
|
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);
|
strlcpy(desc, tmps, tmpe - tmps + 1);
|
||||||
cursor = tmpe + 2;
|
cursor = tmpe + 2;
|
||||||
|
|
||||||
// "ясно","icon":"01d"}],
|
// "ясно","icon":"01d"}],
|
||||||
tmps = strstr(cursor, "\"icon\":\"");
|
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;
|
tmps += 8;
|
||||||
tmpe = strstr(tmps, "\"}");
|
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);
|
strlcpy(icon, tmps, tmpe - tmps + 1);
|
||||||
cursor = tmpe + 2;
|
cursor = tmpe + 2;
|
||||||
|
|
||||||
tmps = strstr(cursor, "\"temp\":");
|
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;
|
tmps += 7;
|
||||||
tmpe = strstr(tmps, ",\"");
|
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);
|
strlcpy(temp, tmps, tmpe - tmps + 1);
|
||||||
cursor = tmpe + 1;
|
cursor = tmpe + 1;
|
||||||
float tempf = atof(temp);
|
float tempf = atof(temp);
|
||||||
|
|
||||||
tmps = strstr(cursor, "\"feels_like\":");
|
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;
|
tmps += 13;
|
||||||
tmpe = strstr(tmps, ",\"");
|
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);
|
strlcpy(temp, tmps, tmpe - tmps + 1);
|
||||||
cursor = tmpe + 2;
|
cursor = tmpe + 2;
|
||||||
float tempfl = atof(temp); (void)tempfl;
|
float tempfl = atof(temp); (void)tempfl;
|
||||||
|
|
||||||
tmps = strstr(cursor, "\"pressure\":");
|
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;
|
tmps += 11;
|
||||||
tmpe = strstr(tmps, ",\"");
|
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);
|
strlcpy(press, tmps, tmpe - tmps + 1);
|
||||||
cursor = tmpe + 2;
|
cursor = tmpe + 2;
|
||||||
int pressi = (float)atoi(press) / 1.333;
|
int pressi = (float)atoi(press) / 1.333;
|
||||||
|
|
||||||
tmps = strstr(cursor, "humidity\":");
|
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;
|
tmps += 10;
|
||||||
tmpe = strstr(tmps, ",\"");
|
tmpe = strstr(tmps, ",\"");
|
||||||
tmpc = 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));
|
strlcpy(hum, tmps, tmpe - tmps + (tmpc>tmpe?1:0));
|
||||||
|
|
||||||
tmps = strstr(cursor, "\"grnd_level\":");
|
tmps = strstr(cursor, "\"grnd_level\":");
|
||||||
@@ -283,26 +283,26 @@ bool getWeather(char *wstr) {
|
|||||||
if(grnd_level_pr){
|
if(grnd_level_pr){
|
||||||
tmps += 13;
|
tmps += 13;
|
||||||
tmpe = strstr(tmps, ",\"");
|
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);
|
strlcpy(press, tmps, tmpe - tmps + 1);
|
||||||
cursor = tmpe + 2;
|
cursor = tmpe + 2;
|
||||||
pressi = (float)atoi(press) / 1.333;
|
pressi = (float)atoi(press) / 1.333;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmps = strstr(cursor, "\"speed\":");
|
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;
|
tmps += 8;
|
||||||
tmpe = strstr(tmps, ",\"");
|
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);
|
strlcpy(temp, tmps, tmpe - tmps + 1);
|
||||||
cursor = tmpe + 1;
|
cursor = tmpe + 1;
|
||||||
float wind_speed = atof(temp); (void)wind_speed;
|
float wind_speed = atof(temp); (void)wind_speed;
|
||||||
|
|
||||||
tmps = strstr(cursor, "\"deg\":");
|
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;
|
tmps += 6;
|
||||||
tmpe = strstr(tmps, ",\"");
|
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);
|
strlcpy(temp, tmps, tmpe - tmps + 1);
|
||||||
cursor = tmpe + 1;
|
cursor = tmpe + 1;
|
||||||
int wind_deg = atof(temp)/22.5;
|
int wind_deg = atof(temp)/22.5;
|
||||||
@@ -330,7 +330,7 @@ bool getWeather(char *wstr) {
|
|||||||
nextion.weatherVisible(1);
|
nextion.weatherVisible(1);
|
||||||
#endif
|
#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
|
#ifdef WEATHER_FMT_SHORT
|
||||||
sprintf(wstr, weatherFmt, tempf, pressi, hum);
|
sprintf(wstr, weatherFmt, tempf, pressi, hum);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef options_h
|
#ifndef options_h
|
||||||
#define options_h
|
#define options_h
|
||||||
|
|
||||||
#define YOVERSION "0.9.111"
|
#define YOVERSION "0.9.115"
|
||||||
|
|
||||||
/*******************************************************
|
/*******************************************************
|
||||||
DO NOT EDIT THIS FILE.
|
DO NOT EDIT THIS FILE.
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ void Player::init() {
|
|||||||
setVolume(0);
|
setVolume(0);
|
||||||
_status = STOPPED;
|
_status = STOPPED;
|
||||||
setOutputPins(false);
|
setOutputPins(false);
|
||||||
requestToStart = true;
|
|
||||||
_volTimer=false;
|
_volTimer=false;
|
||||||
playmutex = xSemaphoreCreateMutex();
|
playmutex = xSemaphoreCreateMutex();
|
||||||
randomSeed(analogRead(0));
|
randomSeed(analogRead(0));
|
||||||
@@ -76,9 +75,8 @@ void Player::sendCommand(playerRequestParams_t request){
|
|||||||
|
|
||||||
void Player::stopInfo() {
|
void Player::stopInfo() {
|
||||||
config.setSmartStart(0);
|
config.setSmartStart(0);
|
||||||
telnet.info();
|
//telnet.info();
|
||||||
netserver.requestOnChange(MODE, 0);
|
netserver.requestOnChange(MODE, 0);
|
||||||
requestToStart = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setError(const char *e){
|
void Player::setError(const char *e){
|
||||||
@@ -185,7 +183,6 @@ void Player::_play(uint16_t stationId) {
|
|||||||
config.setSmartStart(1);
|
config.setSmartStart(1);
|
||||||
netserver.requestOnChange(MODE, 0);
|
netserver.requestOnChange(MODE, 0);
|
||||||
setOutputPins(true);
|
setOutputPins(true);
|
||||||
requestToStart = true;
|
|
||||||
display.putRequest(PSTART);
|
display.putRequest(PSTART);
|
||||||
if (player_on_start_play) player_on_start_play();
|
if (player_on_start_play) player_on_start_play();
|
||||||
}else{
|
}else{
|
||||||
@@ -210,7 +207,6 @@ void Player::browseUrl(){
|
|||||||
config.setTitle("");
|
config.setTitle("");
|
||||||
netserver.requestOnChange(MODE, 0);
|
netserver.requestOnChange(MODE, 0);
|
||||||
setOutputPins(true);
|
setOutputPins(true);
|
||||||
requestToStart = true;
|
|
||||||
display.putRequest(PSTART);
|
display.putRequest(PSTART);
|
||||||
if (player_on_start_play) player_on_start_play();
|
if (player_on_start_play) player_on_start_play();
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ class Player: public Audio {
|
|||||||
void _play(uint16_t stationId);
|
void _play(uint16_t stationId);
|
||||||
void _loadVol(uint8_t volume);
|
void _loadVol(uint8_t volume);
|
||||||
public:
|
public:
|
||||||
bool requestToStart;
|
|
||||||
SemaphoreHandle_t playmutex=NULL;
|
SemaphoreHandle_t playmutex=NULL;
|
||||||
bool lockOutput = true;
|
bool lockOutput = true;
|
||||||
bool resumeAfterUrl = false;
|
bool resumeAfterUrl = false;
|
||||||
|
|||||||
@@ -125,7 +125,10 @@ void Telnet::printf(const char *format, ...) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strcmp(buf, "> ") == 0) return;
|
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, ...) {
|
void Telnet::printf(byte id, const char *format, ...) {
|
||||||
|
|||||||
Reference in New Issue
Block a user