index.html is now served from SPIFFS. You can add rfid tag -> folder mappings via the webinterface. And I've added the missing controller json data messages.

This commit is contained in:
2019-11-17 00:35:23 +01:00
parent b9a4770ff2
commit 5c15a7d4cb
6 changed files with 95 additions and 16 deletions

View File

@ -93,6 +93,7 @@ void Controller::_check_rfid() {
if (_state != LOCKED) {
_player->stop();
}
send_controller_status();
} else {
uint32_t uid = _get_rfid_card_uid();
if (uid > 0) {
@ -157,7 +158,8 @@ void Controller::_check_rfid() {
}
_player->play(pl);
send_playlist_manager_status();
//send_playlist_manager_status();
send_controller_status();
}
}
}
@ -285,6 +287,13 @@ bool Controller::process_message(String cmd) {
_player->init();
} else if (cmd.equals("reboot")) {
ESP.restart();
} else if (cmd.startsWith("add_mapping=")) {
String rest = cmd.substring(12);
uint8_t idx = rest.indexOf('=');
String id = rest.substring(0, idx);
String folder = rest.substring(idx + 1);
_pm->add_mapping(id, folder);
send_playlist_manager_status();
} else {
ERROR("Unknown command: %s\n", cmd.c_str());
return false;
@ -352,6 +361,7 @@ String Controller::json() {
case LOCKING: json["state"] = "locking"; break;
case NORMAL: json["state"] = "normal"; break;
}
json["is_rfid_present"] = _rfid_present;
JsonObject rfid = json.createNestedObject("last_rfid");
rfid["uid"] = _last_rfid_uid;
rfid["data"] = _last_rfid_data;
@ -359,7 +369,7 @@ String Controller::json() {
}
void Controller::send_player_status() {
TRACE("In send_player_status()...\n");
TRACE("In send_player_status()...\n");
if (_http_server->ws->count() > 0) {
_http_server->ws->textAll(_player->json());
@ -376,12 +386,19 @@ void Controller::send_playlist_manager_status() {
void Controller::send_position() {
TRACE("In send_position()...\n");
if (_http_server->ws->count() > 0) {
if (_http_server->ws->count() > 0 && _player->is_playing()) {
_http_server->ws->textAll(_player->position_json());
}
_last_position_info_at = millis();
}
void Controller::send_controller_status() {
TRACE("In send_controller_status()...\n");
if (_http_server->ws->count() > 0) {
_http_server->ws->textAll(json());
}
}
void Controller::inform_new_client(AsyncWebSocketClient* client) {
String s;
s += _pm->json();
@ -389,6 +406,8 @@ void Controller::inform_new_client(AsyncWebSocketClient* client) {
s += _player->json();
s += '\n';
s += _player->position_json();
s += '\n';
s += json();
client->text(s);
}