Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
psy0rz committed Oct 4, 2024
1 parent dacdde9 commit 3b7d2bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 6 additions & 3 deletions ledder/animations/MQTT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ export default class MQTT extends Animator {
mqttClient.on('connect', ()=>{
console.log(`MQTT: ${mqttHost.text} connected`)
this.statusMessage("conn ok")
mqttClient.subscribe(mqttTopic.text+"/#")
})

mqttClient.on('disconnect', ()=>{
console.log(`MQTT: ${mqttHost.text} disconnected`)
console.error(`MQTT: ${mqttHost.text} disconnected`)
this.statusMessage("disc.")
})

mqttClient.on('error', (e)=>{
console.log(`MQTT: ${mqttHost.text} error ${e}`)
console.error(`MQTT: ${mqttHost.text} error ${e}`)
this.statusMessage("error")
})

Expand All @@ -91,7 +92,7 @@ export default class MQTT extends Animator {

mqttClient.on('message', async (topic, messageBuf) => {
let message = messageBuf.toString()
// console.log(`MQTT ${topic}: ${message}`)
console.log(`MQTT ${topic}: ${message}`)
this.statusMessage("")

let subTopic = topic.substring(mqttTopic.text.length + 1)
Expand All @@ -104,7 +105,9 @@ export default class MQTT extends Animator {
console.log(`MQTT select ${message}`)

await this.animationManager.select(message, false).catch((e) => {
this.animationManager.stop(false)
this.statusMessage((e.message))
console.error(e.message)

})

Expand Down
12 changes: 10 additions & 2 deletions ledder/server/AnimationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,16 @@ export default class AnimationManager {

//select an animation and preset, load it and start it
public async select(animationAndPresetPath: string, keepControls: boolean) {
this.animationName = animationAndPresetPath.match(RegExp("(^.*)/"))[1]
this.presetName = animationAndPresetPath.match(RegExp("[^/]+$"))[0]

try {
this.animationName = animationAndPresetPath.match(RegExp("(^.*)/"))[1]
this.presetName = animationAndPresetPath.match(RegExp("[^/]+$"))[0]
}
catch (e)
{
console.error(`Invalid name: ${animationAndPresetPath}`)
return
}

await this.reload(keepControls)

Expand Down

0 comments on commit 3b7d2bd

Please sign in to comment.