step: GameMode
This commit is contained in:
1 parent
c1e8f2a7a4
commit
313e097a53
8 files changed
+251
-46
No files matched your search
+16
-13
@@ -8,7 +8,6 @@ class MqttChannel {
|
||||
: Config(cfg),
|
||||
IoStat(ioStat),
|
||||
Logger(log),
|
||||
runTopic(cfg.StationPath + "run"),
|
||||
cfgTopic(cfg.StationPath + "cfg"),
|
||||
setTopic(cfg.StationPath + "set"),
|
||||
verTopic(cfg.StationPath + "ver"),
|
||||
@@ -16,13 +15,7 @@ class MqttChannel {
|
||||
statTopic(cfg.StationPath + "stat"),
|
||||
resetTopic(cfg.StationPath + "reset"),
|
||||
|
||||
gameCommands({
|
||||
{"gameStarted", GameModeCommands_e::GameStarted},
|
||||
{"gameFinished", GameModeCommands_e::GameFinished},
|
||||
{"stayLocked", GameModeCommands_e::GameNextTryLocked},
|
||||
{"releaseLock", GameModeCommands_e::GameNextTryRelease},
|
||||
}),
|
||||
serviceCommands({
|
||||
serviceCommands({ // cfg-topic
|
||||
{"openLock", ServiceCommands_e::SetLockOpen},
|
||||
{"closeLock", ServiceCommands_e::SetLockClose},
|
||||
{"mute", ServiceCommands_e::SetDisableSound},
|
||||
@@ -31,11 +24,18 @@ class MqttChannel {
|
||||
{"playSound:Deny", ServiceCommands_e::PlaySoundDeny},
|
||||
{"playSound:Chosen", ServiceCommands_e::PlaySoundChosen},
|
||||
}),
|
||||
setCommands({
|
||||
setCommands({ // cfg-topic
|
||||
{"volume", ServiceCommands_e::SetConfigVolume},
|
||||
{"promoDelay", ServiceCommands_e::SetConfigPromoDelay},
|
||||
}),
|
||||
subTopics{{runTopic, setTopic, cfgTopic, resetTopic}},
|
||||
gameCommands({ // set-topic
|
||||
{"gameStarted", GameModeCommands_e::GameStarted},
|
||||
{"gameFinished", GameModeCommands_e::GameFinished},
|
||||
{"stayLocked", GameModeCommands_e::GameNextTryLocked},
|
||||
{"releaseLock", GameModeCommands_e::GameNextTryRelease},
|
||||
{"abortTry", GameModeCommands_e::GameAbortTry},
|
||||
}),
|
||||
subTopics{{setTopic, cfgTopic, resetTopic}},
|
||||
client(name, cfg.BrockerUrl, subTopics,
|
||||
{cfg.MqttUser, cfg.MqttPassword}) {
|
||||
fmt::println("MQTT: Starting task:");
|
||||
@@ -90,6 +90,7 @@ class MqttChannel {
|
||||
static void runMasterService(Thread::Context& ctx, MqttChannel& instance, function<void()> resetCall, CurrMon& mon) {
|
||||
while (true) {
|
||||
auto serMsg = instance.MasterQueue.tryDequeueFor(500ms);
|
||||
// only resetTopic and cfgTopic arrive here
|
||||
instance.sendStatusMessage();
|
||||
if (!serMsg) {
|
||||
continue;
|
||||
@@ -116,6 +117,8 @@ class MqttChannel {
|
||||
if (val >= 20 && val <= 100) {
|
||||
instance.IoStat.Volume = val;
|
||||
MediaPlayer::setVolume(val);
|
||||
} else {
|
||||
instance.Logger.sendEvent("Vol", "discarded volume");
|
||||
}
|
||||
}
|
||||
if (payload.starts_with("promoDelay:")) {
|
||||
@@ -148,13 +151,13 @@ class MqttChannel {
|
||||
auto currE = mon.sampleCurrent();
|
||||
} break;
|
||||
case ServiceCommands_e::PlaySoundPromo: {
|
||||
MediaPlayer::playWavFile(instance.Config.SoundPromo);
|
||||
MediaPlayer::playWavFileAsync(instance.Config.SoundPromo);
|
||||
} break;
|
||||
case ServiceCommands_e::PlaySoundDeny: {
|
||||
MediaPlayer::playWavFile(instance.Config.getNextDeny());
|
||||
MediaPlayer::playWavFileAsync(instance.Config.getNextDeny());
|
||||
} break;
|
||||
case ServiceCommands_e::PlaySoundChosen: {
|
||||
MediaPlayer::playWavFile(instance.Config.getNextAllow());
|
||||
MediaPlayer::playWavFileAsync(instance.Config.getNextAllow());
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user