Open pierregremaud opened 7 months ago
Hi @pierregremaud,
Thank you for your question. Your code is correct. Have you seen the "mqtt connected" log? Additionally, if you want to see the "topic=${topic} message=${message.toString()}
", you need to publish a message to the topic "/v3/gre-application-1@ttn/devices/23-v6-02-20/#".
You can also refer to my other repository at "https://github.com/tommy44458/light-vue3-starter" to learn how to control the topic event using "mqtt-vue-hook".
Hi,
Thank you for your quick reply. I managed to receive the messages after a few tries. Everything is working now...
Any idea how I could manage the connection globally in the main.ts file (using app.use(...)) and then do only subscribe and unsubscribe in the vue component ?
Hi @pierregremaud,
Congratulations! You can connect to the broker and subscribe to the topic from anywhere. For example, you can call mqttHook.connect() in main.ts and mqttHook.subscribe() or mqttHook.registerEvent() in a Vue component or another .ts file.
I am using Vue 3 and I managed to connect to a server and to subscribe to a topic, but i can't figure out how to display the messages..
Any help would be appreciated.
This is my code so far...