v0.4.322
This commit is contained in:
@@ -222,6 +222,9 @@ download _http://\<yoradioip\>/data/playlist.csv_ and _http://\<yoradioip\>/data
|
|||||||
**play x** - play station x
|
**play x** - play station x
|
||||||
---
|
---
|
||||||
## Version history
|
## Version history
|
||||||
|
#### v0.4.322
|
||||||
|
- fixed garbage in MQTT payload
|
||||||
|
|
||||||
#### v0.4.320
|
#### v0.4.320
|
||||||
- MQTT support
|
- MQTT support
|
||||||
|
|
||||||
|
|||||||
@@ -67,41 +67,51 @@ void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
|
void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
|
||||||
if (strlen(payload) == 0) return;
|
if (len == 0) return;
|
||||||
if (strcmp(payload, "prev") == 0) {
|
char buf[20];
|
||||||
|
strlcpy(buf, payload, len+1);
|
||||||
|
if (strcmp(buf, "prev") == 0) {
|
||||||
player.prev();
|
player.prev();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(payload, "next") == 0) {
|
if (strcmp(buf, "next") == 0) {
|
||||||
player.next();
|
player.next();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(payload, "toggle") == 0) {
|
if (strcmp(buf, "toggle") == 0) {
|
||||||
player.toggle();
|
player.toggle();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(payload, "stop") == 0) {
|
if (strcmp(buf, "stop") == 0) {
|
||||||
player.mode = STOPPED;
|
player.mode = STOPPED;
|
||||||
telnet.info();
|
telnet.info();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(payload, "start") == 0 || strcmp(payload, "play") == 0) {
|
if (strcmp(buf, "start") == 0 || strcmp(buf, "play") == 0) {
|
||||||
player.play(config.store.lastStation);
|
player.play(config.store.lastStation);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(payload, "boot") == 0 || strcmp(payload, "reboot") == 0) {
|
if (strcmp(buf, "boot") == 0 || strcmp(buf, "reboot") == 0) {
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (strcmp(buf, "volm") == 0) {
|
||||||
|
player.stepVol(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (strcmp(buf, "volp") == 0) {
|
||||||
|
player.stepVol(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int volume;
|
int volume;
|
||||||
if ( sscanf(payload, "vol %d", &volume) == 1) {
|
if ( sscanf(buf, "vol %d", &volume) == 1) {
|
||||||
if (volume < 0) volume = 0;
|
if (volume < 0) volume = 0;
|
||||||
if (volume > 254) volume = 254;
|
if (volume > 254) volume = 254;
|
||||||
player.setVol(volume, false);
|
player.setVol(volume, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint16_t sb;
|
uint16_t sb;
|
||||||
if (sscanf(payload, "play %d", &sb) == 1 ) {
|
if (sscanf(buf, "play %d", &sb) == 1 ) {
|
||||||
if (sb < 1) sb = 1;
|
if (sb < 1) sb = 1;
|
||||||
if (sb >= config.store.countStation) sb = config.store.countStation;
|
if (sb >= config.store.countStation) sb = config.store.countStation;
|
||||||
player.play(sb);
|
player.play(sb);
|
||||||
|
|||||||
46
yoRadio/mqttoptions.h
Normal file
46
yoRadio/mqttoptions.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#include "options.h"
|
||||||
|
|
||||||
|
#define MQTT_HOST "192.168.7.3"
|
||||||
|
#define MQTT_PORT 1883
|
||||||
|
#define MQTT_USER ""
|
||||||
|
#define MQTT_PASS ""
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HWID's:
|
||||||
|
* 0: with yellow-blue SSD1306
|
||||||
|
* 1: white SSD1306 without controls
|
||||||
|
* 2: ST7735 with encoder
|
||||||
|
* 3: Nokia 5110 dev board
|
||||||
|
* 4: VS1053 dev
|
||||||
|
* 5: VS1053 UNO3 Shield
|
||||||
|
*/
|
||||||
|
#if HWID==0
|
||||||
|
#define MQTT_ROOT_TOPIC "yoradio/tv/"
|
||||||
|
#elif HWID==1
|
||||||
|
#define MQTT_ROOT_TOPIC "yoradio/work/"
|
||||||
|
#elif HWID==2
|
||||||
|
#define MQTT_ROOT_TOPIC "yoradio/st7735/"
|
||||||
|
#elif HWID==3
|
||||||
|
#define MQTT_ROOT_TOPIC "yoradio/nokia5110/"
|
||||||
|
#elif HWID==4
|
||||||
|
#define MQTT_ROOT_TOPIC "yoradio/vs1053dev/"
|
||||||
|
#elif HWID==5
|
||||||
|
#define MQTT_ROOT_TOPIC "yoradio/kitchen/"
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
Topics:
|
||||||
|
MQTT_ROOT_TOPIC/command // Commands
|
||||||
|
MQTT_ROOT_TOPIC/status // Player status
|
||||||
|
MQTT_ROOT_TOPIC/playlist // Playlist URL
|
||||||
|
MQTT_ROOT_TOPIC/volume // Current volume
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
prev // prev station
|
||||||
|
next // next station
|
||||||
|
toggle // start/stop playing
|
||||||
|
stop // stop playing
|
||||||
|
start, play // start playing
|
||||||
|
boot, reboot // reboot
|
||||||
|
vol x // set volume
|
||||||
|
play x // play station x
|
||||||
|
*/
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef options_h
|
#ifndef options_h
|
||||||
#define options_h
|
#define options_h
|
||||||
|
|
||||||
#define VERSION "0.4.320"
|
#define VERSION "0.4.322"
|
||||||
|
|
||||||
#if __has_include("myoptions.h")
|
#if __has_include("myoptions.h")
|
||||||
#include "myoptions.h" // <- write your variable values here
|
#include "myoptions.h" // <- write your variable values here
|
||||||
|
|||||||
Reference in New Issue
Block a user