Added MQTT client, better speaker handling, fixed bug in FTP server, ...
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
#include <Arduino.h>
|
||||
#include "config.h"
|
||||
#include "player.h"
|
||||
#include "mqtt_client.h"
|
||||
#include <MFRC522.h>
|
||||
#include <MCP23S17/MCP23S17.h>
|
||||
|
||||
@ -10,6 +11,7 @@ class Controller {
|
||||
private:
|
||||
MFRC522* _rfid;
|
||||
MCP* _mcp;
|
||||
MQTTClient* _mqtt_client;
|
||||
bool _rfid_enabled = true;
|
||||
void _check_rfid();
|
||||
void _check_serial();
|
||||
@ -25,8 +27,10 @@ private:
|
||||
void _execute_command_help();
|
||||
unsigned long _button_last_pressed_at[NUM_BUTTONS];
|
||||
bool _check_button(uint8_t btn);
|
||||
unsigned long _last_mqtt_report_at = 0;
|
||||
void _send_mqtt_report();
|
||||
public:
|
||||
Controller(Player* p, MCP* m);
|
||||
String rfid_uid() { return String(_last_rfid_card_uid, HEX); }
|
||||
Controller(Player* p, MCP* m, MQTTClient* mqtt);
|
||||
String get_status_json();
|
||||
void loop();
|
||||
};
|
||||
|
18
include/mqtt_client.h
Normal file
18
include/mqtt_client.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#include <PubSubClient.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
|
||||
class MQTTClient {
|
||||
private:
|
||||
WiFiClient* _wifi_client;
|
||||
PubSubClient* _mqtt;
|
||||
unsigned long _last_reconnect_attempt;
|
||||
void _reconnect();
|
||||
public:
|
||||
MQTTClient();
|
||||
void loop();
|
||||
void publish_status(String s);
|
||||
void publish_rfid_uid(uint32_t uid);
|
||||
};
|
@ -57,7 +57,7 @@ private:
|
||||
void _play_file(String filename, uint32_t offset);
|
||||
uint32_t _id3_tag_offset(File f);
|
||||
void _finish_playing();
|
||||
void _finish_stopping();
|
||||
void _finish_stopping(bool turn_speaker_off);
|
||||
void _mute();
|
||||
void _unmute();
|
||||
void _sleep();
|
||||
@ -95,7 +95,7 @@ public:
|
||||
void play_random_album();
|
||||
bool play_song(String album, uint8_t song_index, uint32_t offset=0);
|
||||
void play_system_sound(String filename);
|
||||
void stop();
|
||||
void stop(bool turn_speaker_off=true);
|
||||
bool loop();
|
||||
void set_volume(uint8_t vol, bool save = true);
|
||||
std::list<String> ls(String path, bool withFiles=true, bool withDirs=true, bool withHidden=false);
|
||||
|
Reference in New Issue
Block a user