step: version-return
This commit is contained in:
1 parent
b34a3a4acd
commit
baf986a448
3 files changed
+16
-4
No files matched your search
@@ -15,6 +15,7 @@ enum ServiceCommands_e {
|
|||||||
PlaySoundPromo,
|
PlaySoundPromo,
|
||||||
PlaySoundDeny,
|
PlaySoundDeny,
|
||||||
PlaySoundChosen,
|
PlaySoundChosen,
|
||||||
|
SetMaintanence,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GameModeCommands_e {
|
enum GameModeCommands_e {
|
||||||
|
|||||||
@@ -4,8 +4,11 @@
|
|||||||
|
|
||||||
class MqttChannel {
|
class MqttChannel {
|
||||||
public:
|
public:
|
||||||
|
static constexpr array<const char*, 3> Modes = {"Undefined", "Maintanance", "Production"};
|
||||||
|
|
||||||
MqttChannel(string name, string version, SwordConfig cfg, DeviceIoState& ioStat, SeqLogger& log)
|
MqttChannel(string name, string version, SwordConfig cfg, DeviceIoState& ioStat, SeqLogger& log)
|
||||||
: Config(cfg),
|
: Version(version),
|
||||||
|
Config(cfg),
|
||||||
IoStat(ioStat),
|
IoStat(ioStat),
|
||||||
Logger(log),
|
Logger(log),
|
||||||
cfgTopic(cfg.StationPath + "cfg"),
|
cfgTopic(cfg.StationPath + "cfg"),
|
||||||
@@ -24,6 +27,7 @@ class MqttChannel {
|
|||||||
{"playSound:Promo", ServiceCommands_e::PlaySoundPromo},
|
{"playSound:Promo", ServiceCommands_e::PlaySoundPromo},
|
||||||
{"playSound:Deny", ServiceCommands_e::PlaySoundDeny},
|
{"playSound:Deny", ServiceCommands_e::PlaySoundDeny},
|
||||||
{"playSound:Chosen", ServiceCommands_e::PlaySoundChosen},
|
{"playSound:Chosen", ServiceCommands_e::PlaySoundChosen},
|
||||||
|
{"setMaintanance", ServiceCommands_e::SetMaintanence},
|
||||||
}),
|
}),
|
||||||
setCommands({
|
setCommands({
|
||||||
// cfg-topic
|
// cfg-topic
|
||||||
@@ -102,6 +106,11 @@ class MqttChannel {
|
|||||||
if (serMsg->Topic == instance.resetTopic) {
|
if (serMsg->Topic == instance.resetTopic) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (serMsg->Payload == "setMaintanance") {
|
||||||
|
std::string m{Modes[static_cast<int>(instance.IoStat.Mode)]};
|
||||||
|
instance.client.send(instance.verTopic, fmt::format("{}", instance.Version));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto payload = serMsg->Payload;
|
auto payload = serMsg->Payload;
|
||||||
if (payload == "mute") {
|
if (payload == "mute") {
|
||||||
@@ -204,6 +213,7 @@ class MqttChannel {
|
|||||||
const std::map<string, ServiceCommands_e>& getSerCommands() { return serviceCommands; }
|
const std::map<string, ServiceCommands_e>& getSerCommands() { return serviceCommands; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string Version;
|
||||||
SwordConfig Config;
|
SwordConfig Config;
|
||||||
Queue<MqttQe> MasterQueue;
|
Queue<MqttQe> MasterQueue;
|
||||||
Queue<MqttQe> MqttQueue;
|
Queue<MqttQe> MqttQueue;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using namespace std::literals::string_view_literals;
|
|||||||
using namespace std::literals::chrono_literals;
|
using namespace std::literals::chrono_literals;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const string Version = "V 0.9.2";
|
const string Version = "V 0.9.3";
|
||||||
|
|
||||||
unique_ptr<SwordConfig> SwordCfg;
|
unique_ptr<SwordConfig> SwordCfg;
|
||||||
unique_ptr<DeviceIoState> IoStat;
|
unique_ptr<DeviceIoState> IoStat;
|
||||||
@@ -87,8 +87,7 @@ int main(int argc, char* argv[]) {
|
|||||||
} else {
|
} else {
|
||||||
fmt::println("unknown {}", modeArg);
|
fmt::println("unknown {}", modeArg);
|
||||||
}
|
}
|
||||||
constexpr array<const char*, 4> modes = {"Undefined", "Maintanance", "PromoMode", "Production"};
|
log.sendBootUp(Version, MqttChannel::Modes[static_cast<int>(IoStat->Mode)]);
|
||||||
log.sendBootUp(Version, modes[static_cast<int>(IoStat->Mode)]);
|
|
||||||
|
|
||||||
MqttChannel mqtt(appName, Version, *SwordCfg, *IoStat, log);
|
MqttChannel mqtt(appName, Version, *SwordCfg, *IoStat, log);
|
||||||
auto resetCall = [&]() {
|
auto resetCall = [&]() {
|
||||||
@@ -209,6 +208,8 @@ void processProduction(MqttChannel& mqtt, SeqLogger& log) {
|
|||||||
fmt::println("Got GameStarted");
|
fmt::println("Got GameStarted");
|
||||||
log.sendEvent("Req", "GameStarted");
|
log.sendEvent("Req", "GameStarted");
|
||||||
IoStat->GameRunning = true;
|
IoStat->GameRunning = true;
|
||||||
|
|
||||||
|
system("pinctrl set 6 ip pd");
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case GameModeCommands_e::GameFinished: {
|
case GameModeCommands_e::GameFinished: {
|
||||||
|
|||||||
Reference in new issue
Block a user