LMS can set player's name (only LMS scope) - release

This commit is contained in:
Philippe G
2021-03-31 19:24:34 -07:00
parent 43aa62ac56
commit 0629b017b1
4 changed files with 32 additions and 0 deletions

View File

@@ -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);
}