mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 12:37:01 +03:00
LMS can set player's name (only LMS scope) - release
This commit is contained in:
@@ -387,6 +387,7 @@ int set_squeezelite_player_name(FILE * f,const char * name){
|
||||
|
||||
FREE_AND_NULL(nvs_config);
|
||||
FREE_AND_NULL(argv);
|
||||
free(cleaned_name);
|
||||
return nerrors;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "esp_timer.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "monitor.h"
|
||||
#include "platform_config.h"
|
||||
|
||||
mutex_type slimp_mutex;
|
||||
|
||||
@@ -69,3 +70,27 @@ u16_t get_plugged(void) {
|
||||
u8_t get_battery(void) {
|
||||
return (battery_level_svc() * 16) / 100;
|
||||
}
|
||||
|
||||
void set_name(char *name) {
|
||||
char *cmd = config_alloc_get(NVS_TYPE_STR, "autoexec1");
|
||||
char *p, *q;
|
||||
|
||||
if (!cmd) return;
|
||||
|
||||
if ((p = strstr(cmd, " -n")) != NULL) {
|
||||
q = p + 3;
|
||||
// in case some smart dude has a " -" in player's name
|
||||
while ((q = strstr(q, " -")) != NULL) {
|
||||
if (!strchr(q, '"') || !strchr(q+1, '"')) break;
|
||||
q++;
|
||||
}
|
||||
if (q) memmove(p, q, strlen(q) + 1);
|
||||
else *p = '\0';
|
||||
}
|
||||
|
||||
asprintf(&q, "%s -n \"%s\"", cmd, name);
|
||||
config_set_value(NVS_TYPE_STR, "autoexec1", q);
|
||||
|
||||
free(q);
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,9 @@ u16_t get_RSSI(void); // must provide or define as 0xffff
|
||||
u16_t get_plugged(void); // must provide or define as 0x0
|
||||
u8_t get_battery(void); // must provide 0..15 or define as 0x0
|
||||
|
||||
// set name
|
||||
void set_name(char *name); // can be defined as an empty macro
|
||||
|
||||
// to be defined to nothing if you don't want to support these
|
||||
extern struct visu_export_s {
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
@@ -480,6 +480,9 @@ static void process_setd(u8_t *pkt, int len) {
|
||||
LOG_INFO("set name: %s", setd->data);
|
||||
// confirm change to server
|
||||
sendSETDName(setd->data);
|
||||
#if EMBEDDED
|
||||
set_name(player_name);
|
||||
#endif
|
||||
// write name to name_file if -N option set
|
||||
if (name_file) {
|
||||
FILE *fp = fopen(name_file, "w");
|
||||
|
||||
Reference in New Issue
Block a user